Convert types from CString to CLSID

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

How to get     value_CLSID    usign string_CLSID ?
dvplayltdAsked:
Who is Participating?
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
There is a semicolon missing at the end of CString declaration....
0
 
dvplayltdAuthor Commented:
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
 
dvplayltdAuthor Commented:
for --- jaime_olivares
mistake about erro is due to my absence of mind :)

your code work OK !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.