user1838343
user1838343

Reputation: 449

Generating UID of windows computer

I have some long strings. Each strings contain information of a windows computer (computer name, MAC address etc). I want to generate 8 character long UIDs from those strings. How I can generate that ? Is there any C++ library or method to do that.

Upvotes: 0

Views: 288

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50667

You are looking for GUIDFromString to converts a string to a GUID.

BOOL GUIDFromString(
  _In_   LPCTSTR psz,
  _Out_  LPGUID pguid
);

Alternatively, you can try CLSIDFromString. A CLSID is actually defined as:

typedef GUID CLSID;

therefore you can use CLSIDFromString to generate a GUID. Here's some sample code:

LPWSTR guidstr;
GUID guid;

...

HRESULT hr = CLSIDFromString(guidstr, (LPCLSID)&guid);
if (hr != S_OK) {
    // bad GUID string...
    ...
}

Upvotes: 1

Related Questions