StringFromGUID2 function
Applies to: desktop apps | Metro style apps
Converts a globally unique identifier (GUID) into a string of printable characters.
Syntax
int StringFromGUID2( __in REFGUID rguid, __out LPOLESTR lpsz, __in int cchMax );
Parameters
- rguid [in]
-
The GUID to be converted.
- lpsz [out]
-
A pointer to a caller-allocated string variable to receive the resulting string. The string that represents rguid includes enclosing braces.
- cchMax [in]
-
The number of characters available in the lpsz buffer.
Return value
If the function succeeds, the return value is the number of characters in the returned string, including the null terminator. If the buffer is too small to contain the string, the return value is 0.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/7/2012
REFGUID is defined differently between C++ and C!
If you are calling this function from C++, REFGUID is defined as "const GUID &", so you can just pass the GUID struct directly. However, if you are calling this function from C, REFGUID is defined as "const GUID *"! So make sure you pass the address of the GUID struct. This is particularly important if you are handed a VOID* as a pointer to a GUID.
- 5/17/2012
- KenSadahiro
Example use
OLECHAR szGuid[40]={0};
int nCount = ::StringFromGUID2(guid, szGuid, 40);
CString str(szGuid);
- 12/6/2011
- House Sparrow
- 12/6/2011
- House Sparrow
Endianness
The Data1, Data2, and Data3 fields of the
GUID structure are printed to the buffer in Big Endian hexadecimal format.
- 5/31/2011
- Daniel Trebbien
Minimum buffer size
The buffer pointed to by lpsz needs to have space for 39 wide characters; cchMax needs to be at least 39.
- 5/31/2011
- Daniel Trebbien
Returns the number of characters including the NUL terminator
The return value is either 39 or 0, indicating that the wide string pointed to by lpsz does not have space for 39 characters.
- 6/11/2007
- yecril
- 5/31/2011
- Daniel Trebbien