【问题标题】:Masm32 winApi function IsWindows10OrGreater isn't recognizedMasm32 winApi 函数 IsWindows10OrGreater 无法识别
【发布时间】:2022-11-07 17:23:08
【问题描述】:

我试图在 Masm32 中调用 winApi 函数 IsWindows10OrGreater,但出现错误 LNK2001:未解析的外部符号 _IsWindows10OrGreater@0。我也尝试在visual studio .asm中调用这个函数,但是结果是一样的。为什么 masm 不能识别这个函数?我试图用 C 代码调用这个函数,它可以工作。 这是我的代码:

.686 
.model flat, STDCALL
option casemap :none 
include D:\masm32\include\windows.inc 
include D:\masm32\macros\macros.asm 


include D:\masm32\include\masm32.inc
include D:\masm32\include\gdi32.inc
include D:\masm32\include\user32.inc
include D:\masm32\include\kernel32.inc
include D:\masm32\include\ntdll.inc


includelib D:\masm32\lib\masm32.lib
includelib D:\masm32\lib\gdi32.lib
includelib D:\masm32\lib\user32.lib
includelib D:\masm32\lib\kernel32.lib
includelib D:\masm32\lib\ntdll.lib

IsWindows10OrGreater proto STDCALL
MessageBoxA proto STDCALL, h : DWORD, lpText : DWORD, LPCSTR : DWORD, UINT : DWORD
ExitProcess proto STDCALL, uExitCode : DWORD
.data 
buflen dd 256
hello_title db ' Lab ', 0
hello_message db 'IsWindows10OrGreater: '
.code 
Start:


call IsWindows10OrGreater 
push 40h 
push offset hello_title 
push offset hello_message 

push 0 
call MessageBoxA 
push 0
call ExitProcess 
end Start 

【问题讨论】:

    标签: winapi masm32


    【解决方案1】:

    查看 IsWindows10OrGreater 的 docs,我们看到该函数是在 versionhelpers.h 中定义的。查看 versionhelpers.h,我们看到该函数未在库中定义。它写在 versionhelpers.h 中,其中 IsWindows10OrGreater 调用 IsWindowsVersionOrGreater,后者又调用 VerifyVersionInfoW

    所以在任何名为 IsWindows10OrGreater 的库中都没有符号,这就解释了为什么链接器找不到它。您应该能够从这些函数重新创建逻辑并直接调用VerifyVersionInfoW,它是导出的(从Kernel32.lib)。

    【讨论】:

      【解决方案2】:

      有没有人有解决方案?即使有上面​​提到的VerifyVersionInfoW 功能,因为我也真的很坚持...

      【讨论】:

        猜你喜欢
        • 2011-07-10
        • 2017-06-04
        • 1970-01-01
        • 1970-01-01
        • 2020-02-13
        • 2013-06-29
        • 2015-08-16
        • 2012-07-02
        • 2013-07-03
        相关资源
        最近更新 更多