GUID PID format

# GUID PID format

• lundi 9 avril 2012 13:47

I know that we can get the values of properties of devices using the GUID-PID format. For example, we can get the Config Flag of a device by the following way:

"{a45c254e-df1c-4efd-8020-67d16a850e0} 12"

But the DevPKey for the corresponding property is 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0. How is this value converted to the GUID format "a45c254e-df1c-4efd-8020-67d16a850e0"? What is the general conversion logic?

### Toutes les réponses

• lundi 9 avril 2012 17:23
Modérateur

its_me_here,

The general conversion logic can be found here: http://en.wikipedia.org/wiki/Globally_Unique_Identifier .  I believe you will want to look at the  4+2+2+8*1 format.  I would give that a try.

Best Wishes - Eric

• mardi 10 avril 2012 04:57

Thank you Eric. So  the conversion is like below, right?

Base string - 0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c

Converted String: 8C7ED206-3F8A-4827-B3AB-AE9E1FAEFC6C

ie. 8,4,4,4,12 format. First 8 digits, then the remaining 4 consectutive digits, then the reminaing 4 consecutive digits, then the remaining 4 consecutive digits and the remainign 12 consecutive digts.

I think there was a mistake in converted string in the question I asked . Instead of "{a45c254e-df1c-4efd-8020-67d16a850e0}, it should have been "{a45c254e-df1c-4efd-8020-67d146a850e0}.The 4 was missing in the last section. Right?

• vendredi 13 avril 2012 21:27

Greetings,

It's best to think of the elements as types rather than digits.

For instance, in Windows, the GUID type is defined as:

typedef struct _GUID
{
unsigned long  Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char  Data4[ 8 ];
} GUID;

or // {266488C3-DDA7-421F-BAFB-B9096F525790}
DEFINE_GUID(<<name>>, 0x266488c3, 0xdda7, 0x421f, 0xba, 0xfb, 0xb9, 0x9, 0x6f, 0x52, 0x57, 0x90);

Which is 4,2,2,1[8]

Registry format: {09313DB0-F837-4EDD-AF50-A8C12C65F0FA}

which is 4 bytes, 2 bytes, 2 bytes, 2 bytes,  6 bytes

So the bytes layout is really a function of the function using it. Another common layout is:

// {A5BD6EC6-9B92-4A4A-86FD-33949EE4F9CA}
static const GUID <<name>> =
{ 0xa5bd6ec6, 0x9b92, 0x4a4a, { 0x86, 0xfd, 0x33, 0x94, 0x9e, 0xe4, 0xf9, 0xca } };

So depending on what your particular function calls for, you provide the needed format.  OLE, Registry, const, etc.