Runtime C # knowing whether a 32-bit or 64-bit version of the COM interface is used

I want to create a DLL class library using COM Interop, with C #, the target of ANY CPU, and register it as 32-bit and 64-bit interfaces.

I want at runtime to display which interface was used - if I am using the 32-bit version or the 64-bit version.

Any ideas?

+3
source share
2 answers

In order for a process to load a 32-bit DLL, the process must be 32-bit. And the same goes for 64-bit. So, to find out what was loaded, assuming it already worked, you just need to know the CLR bitmap:

if (System.IntPtr.Size == 8) { // 64-bit } else { // 32-bit } 

PS. for a discussion of whether you need to check for size 16, see my answer to this question .

+8
source

and again, what about 32-bit processes running on win64?

fooobar.com/questions/68040 / ...

If you are using .Net 4.0, this is one line for the current process:

Environment.Is64BitProcess

http://msdn.microsoft.com/en-us/library/system.environment.is64bitprocess.aspx

0
source

All Articles