CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    4

    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


  2. #2
    Join Date
    May 1999
    Posts
    48

    Re: How to use CLSIDFromProgID function.

    use: CLSIDFromrogID(L"MY.COMCLASS.1", &clsid.), where CLSID clsid.
    Sincerely, Mihai


  3. #3
    Join Date
    Apr 1999
    Posts
    3

    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.





  4. #4
    Guest

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured