Created
April 28, 2017 09:27
-
-
Save mrousavy/c1d5ddda0f49ce945369a79613a7252f to your computer and use it in GitHub Desktop.
Create a random GUID - C
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
#include <stdio.h> | |
#include <unknwn.h> | |
void wmain(int argc, wchar_t* argv[]) | |
{ | |
GUID guid; | |
wchar_t wzGuid[39] = { 0 }; | |
int count = (1 < argc) ? _wtoi(argv[1]) : 1; | |
for (int i = 0; i < count; ++i) | |
{ | |
if (SUCCEEDED(CoCreateGuid(&guid)) && StringFromGUID2(&guid, wzGuid, sizeof(wzGuid) / sizeof(wzGuid[0]))) | |
{ | |
_putws(wzGuid); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment