Generate GUID

const char* newGUID()

{

 static char buf[64] = {0};

 GUID guid;

 if (S_OK ==
::CoCreateGuid(&guid))

 {

  _snprintf(buf, sizeof(buf)

   ,
"{%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]

   );

 }

 return (const char*)buf;

}

 

int main(int argc, char* argv[])

{

 //–COM

 CoInitialize(NULL);

 

 printf(newGUID());

 printf("\r\n");

 

 //–COM

 CoUninitialize();

 return 0;

}

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: