Last active
April 26, 2018 09:53
-
-
Save kennykerr/cb7d7045f3762847eb0af1e433fb9a33 to your computer and use it in GitHub Desktop.
Generates a GUID and copies it to the clipboard.
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
// cl /EHsc /std:c++17 /O2 gclip.cpp | |
// Requires VS 2017 15.6+ and the RS4 Windows SDK. | |
#pragma comment(lib, "windowsapp") | |
#pragma comment(lib, "ole32") | |
#include <winrt/Windows.ApplicationModel.DataTransfer.h> | |
#include <windows.h> | |
using namespace winrt; | |
using namespace Windows::ApplicationModel::DataTransfer; | |
int main() | |
{ | |
init_apartment(apartment_type::single_threaded); | |
GUID guid{}; | |
CoCreateGuid(&guid); | |
wchar_t* text{}; | |
StringFromCLSID(guid, &text); | |
text[37] = 0; | |
DataPackage content; | |
content.SetText(text + 1); | |
Clipboard::SetContent(content); | |
Clipboard::Flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
auto [guid, guid_str] = make_guid ();
Have no RS4 enabled machine at hand, so just a chat :) If, I implement the above function, I would like to be able to "just" write:
DataPackage content; content.SetText( guid_str);
In other words what would be the preferred guid_str type returning from the make_guid ?