本文介绍了如何在MFC中创建guid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够即时创建guids。有没有办法在MFC?我看到如何在.net中做,但我们还没有去那里。

I need to be able to create guids on the fly. Is there a way to do that in MFC? I see how to do it in .net, but we haven't gone there yet. If not, do you have pointers to some code I can use?

推荐答案

GUID guid;
HRESULT hr = CoCreateGuid(&guid);

// Convert the GUID to a string
_TUCHAR * guidStr;
UuidToString(&guid, &guidStr);

应用程序负责调用 RpcStringFree 释放为StringUuid参数中返回的字符串分配的内存。

The application is responsible for calling RpcStringFree to deallocate the memory allocated for the string returned in the StringUuid parameter.

这篇关于如何在MFC中创建guid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 16:30