Print a GUID variable

前端 未结 11 1691
孤城傲影
孤城傲影 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:23

    Use the StringFromCLSID function to convert it to a string

    e.g.:

    GUID guid;
    CoCreateGuid(&guid);
    
    OLECHAR* guidString;
    StringFromCLSID(guid, &guidString);
    
    // use guidString...
    
    // ensure memory is freed
    ::CoTaskMemFree(guidString);
    

    Also see the MSDN definition of a GUID for a description of data4, which is an array containing the last 8 bytes of the GUID

提交回复
热议问题