Print a GUID variable

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

    I know the question is quite old, but would this work maybe?

    inline std::ostream& operator <<(std::ostream& ss,GUID const& item) {
      OLECHAR* bstrGuid;
      ::StringFromCLSID(item, &bstrGuid);
      ss << bstrGuid;
      ::CoTaskMemFree(bstrGuid);
      return ss;
    }
    

提交回复
热议问题