Convert types from CString to CLSID

Posted on 2005-05-15
Last Modified: 2013-11-20
I has:
CString string_CLSID = "{4A69B442-28BE-4991-969C-B500ADF5D8A8}"

How to get     value_CLSID    usign string_CLSID ?
Question by:dvplayltd
    LVL 55

    Accepted Solution

    Assumming you string is valid, use CLSIDFromString() function:

    HRESULT CLSIDFromString(
      LPOLESTR lpsz,
      LPCLSID pclsid

    Could be something like this:

      CString string_CLSID = "{4A69B442-28BE-4991-969C-B500ADF5D8A8}"
      CLSID value_CLSID;

      BSTR Buffer;
      Buffer= string_CLSID.AllocSysString();
      CLSIDFromString(Buffer, &value_CLSID);

    More info at:
    LVL 55

    Expert Comment

    by:Jaime Olivares
    There is a semicolon missing at the end of CString declaration....

    Author Comment

    It look good, but I recive error at  "Buffer = string_CLSID.AllocSysString();"
    xxxx: error C2228: left of '.AllocSysString' must have class/struct/union type

    how to fix it ?

    Author Comment

    for --- jaime_olivares
    mistake about erro is due to my absence of mind :)

    your code work OK !

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now