I've been scanning all over Google for code or articles explaining this but nothing seems to tell me what I need to know. Most have said to use InPtr = 4 for 32 or 8 for 64.

I just need to be able to determine whether the OS the program is currently running on is either 32bit or 64bit.

Recommended Answers

All 5 Replies

Member Avatar for Unhnd_Exception

Heres what I do to determine 32 or 64 bit. If the intptr size = 8 then 64 bit

If IntPtr.Size = 8 Then
     '64 bit machine
 Else

 End If

I thought that it would only tell if the the app is running 32 or 64 bit not the OS.

Member Avatar for Unhnd_Exception

I thought you asked if the OS is either 32 or 64.

This will tell you info on the OS if that helps.

dim s1 as string = My.Computer.Info.OSFullName
  dim s2 as string = My.Computer.Info.OSPlatform
  dim s3 as string = My.Computer.Info.OSVersion

As far as i know the first post will tell you if the os is 32 or 64. I use the first post code to determine that. In certain situations I need some chunks of code to run differently on a 64 bit machine as opposed to a 32 bit machine. Thats how I do it.

Example

If IntPtr.Size = 8 Then
      theDevDetailData.cbsize = 8
 Else
      theDevDetailData.cbsize = 5
 End If

And another thing, that code comes straight from my GarminDeviceLibrary. The application that runs it is built for Any Platform. If I hard code the cbsize to 5 and installed the app on Windows 7: It will not work. Vice Verca it would work on Windows XP.

Cool. It worked for me. Sorry about that.

Member Avatar for Unhnd_Exception

Mark it as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.