Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CoCreateGuid

CoCreateGuid

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Al_Pennyworth
    wrote on last edited by
    #1

    I am calling CoCreateGuid to get the guid but now I need to take the guid and copy it into a string. I have tried several different ways but nothing is working. So far my code looks like GUID guidID; if( S_OK == CoCreateGuid(&guidID) ) { } How can I take guidID and copy it into a char string?

    J T 2 Replies Last reply
    0
    • A Al_Pennyworth

      I am calling CoCreateGuid to get the guid but now I need to take the guid and copy it into a string. I have tried several different ways but nothing is working. So far my code looks like GUID guidID; if( S_OK == CoCreateGuid(&guidID) ) { } How can I take guidID and copy it into a char string?

      J Offline
      J Offline
      Jack Puppy
      wrote on last edited by
      #2

      I use this with MFC:

      // Format is XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
      strGUID.Format(_T("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"),
      guid.Data1,
      guid.Data2,
      guid.Data3,
      guid.Data4[0],
      guid.Data4[1],
      guid.Data4[2],
      guid.Data4[3],
      guid.Data4[4],
      guid.Data4[5],
      guid.Data4[6],
      guid.Data4[7]);

      In your case, replace strGUID with a char array, and replace Format with sprintf. In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock! -- Harry Lime

      1 Reply Last reply
      0
      • A Al_Pennyworth

        I am calling CoCreateGuid to get the guid but now I need to take the guid and copy it into a string. I have tried several different ways but nothing is working. So far my code looks like GUID guidID; if( S_OK == CoCreateGuid(&guidID) ) { } How can I take guidID and copy it into a char string?

        T Offline
        T Offline
        TheGreatAndPowerfulOz
        wrote on last edited by
        #3

        Lookup the following: StringFromGUID2 StringFromIID StringFromCLSID

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups