I have a C# app I'm writing that will be run on both Win32 and Win64
platforms. I'm limited to XP, 2003, Vista and beyond, and don't have to
support 9x/2000/NT.
This application calls other, external tools to do its work, and which
tool should be used varies depending on the platform and whether it is
64 bit or 32 bit.
Things I perceive as dead ends:
IsWow64Process. This seems to be NOT what I want, since I actually
don't care if the C# app is running in 32 bit mode or 64 bit mode --
it's irrelevant to me. What I care about is "Am I running on a
Win32-only platform, or a Win64 capable platform?"
GetNativeSystemInfo. This tells me what the physical hardware is, but
that doesn't tell me what OS is running on it.
If it comes to that, I'll write a command line tool in C++ that does
nothing but answer this question for me. But I thought I'd make sure
there was no other way before I resorted to this.
Is there a clean way to determine if I'm running on a 64-bit OS from
C#?
I will try to read responses to the group, but email CC's are greatly
appreciated.
Stew
cody - 25 Apr 2006 09:15 GMT
does sizeof(IntPtr) help?
> I have a C# app I'm writing that will be run on both Win32 and Win64
> platforms. I'm limited to XP, 2003, Vista and beyond, and don't have to
[quoted text clipped - 25 lines]
>
> Stew
StewLG - 25 Apr 2006 16:29 GMT
I can't even compile sizeof(IntPtr) in a safe way.
return sizeof(IntPtr);
Gets me this error:
Error 2 'System.IntPtr' does not have a predefined size, therefore
sizeof can only be used in an unsafe context (consider using
System.Runtime.InteropServices.Marshal.SizeOf)
cody - 25 Apr 2006 17:19 GMT
IntPtr has a static property "Size" which will tell you.
>I can't even compile sizeof(IntPtr) in a safe way.
>
[quoted text clipped - 5 lines]
> sizeof can only be used in an unsafe context (consider using
> System.Runtime.InteropServices.Marshal.SizeOf)
StewLG - 19 May 2006 16:03 GMT
Ok, I can now distinguish 32 from 64 bit platforms. This is a good
start
Now, how can I distinguish IA64 from x86-64, from C#?
cody - 19 May 2006 16:56 GMT
Iam afraid you can't with pure .net. use p/invoke for that there are many
libraries out there which detects cpu type and similar hardware
configuration stuff.
> Ok, I can now distinguish 32 from 64 bit platforms. This is a good
> start
>
> Now, how can I distinguish IA64 from x86-64, from C#?