Get CLSID from ProgID

1.3k views Asked by At

I am working on small program using com component on windows 10 1909, but I've got a problem with com function CLSIDFromProgID. The c++ code is as follows.

CoInitialize(NULL);
HRESULT hr = NULL;
CLSID clsid;
LPOLESTR pProgID = L"ProvisioningWapDPURemote";
hr = ProgIDFromCLSID(clsid, &pProgID);

I checked out that the progid exists in registry, but whenver I execute this code, ProgIDFromCLSID function returns invalid class string. What's more, when I get progid from clsid, the clsid I got is same as original one, I mean "ProvisioningWapDPURemote". I cannot find what the problem is. Could anyone help me?

1

There are 1 answers

0
Remy Lebeau On

Your question mentions CLSIDFromProgID(), but your code is calling ProgIDFromCLSID() instead. You need to call the former, eg:

CLSID clsid;
LPOLESTR pProgID = L"ProvisioningWapDPURemote";
HRESULT hr = CLSIDFromProgID(pProgID, &clsid);