How to convert a GUID to a REFCLSID (=const CLSID &)?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How to convert a GUID to a REFCLSID (=const CLSID &)?

  1. #1
    Join Date
    Oct 2001
    Location
    Belgium
    Posts
    92

    How to convert a GUID to a REFCLSID (=const CLSID &)?

    Hi,

    Does anyone know how to convert a GUID to a REFCLSID (=const CLSID &)?


    ///When I retrieve the GUID from an OCX like below
    ITypeLib *pptlib;
    TLIBATTR *ppTLibAttrr;
    GUID guid;

    LoadTypeLib("..."/*PATH TO OCX-FIlE*/,&pptlib);
    pptlib->GetLibAttr(&ppTLibAttrr);
    guid = ppTLibAttrr->guid;

    //And I want to use this GUID to Create an ActiveX Control on an Window
    //The function fails!
    CWnd cWnd
    cWnd.CreateControl(guid, "", WS_VISIBLE|WS_CHILD, crTabRect, &m_cTab, 100); //FAIL

    //But when I write
    static CLSID const clsid = { 0xcf9904f7, 0x8623, 0x465b, { 0xa0, 0x5e, 0x9d, 0x5a, 0xa, 0x2c, 0x1a, 0xe7 } }; //ITS FROM THE SAME ACTIVEX!!!
    cWnd.CreateControl(clsid, "", WS_VISIBLE|WS_CHILD, crTabRect, &m_cTab, 100);//SUCCES
    //The Function succeeds!




    So does anyone know how to convert the "guid" to a another format so that the CWnd::CreateControl() function Succeds?

    Any Help is welcome

    Thx, you're the best

    Tom




  2. #2
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382

    Re: How to convert a GUID to a REFCLSID (=const CLSID &)?

    Since you know the complete path to the control, try using GetClassFile() to get the CLSID instead of using the ITypeLib interface.


  3. #3
    Join Date
    Mar 2002
    Location
    Izhevsk, Udmurtia, Russia
    Posts
    930

    Re: How to convert a GUID to a REFCLSID (=const CLSID &)?

    pptlib->GetLibAttr returns the GUID of Type Library for which the pptlib was received. This GUID is valid to identify the Type Library, but it can not be used to create any objects.
    Instead of ITypeLib::GetLibAttr you should use ItypeInfo::GetTypeAttr member to obtain the needed GUID. To enum the info types you chould use the ITypeLib::GetTypeInfoType.


    With best wishes,
    Vita
    With best wishes,
    Vita
    -----------------------
    Russian Software Development Network -- http://www.rsdn.ru

  4. #4
    Join Date
    Nov 2013
    Posts
    1

    Re: How to convert a GUID to a REFCLSID (=const CLSID &)?

    use

    HRESULT CLSIDFromString(
    _In_ LPCOLESTR lpsz,
    _Out_ LPCLSID pclsid
    );

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,472

    Re: How to convert a GUID to a REFCLSID (=const CLSID &)?

    Quote Originally Posted by zhi3385 View Post
    use

    HRESULT CLSIDFromString(
    _In_ LPCOLESTR lpsz,
    _Out_ LPCLSID pclsid
    );

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    Hmmm, very "wanted" reply after 11.5 years...
    Victor Nijegorodov

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center