I have an MFC application that exposes a bunch of OLE objects for the application, and open documents.
I can connect to the server using the GUID of the application class (e.g.: in ruby for windows: WIN23OLE.new('{12345678-1234-1234-1234-12345678}')
) but when I try to connect using the class name WIN32OLE.new('MyApp.Application')
, it always fails with "Invalid Class String" error (HRESULT error code:0x800401f3). The same thing happens
There are no errors returned by the OLE initialisation in the MFC app, and once a connection is made by GUID, then it works fine.
I'm just really curious why the class string approach isn't working. Any ideas?
The class string is called a ProgID (short for programmatic ID), and it's really just a human-readable version of the ClassID. ProgIDs are stored in the registry under HKEY_CLASSES_ROOT, for example picking one at random from my registry:
HKEY_CLASSES_ROOT\Microsoft.XMLDOM
Under this key there is another key called CLSID:
HKEY_CLASSES_ROOT\Microsoft.XMLDOM\CLSID
And inside that key is a REG_SZ value which contains the ClassID:
{2933BF90-7B36-11D2-B20E-00C04F983E60}
So basically the way it works is that COM is going to try to find the CLSID in the registry under the specified ProgID. I'm guessing it's not there or it's inaccessible somehow. If you want to figure it out for sure, crack open REGEDIT.EXE and take a look to see if the expected registry settings are there. If they aren't, there's your answer about why it's not working (for some reason the registration of the COM component isn't creating the ProgID keys).
If the settings are there, I would recommend running Process Monitor (sysinternals.com) and set up some registry filters to see what is happening when the registry is scanned for that ProgID.
Here's a little more info about ProgIDs:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd542719(v=vs.85).aspx
User contributions licensed under CC BY-SA 3.0