Creating a GUID from C++
How to create a GUID:
#include <iostream>
#include <objbase.h>
int main (int argc, char **argv)
{
char szGUID[] = "(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)";
const int GUID_LEN = sizeof(szGUID)/sizeof(szGUID[0]);
GUID g;
CoCreateGuid(&g);
wchar_t szwGUID[GUID_LEN];
::StringFromGUID2(g, szwGUID, GUID_LEN);
wcstombs(szGUID, szwGUID, GUID_LEN);
std::cout<<szGUID<<std::endl;
return 0;
}
Comments