Yuchen
Yuchen

Reputation: 33036

How to convert from Platform::String^ to Platform::Guid^

It is super easy to go from Platform::Guid^ to Platform::String^ with the ToString() method. See the documentation for more details.

But how do we convert from Platform::String^ to Platform::Guid^?


Edit:

Both CLSIDFromString and IIDFromString will do. Please refer to the accepted answer as an example. Also please #include <wrl\wrappers\corewrappers.h>.

Upvotes: 0

Views: 1336

Answers (1)

Hans Passant
Hans Passant

Reputation: 941465

Just call in the help from the IIDFromString() function. Sample code:

Platform::String^ example("{6DDAD7B6-F8C5-42D9-B4EB-59FE94A4EA5F}");
GUID rawguid;
HRESULT hr = IIDFromString(example->Data(), &rawguid);
if (SUCCEEDED(hr)) {
    Platform::Guid guid(rawguid);
    // etc..
}

Upvotes: 5

Related Questions