GME  13
GUIDCreate.cpp
Go to the documentation of this file.
00001 #include "stdafx.h"
00002 #include "GUIDCreate.h"
00003 #include <stdio.h>
00004 /*static*/ const char * GuidCreate::format_str = "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}";
00005 
00006 CComBSTR GuidCreate::newGuid()
00007 {
00008         char res[39] = {0};
00009         GUID t_guid = GUID_NULL;
00010         ::CoCreateGuid(&t_guid);
00011                 
00012         if (t_guid != GUID_NULL)
00013         {
00014                 sprintf( res, format_str,
00015                         t_guid.Data1, t_guid.Data2, t_guid.Data3,
00016                         t_guid.Data4[0], t_guid.Data4[1], t_guid.Data4[2], t_guid.Data4[3],
00017                         t_guid.Data4[4], t_guid.Data4[5], t_guid.Data4[6], t_guid.Data4[7]);
00018         } // else send blank
00019 
00020         return CComBSTR(res);
00021 }