Search code examples
.netvb.netwindowsregistryremovable-storage

How do I determine the Windows version installed on a removable drive


I am unable to find out how to determine the version of Windows installed on a removable/slave drive. In my search I discovered the DriveInfo class, which has some neat stuff, but doesn't show me if the drive has XP, or Vista or higher (I need to know this since they have different directory structures and I want to automate the process of backing up their data).

Will I have to access the drive's registry somehow? I want to avoid that if possible because it's complicated, and at the end of the day I just want to do something like (crappy psuedocode):

if drive.has(XP) then

else

end if

Any help would be greatly appreciated. Thank you.


Solution

  • An alternative way to determine the operating system version is documented on the MSDN page "Getting the System Version":

    To obtain the full version number for the operating system, call the GetFileVersionInfo function on one of the system DLLs, such as Kernel32.dll, then call VerQueryValue to obtain the \StringFileInfo\\ProductVersion subblock of the file version information.

    Luckily, that will work for offline instances just as well as for the running instance. The only real complication is if you need to cope with the possibility that the system folder has been given a non-standard name.