Converting an Atom Store GUID into a .NET GUID
I just posted about making the Atom Store SDK work in .NET. One thing I missed is that the Atom Store provides application GUID's in the format:
"0x00000000,0x00000000,0x00000000,0x00000000"
But normal .NET GUID's are in a different format:
"00000000-0000-0000-0000-000000000000"
Well, you have to be careful because you can't convert by just changing the text around. Look at that the conversion actually looks like:
App Store GUID: "0x01020304,0x05060708,0x090A0B0C,0x0D0E0F00"
.NET GUID: {04030201-0605-0807-090a-0b0c0d0e0f00}
Platform byte ordering comes into play. Now, I need someone to verify this, but I wrote a small piece of code to perform the conversion:
public static Guid ParseStoreGuid(string guidstr)
{
guidstr = guidstr.Replace("0x", "").Replace(" ", "").Replace(",", "").Replace("\r", "").Replace("\n", "");
byte[] buf = new byte[guidstr.Length / 2];
for (int i = 0; i < buf.Length; i++)
Byte.TryParse(guidstr.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber, null, out buf[((3 - (i % 4)) + ((i / 4) * 4))]);
return new Guid(buf);
}
This should do it correctly. In fact, if you call "ToArray()" on the .NET GUID, you get a byte array that look like what the App Store game.
Update: I fixed the ParseStoreGuid() method to account for the AppStore values being small-endian.
Ylian
Comments
Update to this blog post (also from Ylian) can be found at - http://appdeveloper.intel.com/en-us/blog/2009/12/20/app-store-guid
Thank you for your valuable Information...
This thread is outdated right? The hello world example shows code using the appup GUID directly.
Post new comment