Created
March 28, 2012 15:47
-
-
Save aslatter/2227515 to your computer and use it in GitHub Desktop.
Working with UUIDs on windows (with Rpc.h)
This file contains hidden or 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
| #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