首頁 > 後端開發 > C++ > 如何使用託管程式碼確定本機 DLL 的體系結構(x86 或 x64)?

如何使用託管程式碼確定本機 DLL 的體系結構(x86 或 x64)?

Barbara Streisand
發布: 2024-12-28 03:54:08
原創
682 人瀏覽過

How Can I Determine the Architecture (x86 or x64) of a Native DLL Using Managed Code?

確定託管程式碼中本機DLL 的體系結構

要確定本機DLL 的體系結構(x64 或x86),您可以利用PE 標頭。此資訊對於作業系統載入程式正確執行 DLL 至關重要。

擷取此資料的選項之一是使用 DUMPBIN 公用程式。使用 /headers 或 /all 標誌,第一個列出的文件頭將提供體系結構資訊。以下是範例:

64 位元DLL:

dumpbin /headers cv210.dll
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 位元DLL:

dumpbin /headers acrdlg.dll
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
登入後複製

為了簡化過程,使用find 如下:

dumpbin /headers cv210.dll |find "machine"
        8664 machine (x64)
登入後複製

以上是如何使用託管程式碼確定本機 DLL 的體系結構(x86 或 x64)?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板