MFC中获取GUID
GUID:全局唯一标识 GUID(Global Unique Identifier)
// 获取全局唯一标识 GUID(Global Unique Identifier) 头文件 include <objbase.h> CString GetGUID() { GUID guid; OLECHAR arrGUID[39]={0}; CoCreateGuid(&guid); int ret = StringFromGUID2(guid, arrGUID, 39); return CString(arrGUID); // "{C876CF2F-8831-4AE1-AEAB-CFDA78EED36D}" }
或
std::string GuidToString(const GUID &guid) { char buf[39] = { 0 }; sprintf_s(buf, sizeof(buf), "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); return std::string(buf); } //使用 GUID guid; LRESULT ret = ::CoCreateGuid(&guid);//成功,返回0,即 S_OK std::string s2 = GuidToString(guid);
2. 使用Poco,参考Poco学习(二)
// GUID 或者 UUID #include <Poco/UUIDGenerator.h> int main() { Poco::UUID uuid; try { uuid = Poco::UUIDGenerator::defaultGenerator().create();//Creates a new time-based UUID std::string sRet = uuid.toString();//67440b59-4ad8-3f74-8bab-8b4ae76b4fc3 } catch (Poco::Exception& exc) { std::cerr << exc.displayText() << std::endl; return 1; } return 0; }
----------------------------
https://blog.csdn.net/semicloud/article/details/89332018
常记溪亭日暮,沉醉不知归路。兴尽晚回舟,误入藕花深处。争渡,争渡,惊起一滩鸥鹭。
昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否?知否?应是绿肥红瘦。