Determine executing OS, not application architecture
-
I'm not sure why this has to be so hard but I've check and seen a bunch of solutions that do not work. Currently I've tried this: Private Structure SYSTEM_INFO Public wProcessorArchitecture As Integer Public wReserved As Integer Public dwPageSize As Long Public lpMinimumApplicationAddress As Long Public lpMaximumApplicationAddress As Long Public dwActiveProcessorMask As Long Public dwNumberOfProcessors As Long Public dwProcessorType As Long Public dwAllocationGranularity As Long Public wProcessorLevel As Integer Public wProcessorRevision As Integer End Structure Private Declare Sub GetNativeSystemInfo Lib "kernel32" (ByVal lpSystemInfo As SYSTEM_INFO) . . . Dim si As SYSTEM_INFO GetNativeSystemInfo(si) If si.wProcessorArchitecture = 9 Then Console.WriteLine("64 bitter") End If . . . What I noticed is that the structure never gets filled in. I'm testing this on a Windows 7 64 bit OS Any idea why this does not work or any ideas on how to figure out the OS architecture? Thanks in advance
Tony Teveris Gerber Scientific Products Senior Software Engineer Phone: 860 648 8151 Fax: 860 648 8214 83 Gerber Road West South Windsor, CT 06074
-
I'm not sure why this has to be so hard but I've check and seen a bunch of solutions that do not work. Currently I've tried this: Private Structure SYSTEM_INFO Public wProcessorArchitecture As Integer Public wReserved As Integer Public dwPageSize As Long Public lpMinimumApplicationAddress As Long Public lpMaximumApplicationAddress As Long Public dwActiveProcessorMask As Long Public dwNumberOfProcessors As Long Public dwProcessorType As Long Public dwAllocationGranularity As Long Public wProcessorLevel As Integer Public wProcessorRevision As Integer End Structure Private Declare Sub GetNativeSystemInfo Lib "kernel32" (ByVal lpSystemInfo As SYSTEM_INFO) . . . Dim si As SYSTEM_INFO GetNativeSystemInfo(si) If si.wProcessorArchitecture = 9 Then Console.WriteLine("64 bitter") End If . . . What I noticed is that the structure never gets filled in. I'm testing this on a Windows 7 64 bit OS Any idea why this does not work or any ideas on how to figure out the OS architecture? Thanks in advance
Tony Teveris Gerber Scientific Products Senior Software Engineer Phone: 860 648 8151 Fax: 860 648 8214 83 Gerber Road West South Windsor, CT 06074
Look at Environment.OSVersion
-
I'm not sure why this has to be so hard but I've check and seen a bunch of solutions that do not work. Currently I've tried this: Private Structure SYSTEM_INFO Public wProcessorArchitecture As Integer Public wReserved As Integer Public dwPageSize As Long Public lpMinimumApplicationAddress As Long Public lpMaximumApplicationAddress As Long Public dwActiveProcessorMask As Long Public dwNumberOfProcessors As Long Public dwProcessorType As Long Public dwAllocationGranularity As Long Public wProcessorLevel As Integer Public wProcessorRevision As Integer End Structure Private Declare Sub GetNativeSystemInfo Lib "kernel32" (ByVal lpSystemInfo As SYSTEM_INFO) . . . Dim si As SYSTEM_INFO GetNativeSystemInfo(si) If si.wProcessorArchitecture = 9 Then Console.WriteLine("64 bitter") End If . . . What I noticed is that the structure never gets filled in. I'm testing this on a Windows 7 64 bit OS Any idea why this does not work or any ideas on how to figure out the OS architecture? Thanks in advance
Tony Teveris Gerber Scientific Products Senior Software Engineer Phone: 860 648 8151 Fax: 860 648 8214 83 Gerber Road West South Windsor, CT 06074
Environment.OSVersion is good enough for me. your "ByVal" is obviously wrong, where is the output going to go? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Look at Environment.OSVersion
On my Windows 7 64 bit the value is "Microsoft Windows NT 6.1.7600.0"
Tony Teveris Gerber Scientific Products Senior Software Engineer Phone: 860 648 8151 Fax: 860 648 8214 83 Gerber Road West South Windsor, CT 06074
-
Environment.OSVersion is good enough for me. your "ByVal" is obviously wrong, where is the output going to go? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Right now I'm just debugging the code and just looking "quick watch" on the structure. As a first time .Net/VB coder it should be ByRef. Now it works. I'll do more testing on other OSs
Tony Teveris Gerber Scientific Products Senior Software Engineer Phone: 860 648 8151 Fax: 860 648 8214 83 Gerber Road West South Windsor, CT 06074
-
On my Windows 7 64 bit the value is "Microsoft Windows NT 6.1.7600.0"
Tony Teveris Gerber Scientific Products Senior Software Engineer Phone: 860 648 8151 Fax: 860 648 8214 83 Gerber Road West South Windsor, CT 06074
if(IntPtr.Size == 8) { //64-bit } else if(IntPtr.Size == 4) { //32-bit } This is based off the OS installed, not the CPU which is what I think you are looking for.