如何以编程方式检测DLL是在.NET中编译为32位还是64位?
问题描述:
到目前为止,我已经能够使用下面的代码加载DLL:如何以编程方式检测DLL是在.NET中编译为32位还是64位?
Assembly^ assembly = Assembly::LoadFrom(pathDll);
但我不知道如何检测它是否是32位或64位。
答
我认为我找到了答案。关当然,首先你必须获得与DLL相关的组件,虽然下面的代码行:
ProcessorArchitecture processor_architecture = assembly->GetName()->ProcessorArchitecture;
if (ProcessorArchitecture::Amd64 == processor_architecture)
{
// 64bits
}
if (ProcessorArchitecture::X86 == processor_architecture)
{
//32 bits
}
可能:
那么你可以通过下面的代码获得有关该平台的信息[我如何测试Windows DLL以确定它是32位还是64位?](http://stackoverflow.com/questions/495244/how-can-i-test-a-windows-dll-to-determine -if-it-is-32bit-or-64bit) – t0mm13b
你可以使用dumpbin utli语法:dumpbin/headers –