COM and interfaces
-
Ok, here's the deal. I have an Active-X control on a form. I call a function off that control and get an object. This object I get does NOT have a typelib that I can create a RCW from, but I do know that functions and properties it has. So, right now I created a class that just thunks down using the InvokeMethod stuff. However, I'd like to use standard .NET interfaces instead. The problem is that I can't seem to get the object to cast to the interface, nor do I know the GUID for the object. Is there any way of forcing the COM object to route thru a interface I've created? Thanks. -- Joel Lucsy
-
Ok, here's the deal. I have an Active-X control on a form. I call a function off that control and get an object. This object I get does NOT have a typelib that I can create a RCW from, but I do know that functions and properties it has. So, right now I created a class that just thunks down using the InvokeMethod stuff. However, I'd like to use standard .NET interfaces instead. The problem is that I can't seem to get the object to cast to the interface, nor do I know the GUID for the object. Is there any way of forcing the COM object to route thru a interface I've created? Thanks. -- Joel Lucsy
What you could do is use Ole View (go to Run, type oleview and hit enter). Select File -> View TypeLib... and select you ActiveX control. Once you have the control open in the ITypeLib Viewer select File -> Save As. This will allow you to save the contents to a .idl file (Interface Definition Language). You can now use the MIDL compiler to generate a type library from the .idl. Once you have a .tlb file you can use one of the .NET command line tools to generate the appropriate interop assemblies. Use tlbimp.exe to generate an output assembly based on the COM-based type library you just generated. Use the newly generated assemblies in your .NET project. HTH - Nick Parker
My Blog | My Articles -
What you could do is use Ole View (go to Run, type oleview and hit enter). Select File -> View TypeLib... and select you ActiveX control. Once you have the control open in the ITypeLib Viewer select File -> Save As. This will allow you to save the contents to a .idl file (Interface Definition Language). You can now use the MIDL compiler to generate a type library from the .idl. Once you have a .tlb file you can use one of the .NET command line tools to generate the appropriate interop assemblies. Use tlbimp.exe to generate an output assembly based on the COM-based type library you just generated. Use the newly generated assemblies in your .NET project. HTH - Nick Parker
My Blog | My ArticlesNope, can't do that. The Active-X control doesn't provide a typelib interface for the internal api I'm trying to access. The control itself has a typelib for interacting with the visible component, but the internal api you can get to. For further information, I'm interacting with Adobe's SVG control. You can retrieve the internal DOM document from the COM interface, but Adobe doesn't provide a typelib for interacting with it. The functions and properties available are identical to the Javascript calls you can make from the browser, so I know the interface it provides. I just can't apply a .NET interface to the objects I get back. Any ideas? Is there a way to get the guid from the COM object I get? It seems in order to apply an interface I need a guid. -- Joel Lucsy