Print a GUID variable

前端 未结 11 1890
孤城傲影
孤城傲影 2021-02-01 02:12

I have a GUID variable and I want to write inside a text file its value. GUID definition is:

typedef struct _GUID {          // size is 16
    DWORD Data1;
             


        
11条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 02:21

    In case when your code uses ATL/MFC you also could use CComBSTR::CComBSTR(REFGUID guid) from atlbase.h:

    GUID guid = ...;
    const CComBSTR guidBstr(guid);  // Converts from binary GUID to BSTR
    const CString guidStr(guidBstr); // Converts from BSTR to appropriate string, ANSI or Wide
    

    It will make conversion & memory cleanup automatically.

提交回复
热议问题