Last active
January 1, 2016 03:38
-
-
Save Temptationx/8086397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For UUID | |
#include <Rpc.h> | |
#pragma comment(lib, "Rpcrt4.lib") | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
// Create a new uuid | |
UUID uuid; | |
RPC_STATUS ret_val = ::UuidCreate(&uuid); | |
if (ret_val == RPC_S_OK) | |
{ | |
// convert UUID to LPWSTR | |
WCHAR* wszUuid = NULL; | |
::UuidToStringW(&uuid, (RPC_WSTR*)&wszUuid); | |
if (wszUuid != NULL) | |
{ | |
//TODO: do something with wszUuid | |
// free up the allocated string | |
::RpcStringFree((RPC_WSTR*)&wszUuid); | |
wszUuid = NULL; | |
} | |
else | |
{ | |
//TODO: uh oh, couldn't convert the GUID to string (a result of not enough free memory) | |
} | |
} | |
else | |
{ | |
//TODO: uh oh, couldn't create the GUID, handle this however you need to | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment