#include <stdio.h> BOOL LPCTSR2GUID(LPCTSTR szGUID, GUID &Guid) { memset(&Guid, 0, sizeof(Guid)); int nRet = _stscanf(szGUID, _T("%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 (nRet == 11)? TRUE : FALSE; } LPCTSTR GUID2LPCTS(GUID Guid) { static TCHAR szBuf[65] = {0}; _sntprintf(szBuf, 64, _T("%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 szBuf; } //测试代码 LPCTSTR szGUID = _T("E6F62D77-F3AF-42AA-8C04-C8F7F0FAC85E"); GUID tmpGuid = {0}; LPCTSR2GUID(szGUID , tmpGuid); TRACE( _T("%s"), GUID2LPCTS(tmpGuid));