Created
          May 27, 2015 19:09 
        
      - 
      
 - 
        
Save manassra/28c3d9270b18dbfcf4ad to your computer and use it in GitHub Desktop.  
Revisions
- 
        
manassra created this gist
May 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ ///////////////////////////////////////////// /// using CoCreateGuid /// /////////////////////////////////////////// GUID guid; std::string guidString; HRESULT hr = CoCreateGuid(&guid); if (SUCCEEDED(hr)) { stringstream stream; stream << std::hex << std::uppercase << std::setw(8) << std::setfill('0') << guid.Data1 << "-" << std::setw(4) << std::setfill('0') << guid.Data2 << "-" << std::setw(4) << std::setfill('0') << guid.Data3 << "-"; for (int i = 0; i < sizeof(guid.Data4); ++i) { if (i == 2) stream << "-"; stream << std::hex << std::setw(2) << std::setfill('0') << (int)guid.Data4[i]; } guidString = stream.str(); } ///////////////////////////////////////////// /// using boost /// /////////////////////////////////////////// boost::uuids::uuid guid = boost::uuids::random_generator()(); std::string guidString = boost::lexical_cast<string>(guid);