473,395 Members | 1,823 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,395 software developers and data experts.

Identify Underlying OS Platform?

Hello,

I'm trying to identify whether my C# .NET 2.0 application is running
on a Windows x64 or x86 version.

I'm trying to avoid checking the version numbers because this will
have to work on Vista too, which shares identical build numbers for
x64 and x86.

I'm currently using this:

if (IntPtr.Size == 8)
return "x64";
else
return "x86";

However, I have a question:
If it's x64, I'm going to access a native non-managed C++ library and
run specific code, and if it's x86, I'll be accessing another library.

If the user had installed .NET 32-bit edition on Windows XP x64, would
it return 8? or 4?
i.e. does the size of IntPtr depend on the Windows version's platform
or the .NET version?

More importantly, is there a more reliable (and explicit) method of
detecting x86 vs. x64?

Does IntPtr even exist in VB (for other apps on the same concept but
in VB).

Thanks!

Apr 29 '07 #1
1 2980
>i.e. does the size of IntPtr depend on the Windows version's platform
>or the .NET version?
It depends on the application and the .NET runtime version being
loaded. In a 64-bit process the 64-bit CLR will be loaded and the size
is 8. In a 32-bit application running under WOW64 the size is 4.

>Does IntPtr even exist in VB (for other apps on the same concept but
in VB).
Sure, it exists for any language supporting managed code.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Apr 29 '07 #2

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

Similar topics

1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
3
by: benny | last post by:
Hi, anyway I could get hardware id e.g. CPU id from the client platform using asp.net ? regards, benny ;-)
1
by: samy | last post by:
I have an application which invokes(calls) a webservice (on IIS 5.0 , windows 2K) every 10 seconds. After a long time(about 4 hours),the call to the webservice fails with the error ...
4
by: Goh | last post by:
Hi, I would like to know how can we implement a web page that intelligent enough to unique identify that pc have been visit before without any cookies and login user require. I have try...
12
by: weaselboy1976 | last post by:
Hello, If we have c code like what's below, we will get an error because in the stringManipulator function we attempt to modify a string literal on the second call to the function. My question...
7
by: phal | last post by:
Hi I think there are many different browsers to browse to the Internet, how can I write the javascript to identify different browser and display according to the users. Some browser disable the...
2
by: William LaMartin | last post by:
Does anyone have a method of determining if a visitor to a web page is using a Palm or Blackberry mobile device? With the code below, I can easily identify a Window CE, Pocket PC or Window...
6
by: aki27 | last post by:
Is there a way to find the platform and compiler name during compile time so that conditional compilation can be performed in C? thanks.
16
by: Alan Jones | last post by:
Hello everyone, any help would be greatly appreciated. :) What I'm trying to do may not be advisable, but here goes... I want a page named signature.php to appear conditionally as an include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
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...

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.