473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Determine if OS is x64 or 32bits?

Hi,

I can determine that my OS is:

"Microsoft Windows NT 5.2.3790 Service Pack 1"

via calls to OperatingSystem(pID, ver) and BuildOperatingSystemObjects()

Now, I have 2 Windows 2003 Enterprise servers, one is x32 and one is x64.
They both return the same above OS information. How through code, can I
determine if the OS is 32bit or 64bit?

Thanks.
Sep 8 '06 #1
4 4007
tchinla,

A dirty way to do it would be to check the static Size property on the
IntPtr class. It will be 32 for 32-bit machines, and 64 for 64-bit
machines.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tchinla" <tc*****@discussions.microsoft.comwrote in message
news:FF**********************************@microsof t.com...
Hi,

I can determine that my OS is:

"Microsoft Windows NT 5.2.3790 Service Pack 1"

via calls to OperatingSystem(pID, ver) and BuildOperatingSystemObjects()

Now, I have 2 Windows 2003 Enterprise servers, one is x32 and one is x64.
They both return the same above OS information. How through code, can I
determine if the OS is 32bit or 64bit?

Thanks.

Sep 8 '06 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:ew**************@TK2MSFTNGP05.phx.gbl...
| tchinla,
|
| A dirty way to do it would be to check the static Size property on the
| IntPtr class. It will be 32 for 32-bit machines, and 64 for 64-bit
| machines.
|

Not exactly, it will be 32 for 32 Bit applictions running on 32 and 64 bit
machines (whetever OS version), only when it's 64 you are sure running a 64
bit OS.

Willy.
Sep 8 '06 #3
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrites:
A dirty way to do it would be to check the static Size property on the
IntPtr class. It will be 32 for 32-bit machines, and 64 for 64-bit
machines.
Can you suggest any "non-dirty" way to achieve this? I just thought that
checking IntPtr.Size is the suggested way, as this even documented
behaviour.

Best regards,
Martin
Sep 8 '06 #4
"tchinla" <tc*****@discussions.microsoft.comwrote
Now, I have 2 Windows 2003 Enterprise servers, one is x32 and one is x64.
They both return the same above OS information. How through code, can I
determine if the OS is 32bit or 64bit?
As far as I know, the best way to do this is through WMI.

Doug Holland (one of the C# MVP's) did this recently using the WMI Code
Creator. A bit more detail can be found on his blog:
http://msmvps.com/blogs/cdistilled/a...29/110760.aspx

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins
Sep 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nathan Sokalski | last post by:
I want to determine the operating system using ASP (or VBScript inside of ASP). I tried to get it using the Request. ServerVariables(EnvironmentVariable) method. On the web page about ASP in which...
5
by: Hennie de Nooijer | last post by:
Hi, This is a diffcult issue to explain. I hope to make my problem clear to you. SITUATION I'm building A SLA Query for a customer. This customer has an awkward way to determine the SLA results...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
9
by: VBS Programer | last post by:
I am working with a thermal printer that returns it's status in a string. In vb6.0 I would use the MidB,AscB functions to examine the first 32 bits. What can I use in vb.net to do the same.
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
9
by: Noel Milton | last post by:
Hi: Ok, I've just read in up to 65,535 bytes into a char array (using the recvfrom socket API call). So I have an array of 8 bit char's (char recvString;). Now, four (4) consecutive bytes...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
10
by: Woody Ling | last post by:
In 32 bits DB2 environment, is it meaningful to set sheapthres larger than 256MB for the following case.. 1. Intra-parallel is ON 2. Intra-parallel is OFF
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.