D
David Jackson
Hello,
There was a thread recently about how to tell if the installed version of
Windows is 32-bit or 64-bit, but that seems to have disappeared from my
newsreader so apologies for starting a new thread.
Anyway, the first suggestion was to use IntPtr.Size. That is clearly wrong,
because that will only tell you if your *application* is 32-bit or 64-bit
e.g.
32-bit app on 32-bit OS - IntPtr.Size = 4
64-bit app on 64-bit OS - IntPtr.Size = 8
32-bit app on 64-bit OS - IntPtr.Size = 4
so that's no use, and similar API calls also seem to be unreliable for the
same reason.
The second suggestion was to use WMI, specifically the OSArchitecture value
of the Win32_OperatingSystem class in the System.Management namespace. The
problem with that is that it is available only in Vista -
http://msdn2.microsoft.com/En-US/library/aa394239.aspx which makes it almost
worse than useless.
[There was also a comment that nobody really needs to know this information
anyway, which may be true, but doesn't provide a solution.]
The only way that I can find to do this is:
1) find the drive letter that Windows is installed on (from WMI)
2) add ":\\Program Files (x86)" to it
3) see if the resulting folder exists with Directory.Exists
This is fairly obviously pretty awful but is the most reliable method I have
found so far.
Can anyone suggest a better way?
Thanks,
DJ
There was a thread recently about how to tell if the installed version of
Windows is 32-bit or 64-bit, but that seems to have disappeared from my
newsreader so apologies for starting a new thread.
Anyway, the first suggestion was to use IntPtr.Size. That is clearly wrong,
because that will only tell you if your *application* is 32-bit or 64-bit
e.g.
32-bit app on 32-bit OS - IntPtr.Size = 4
64-bit app on 64-bit OS - IntPtr.Size = 8
32-bit app on 64-bit OS - IntPtr.Size = 4
so that's no use, and similar API calls also seem to be unreliable for the
same reason.
The second suggestion was to use WMI, specifically the OSArchitecture value
of the Win32_OperatingSystem class in the System.Management namespace. The
problem with that is that it is available only in Vista -
http://msdn2.microsoft.com/En-US/library/aa394239.aspx which makes it almost
worse than useless.
[There was also a comment that nobody really needs to know this information
anyway, which may be true, but doesn't provide a solution.]
The only way that I can find to do this is:
1) find the drive letter that Windows is installed on (from WMI)
2) add ":\\Program Files (x86)" to it
3) see if the resulting folder exists with Directory.Exists
This is fairly obviously pretty awful but is the most reliable method I have
found so far.
Can anyone suggest a better way?
Thanks,
DJ