1

This is an extension to this question, which wasn't very well-received:

As this question asked -- how do you verify the validity of a motherboard UUID? From my understanding, UUIDs are generated and supplied by the motherboard vendor. There are instances where the vendor simply just does not provide a UUID, for any reason.

The script I use is this:

string UUID = string.Empty;
ManagementClass mc = new ManagementClass("Win32_ComputerSystemProduct");
ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)
{
    UUID = mo.Properties["UUID"].Value.ToString();
    break;
}
return UUID;

In the event that no vendor supplies a UUID on a particular computer, the output would be:

FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF

I noticed that in this event, the catch statement I have in place would not actually be called, since technically there's no error involved with a unsupplied UUID.

With this in mind -- how do you verify the validity of a UUID other than doing an explicit string comparison with FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF? Is the explicit string comparison even a good idea?

Community
  • 1
  • 1
theGreenCabbage
  • 5,197
  • 19
  • 79
  • 169
  • I see throwing an exception to that string explicitly as the only feasible option. – James Feb 21 '14 at 19:22
  • I'm looking at regex.. http://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid and http://stackoverflow.com/questions/136505/searching-for-uuids-in-text-with-regex. The first link's answer's regex doesn't work, trying it on my mobo's UUID, it returns a false. The second link's answer returns `true` even if the UUID is `FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF`. – theGreenCabbage Feb 21 '14 at 19:29
  • You could convert it to a Guid type first; but why? – Peter Ritchie Feb 21 '14 at 19:30
  • What is "validity" if it's more than not being a value of "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"? – Peter Ritchie Feb 21 '14 at 19:31
  • I'm not sure, Pete. I was thinking there would be other "invalid" ways other than FFFFFFFFF. But so far, Googling doesn't tell me any other way other than FFFFFF. To me, simply matching it to `FFFFF` is a bit too "rigid"; I'm not sure.. Too "dumb" I suppose..? – theGreenCabbage Feb 21 '14 at 19:33
  • The issue is that eventually, validity may become an issue with making any string validity check for this. As it is the standard for no UUID is "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF". If you were asking for the user to input it, I would say validity would be an issue, but manufactures have a standard that they all follow and that is the standard for no UUID. – James Feb 21 '14 at 19:36
  • Hi James. I see. Is there any documentation from vendors which demonstrates the "industry standard" as "FFF....FF"? I was unable to find any, other than some loose MSDN threads that talk about the FFF error. – theGreenCabbage Feb 21 '14 at 19:37
  • Start here, then have fun searching through all the documentation, it may take years, but it's there.(http://en.wikipedia.org/wiki/Universally_unique_identifier) – James Feb 21 '14 at 19:53
  • it also seems that all 0s is another way to identify a UUID that is null or not set as per this article. (http://www.boost.org/doc/libs/1_43_0/libs/uuid/uuid.html) – James Feb 21 '14 at 20:05
  • Hey James. It appears your first link to the Wikipedia UUID page, it's not about motherboard UUIDs, rather it's about software UUIDs. – theGreenCabbage Feb 21 '14 at 20:38
  • And according to MSDN, you're right -- there is the potential that it returned `000...00` too: http://msdn.microsoft.com/en-us/library/aa394105.aspx – theGreenCabbage Feb 21 '14 at 20:46

0 Answers0