473,480 Members | 3,069 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I detect if my .net application is running in 64 bit mode

Is there a function which returns is my application is in 64 bit mode?

-Martijn
Aug 21 '06 #1
4 5114
I would imagine that you could just take the size of a reference (if 4 bytes
= 32 if 8 bytes = 64) although there might be a method somewhere that
already does this.

Cheers,

Greg

"Martijn Boven" <ma*****@daxis.nlwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
Is there a function which returns is my application is in 64 bit mode?

-Martijn


Aug 21 '06 #2
You can just check the static Size property on the IntPtr class.

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

"Greg Young" <dr*******************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I would imagine that you could just take the size of a reference (if 4
bytes = 32 if 8 bytes = 64) although there might be a method somewhere that
already does this.

Cheers,

Greg

"Martijn Boven" <ma*****@daxis.nlwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
>Is there a function which returns is my application is in 64 bit mode?

-Martijn



Aug 21 '06 #3
That's smart. Thanks for the answer.

Greetings,
Martijn

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:%2****************@TK2MSFTNGP04.phx.gbl...
You can just check the static Size property on the IntPtr class.

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

"Greg Young" <dr*******************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>I would imagine that you could just take the size of a reference (if 4
bytes = 32 if 8 bytes = 64) although there might be a method somewhere
that already does this.

Cheers,

Greg

"Martijn Boven" <ma*****@daxis.nlwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
>>Is there a function which returns is my application is in 64 bit mode?

-Martijn




Aug 21 '06 #4
btw this code works fine:

public static bool Is64BitMode()
{
return System.Runtime.InteropServices.Marshal.SizeOf(type of(IntPtr))
== 8;
}

"Martijn Boven" <ma*****@daxis.nlwrote in message
news:ev**************@TK2MSFTNGP02.phx.gbl...
That's smart. Thanks for the answer.

Greetings,
Martijn

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:%2****************@TK2MSFTNGP04.phx.gbl...
> You can just check the static Size property on the IntPtr class.

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

"Greg Young" <dr*******************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>>I would imagine that you could just take the size of a reference (if 4
bytes = 32 if 8 bytes = 64) although there might be a method somewhere
that already does this.

Cheers,

Greg

"Martijn Boven" <ma*****@daxis.nlwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
Is there a function which returns is my application is in 64 bit mode?

-Martijn




Aug 21 '06 #5

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

Similar topics

5
4889
by: Daniel Loose | last post by:
Hello, in order to use my scripts developed at home directly after upload, I wish to define a variable $root at begin of each script in a way that it always - be it here at home or on any other...
1
20411
by: Scott Shaw | last post by:
Hi all, I was wondering if you could help out with this problem that I am having. What I am trying to do is detect keyboard input in a while loop without halting/pausing the loop until the key is...
6
3966
by: Stephane Belzile | last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS unit in case of power failure? Thanks
6
5131
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different...
5
11182
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
9
1876
by: Wayne Wengert | last post by:
I built an ASP application and it runs fine on my local IIS. I am trying to move the application to my web service (ISP) out on the internet. I've read several of the help articles but they all...
5
1772
by: Lara | last post by:
Hi, I am getting the following error. All the files are stored in a directory named 'web' as told by the Server Administrtor can anyone help me Server Error in '/' Application....
0
1510
by: MIke Kansky | last post by:
I need to detect when user's computer goes to idle mode. I also need to detect when user's computer comes back from the idle mode. I have an application running in Sys Tray that should let the...
15
17408
by: Eric Renken | last post by:
Is there something in System.Environment that can tell me if the program is running on a 64bit OS? What I am thinking is right now is to check the size of IntPtr and if it is 4 then it is 32bit,...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
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
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7106
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...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7022
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...
1
4799
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...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.