Converting an Atom Store GUID into a .NET GUID

Printer-friendly version

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

4
Average: 4 (7 votes)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Posted On : December 21, 2009 - 15:34
ajay-mungara's picture
Offline
Last seen: 30 weeks 4 days ago
 Brown Belt
Joined: Sep 9 2009
Points: 6641

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

Posted On : December 23, 2009 - 03:49
i-Fact Technologies's picture
Offline
Last seen: 7 weeks 2 days ago
Joined: Dec 9 2009
Points: 1866

Thank you for your valuable Information...

Posted On : May 20, 2010 - 09:11
muilenta's picture
Offline
Last seen: 11 weeks 6 days ago
Joined: Mar 30 2010
Points: 699

This thread is outdated right? The hello world example shows code using the appup GUID directly.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.