?
Solved

Convert types from CString to CLSID

Posted on 2005-05-15
4
Medium Priority
?
862 Views
Last Modified: 2013-11-20
I has:
CString string_CLSID = "{4A69B442-28BE-4991-969C-B500ADF5D8A8}"
CLSID value_CLSID;

How to get     value_CLSID    usign string_CLSID ?
0
Comment
Question by:dvplayltd
  • 2
  • 2
4 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 14005635
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);
  SysFreeString(Buffer);



More info at:
http://msdn.microsoft.com/library/en-us/com/html/36cc9037-480f-491f-a9bb-5aa1e707781e.asp
0
 
LVL 55

Expert Comment

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

Author Comment

by:dvplayltd
ID: 14005648
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 ?
0
 

Author Comment

by:dvplayltd
ID: 14005651
for --- jaime_olivares
mistake about erro is due to my absence of mind :)

your code work OK !
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

840 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