How to use CLSIDFromProgID function.
URGENT!! Help me read ClsID From ProgramID
Hi,
I want to get ClsID from ProgID
I'm using
HRESULT CLSIDFromProgID( LPCOLESTR lpszProgID, //Pointer to the ProgID
LPCLSID pclsid //Pointer to the CLSID);
My ProgID is "MY.COMCLASS.1"
How to pass this ProgID to above func in LPCOLESTR form and get clsid in CLSID format.
Thanks in advance
Shalini
Re: How to use CLSIDFromProgID function.
use: CLSIDFromrogID(L"MY.COMCLASS.1", &clsid.), where CLSID clsid.
Sincerely, Mihai
Re: How to use CLSIDFromProgID function.
Hi Shalini,
Before using "ClsIDFromProgID" you need to convert the ProgID string into OLE String using "T2OLE".
Follow the sequence of steps,
USES_CONVERSION; // macro for using OLE string Conversions
LPCOLESTR lpszProgID = T2OLE("MY.COMCLASS.1") ;
CLSID clsid ;
RESULT hr = CLSIDFromProgID( lpszProgID, &clsid) ;
if(SUCCESS(hr)
// you got the CLSID for the given ProgID,
else
// your ProgID may not be registered.
Re: How to use CLSIDFromProgID function.
Hi Shalini,
CLSID clsid;
HRESULT hr = CLSIDFromProgID("MY.COMCLASS.1", &clsid);
if(FAILED(hr))
{
ShowErr("CLSIDFromProgID() failed", hr);
return;
} // Start the server...
IUnknown *pUnk = NULL;
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER,IID_IUnknown, (void **)&pUnk);
if(FAILED(hr)) {
ShowErr("CoCreateInstance() failed", hr);
return;
}
Hope this helps u..
Sunil