#pragma once #pragma comment(lib,"rpcrt4.lib") #include <Windows.h> #include <rpcdce.h> #include <iostream> #include <thread> #include <unordered_map> using namespace std; string getUuid() { RPC_CSTR rpcCstr; string uuidValue; UUID newUUID; UuidCreate(&newUUID); UuidToStringA(&newUUID, &rpcCstr); uuidValue = (char*)rpcCstr; RpcStringFreeA(&rpcCstr); return uuidValue; } void hashDemo() { string uuid = getUuid(); size_t hash = std::hash <string>{}(uuid); cout << "Uuid=" << uuid << endl; cout << "Hash=" << hash << endl; } int main(int args, char** argv) { hashDemo(); }
标签:rpcCstr,hash,string,uuidValue,newUUID,C++,include From: https://www.cnblogs.com/Fred1987/p/16798561.html