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

Popular posts from this blog

Using Python to Automate Visio

Microsoft accounts for children - Verify that you're an adult error

Visio for home users