Is it x86 or x64...

  • Thread starter Thread starter ShrimpBoy
  • Start date Start date
S

ShrimpBoy

Hi!

I'm working with .NET 2005 and Framework 2.0

I'm trying to find if the program currently run on a x86 machine or a x64
machine.

Is there a way to do that?

Thanks a lot!

Fred
 
ShrimpBoy said:
I'm working with .NET 2005 and Framework 2.0

I'm trying to find if the program currently run on a x86 machine or a x64
machine.

Is there a way to do that?
If you just need to know whether your *process* is running as 32-bit or
64-bit, you can check IntPtr.Size. This is independent of platform or
processor and it's usually what processes need, if they need to know anything.

..NET offers no way of determining the specific architecture you're running
on, which is probably for the best -- for one thing, the framework is not
restricted to running on either x86 or x64, so making these assumptions can
be dangerous and/or unnecessarily restrictive.

You can do it non-portably with a combination of Environment.OSVersion and
the unmanaged GetNativeSystemInfo() function, but the best you might be able
to get out of this is that you're running on an unknown architecture which
*might* be x86 or x64 or something else altogether (if you're running on
Linux, for example). Make sure you know what you need first.
 
Ivar Lumi said:
By this time, i'm sure there is managed way(without WMI) todo it .... .

Maybe so but it's not the point. Your code technically has a fault by
assuming the only other option is 32 bit. This is something that should be
avoided even if it's unlikely to be an issue. Besides, what happens if your
code is unchanged during this time. Either way you will need to update it
for 128bit OS.

Michael
 
Back
Top