C++Builder6(BCB6)生成UUid

/**
* @author:  HanshuaiWu
* @methodsName: GetUUid
* @description: 生成UUID
* @param:  无
* @return: AnsiString
*/
AnsiString __fastcall TSamThread::GetUUid()
{
    char buffer[64] = { 0 };
    GUID guid;

    if (CoCreateGuid(&guid))
    {
        //fprintf(stderr, "create guid error\n");
        return -1;
    }
    _snprintf(buffer, sizeof(buffer),
        "ZY%08X%04X%04x%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]);
        return (AnsiString)buffer;
}

喜欢的小伙伴点个喜欢或关注吧, 你们的鼓励是我前进的动力!

你可能感兴趣的:(C++Builder6(BCB6)生成UUid)