c# - 如何查找 native DLL 文件是编译为 x64 还是 x86?

标签 c# .net winapi 64-bit x86-64

我想确定托管代码应用程序 ( C# ) 中的 native 程序集是编译为 x64 还是 x86。

我认为它一定在 PE header 中的某处,因为操作系统加载程序需要知道此信息,但我找不到它。当然,我更喜欢在托管代码中执行此操作,但如果有必要,我可以使用 native C++。

最佳答案

您可以使用 DUMPBIN也。使用 /headers/all 标志及其列出的第一个文件头。

dumpbin /headers cv210.dll

64 位

Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file cv210.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
            8664 machine (x64)
               6 number of sections
        4BBAB813 time date stamp Tue Apr 06 12:26:59 2010
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
            2022 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   DLL

32 位

Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file acrdlg.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               5 number of sections
        467AFDD2 time date stamp Fri Jun 22 06:38:10 2007
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            2306 characteristics
                   Executable
                   Line numbers stripped
                   32 bit word machine
                   Debug information stripped
                   DLL

“查找”可以让生活稍微轻松一些:

dumpbin /headers cv210.dll |find "machine"
        8664 machine (x64)

关于c# - 如何查找 native DLL 文件是编译为 x64 还是 x86?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/480696/

相关文章:

c# - C#中有eval函数吗?

c# - 无缓冲的 XmlReader 实现

c# - 如何在 C# 中使用 & 运算符?代码的翻译是否正确?

.net - WPF 命令和事件有什么区别?

c++ - 创建带有子窗口(控件)的分层窗口的策略

c++ - 与CreateNamedPipe重叠的CreateProcess标准输出

c# - ASP.NET MVC Excel 导出文件格式错误

c# - 用另一台电脑调用一台电脑(Dial up Modem)

c# - 跨越一组文本框的验证

listview - 在ListView win32 API中获取所选项目