2016-04-26 75 views
0

到目前爲止,我已經能夠使用下面的代碼加載DLL:如何以編程方式檢測DLL是在.NET中編譯爲32位還是64位?

Assembly^ assembly = Assembly::LoadFrom(pathDll); 

但我不知道如何檢測它是否是32位或64位。

+1

可能:

Assembly^ assembly = Assembly::LoadFrom(pathDll); 

那麼你可以通過下面的代碼獲得有關該平臺的信息[我如何測試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

+0

你可以使用dumpbin utli語法:dumpbin/headers

回答

1

我認爲我找到了答案。關當然,首先你必須獲得與DLL相關的組件,雖然下面的代碼行:

ProcessorArchitecture processor_architecture = assembly->GetName()->ProcessorArchitecture; 
     if (ProcessorArchitecture::Amd64 == processor_architecture) 
     { 
      // 64bits 
     } 
     if (ProcessorArchitecture::X86 == processor_architecture) 
     { 
      //32 bits 
     } 
相關問題