Skip to content

Instantly share code, notes, and snippets.

@aslatter
Created March 28, 2012 15:47
Show Gist options
  • Select an option

  • Save aslatter/2227515 to your computer and use it in GitHub Desktop.

Select an option

Save aslatter/2227515 to your computer and use it in GitHub Desktop.
Working with UUIDs on windows (with Rpc.h)
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#include <windows.h>
#include <Rpc.h>
#include <stdio.h>
int main(int argc, char** argv)
{
UUID uuid;
unsigned char *uuidStr;
if(UuidCreate(&uuid) != RPC_S_OK)
{
fprintf(stderr,"Unable to create UUID!\n");
exit(1);
}
if(UuidToStringA(&uuid, &uuidStr) != RPC_S_OK)
{
fprintf(stderr,"Unable to format UUID as string!\n");
exit(1);
}
printf("Generated UUID: %s\n", uuidStr);
if(RpcStringFreeA(&uuidStr) != RPC_S_OK)
{
fprintf(stderr,"Failed to free UUID display string!\n");
exit(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment