var typelib = new ActiveXObject("scriptlet.typelib");
typelib.Reset();
document.getElementById("myID").innerHTML = typelib.guid;
It works well.
But i tried to call a function from the COM, it did not work.
internal static extern void Reset();
...
...
Reset();
It said Unable to find an entry point named 'Reset' in DLL 'scrobj.dll'.
1) Can i directly use PInvoke DllImport attribute to call a function from a COM DLL?
2) WHY?
Thanks.
VulpesPosted Sep 16, 2011, 9:06 AM
stevenPosted Sep 19, 2011, 2:48 AM
Sam HobbsPosted Sep 18, 2011, 10:55 PM
As for knowing if it is a COM object, one great tool is Visual Studio. If it appears in the COM tab when you try to add a reference, then you know it is a COM object. Simple. Another way is using the OLE-Com Object Viewer. Look for it in the Windows SDK Tools in the Visual Studio menu in the Start Menu.
The thing that makes a COM object a COM object is the type library. Both of the techniques above will recognize it as a COM object (if it is) mainly because of the type library. Sometimes a type library is in the same DLL as the COM object and sometimes the type library is in a tlb file.
There is a tool called Depends that can show you what is in a DLL. Depends is no longer provided by Microsoft but it is available elsewhere. Most COM objects have a DllRegisterServer entry point.
I have a few uncompleted articles in COM And ActiveX in my web site that might help. I use the term COM Automation but that is essentially the same as a COM object.
stevenPosted Sep 18, 2011, 10:11 PM
I just want to know why i cannot call it by PInvoke way. So the reason is as you said, it's not a global function which is exported by scrobj.dll, right...
I have aother question, how to know a DLL is COM object or general dynamic libarary? i can look into a COM object using OLE/COM object Viewer, How can i look into a general DLL, is there some tool like .Net reflector?
VulpesPosted Sep 17, 2011, 8:10 AM
Sam HobbsPosted Sep 17, 2011, 1:46 AM
So in your C# or VB .Net project, go to the Solution Explorer and right-click on the References tab. Select Add Reference. Then look at the COM tab and look for your COM object. If you find it, select it and click on Okay. If you don't find it, then go to the Browse tab and browse to the DLL or whatever, then click okay.