2

I need to know CLSID of COM object which I just ran via CreateObject("xxx.xxx") how can I get it?

TIA! Rafal

  • 3
    [CLSIDFromProgID()](http://msdn.microsoft.com/en-us/library/windows/desktop/ms688386(v=vs.85).aspx) and [StringFromCLSID()](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683917(v=vs.85).aspx) properly imported into your VB app is likely what you seek. Use an API and avoid hammering the registry. I'm not familiar with VB.NET and whether it has this as a native API, but it likely does as part of the COM interop layer. If so, use that. – WhozCraig Dec 11 '12 at 17:38
  • hm... And what is my ProgID() ? Is it that string which I pass to CreateObject ? – Intelligent-Infrastructure Dec 11 '12 at 17:40
  • 1
    @Intelligent-Infrastructure: The ProgId is the string you pass to `CreateObject`, yes, your `xxx.xxx` in the above. – T.J. Crowder Dec 11 '12 at 17:40
  • Yeah, what @T.J.Crowder said. its the "blah.blah" string. I'll be *amazed* if VB.NET doesn't have a native managed-code API to do this, so do some hunting and import the API's mentioned as a last resort. – WhozCraig Dec 11 '12 at 17:43
  • CLSFromProgID() should work but I didn't find a straightforward way to implement it. Many problems in details (i.e. StrPtr which is here: http://support.microsoft.com/kb/183544 ). But more or less it should work fine, however I'd love to see that there's an easier way (in Python I simply write Object.CLSID and get a string... ) – Intelligent-Infrastructure Dec 14 '12 at 10:17

1 Answers1

1

I don't think you can get that information directly from VB itself (e.g., as a side-effect or secondary result of calling CreateObject), but you can read the registry entry at HKEY_LOCAL_MACHINE\SOFTWARE\Classes\xxx.xxx and then look at its CLSID key.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875