tarunlalwani
Member
- Joined
- Oct 14, 2007
- Messages
- 7
- Programming Experience
- Beginner
Hi All,
I have to create a function that would allow me to return a object of a non default - interface from a object. I am pretty new to VB.NET and have tried below code. But i am not sure how can i convert back IntPtr to actual object. I don't want to reference the actual library of the object because this function would be used at run-time for any object and for any Interface.
Any pointers or help is realy appreciated
I have to create a function that would allow me to return a object of a non default - interface from a object. I am pretty new to VB.NET and have tried below code. But i am not sure how can i convert back IntPtr to actual object. I don't want to reference the actual library of the object because this function would be used at run-time for any object and for any Interface.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim IID_IOleContainer = New Guid("{0000011b-0000-0000-C000-000000000046}")
Dim IID_IWebBrowser2 = New Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E")
Dim IID_IHTMLDocument2 = New Guid("332C4425-26CB-11D0-B483-00C04FD90119")
Dim IID_IHTMLElement = New Guid("3050F1FF-98B5-11CF-BB82-00AA00BDCE0B")
Dim IID_IEnumUnknown = New Guid("00000100-0000-0000-C000-000000000046")
Dim IID_IDispatch = New Guid("00020400-0000-0000-C000-000000000046")
Dim IID_IUnknown = New Guid("00000000-0000-0000-C000-000000000046")
Dim t As System.Type
t = System.Type.GetTypeFromCLSID(IID_IHTMLDocument2)
Dim u As mshtml.IHTMLElement
Dim x
x = CreateObject("InternetExplorer.Application")
x.visible = True
x.navigate2("www.google.com")
Do
Loop While x.busy
Dim y
y = Marshal.GetIUnknownForObject(x.document)
Dim z, b
Dim A As IntPtr
Dim f As Object
Dim g As mshtml.IHTMLDocument2
Dim c As Type, d
A = Nothing
z = Marshal.QueryInterface(y, IID_IOleContainer, A)
'Not sure how to convert this A intPtr to a callable object
'So that i can use A.EnumObjects
'b = t.InvokeMember("title", Reflection.BindingFlags.IgnoreCase + Reflection.BindingFlags.GetProperty, Nothing, A, Nothing)
'c = a.GetType()
'c.InvokeMember("title", Reflection.BindingFlags.GetProperty)
'DirectCast(x.document, )
End Sub
Any pointers or help is realy appreciated