How to detect system architecture

  • Thread starter Thread starter Daniel Bello Urizarri
  • Start date Start date
D

Daniel Bello Urizarri

Hello:

I need to link with some external native library from a managed program
written in c#.
I want my program to run in any cpu, so I need to link to the appropriate
external dll.

Is there any way to know it?

Note::
Using (IntPtr.Size == 8) I cant not know If Im in an Itanium64
processor or on an AMD 64, wich have different architectures.
 
About the WMI

Not sure about using it.. The solution is very dependent of the windows
platform. What about linux and Mono? I want my application run on every
platform

Is there a way inside the .net framework?
Something like the System.Environment.OSversion..?
 
You will have to release a seperate distribution for each platform anyway,
so why not just have the user who is installing your app either select a
disti for a specific architecture (which has the value coded in the config
file) or prompt the user for the architecture in your app before loading
that dll?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Hi Nick:

Is not necesary to release a separate distribution. What I'm doing right
now is having a definition of the class "linked" using DllIimport to the
64bits dll version, but in runtime, if IntPtr.Size == 4, I create a similar
class using System.Reflection.Emit linked to de 32 bits version of the dll,
and use the new one.
A thing I can do is install only the external dll that will be used, but
then I shoud need to know the platform on the installer program. (win64 o
win32 for example).. so I have a similar problem.
 
Back
Top