How to convert GUID values

Jul 20, 2012 at 2:37pm
Hi,

This is my first time posting here, but I have found many solutions to programming problems here before. I appreciate the help in the past.

However, I did not find anything on a new problem I have recently. I need to know what is the format of this alphanumeric value: 0xaa9287b4d1 (for example).

The second part of my question is how can I go from a GUID value generated in Microsoft Visual Studio, (via Tools/Create GUID) to the format mentioned above?

this is an example of a generated GUID value: {B3855DE3-F4EE-490e-B627-CB0DB4A3FC0A}

Thank you very much for your time and help on this matter.


vanvanero
Last edited on Jul 20, 2012 at 2:38pm
Jul 20, 2012 at 3:04pm
For the first question: it is an integer number written in hexadecimal format. That means a base-16 number. Just like we normally use a base-10 numbers (like 132 means 1 * 10^2 + 3 * 10^1 + 2 * 10^0), base-16 number A3E means 10 * 16^2 + 3 * 16 + 15 * 16^0. The letters A through E stand for 10 through 15 in base-10 arithmetic. The letters "0x" in the beginning just show the compiler that what follows defines an integer number in base-16 format. Similarly, if you put 00 in the beginning of a number - it will mean the base-8 format (e.g. 00271 = 2 * 8^2 + 7 * 8^1 + 1 * 8^0). Hope this helps somewhat.

As for GUID - I don't have much experience with that, but you might want to look here: http://msdn.microsoft.com/en-us/library/ms886190.aspx

Cheers.
Jul 20, 2012 at 6:48pm
Thank you very much for your reply.......... I will look at the link and study this information.

Thanks.

Jul 20, 2012 at 7:07pm
To create a GUID programatically use CoCreateGuid():
http://msdn.microsoft.com/en-us/library/windows/desktop/ms688568%28v=vs.85%29.aspx
Jul 20, 2012 at 9:05pm
how can I go from a GUID ... to the format mentioned above?
The GUID is already expressed in hex. The 0x is removed from the front and it's broken up in places, but it's made up of hex digits. It's just a very large number, a 128 bit value.
Topic archived. No new replies allowed.