开发者

"cannot find import" error when running program in Windows XP that uses ChangeWindowMessageFilter

开发者 https://www.devze.com 2023-03-22 18:04 出处:网络
I have a program that runs fine on Windows 7/Vista but gives me an error when I execute it in Windows XP. It used to run but I added a feature that, on windows 7, required the function ChangeWindowMes

I have a program that runs fine on Windows 7/Vista but gives me an error when I execute it in Windows XP. It used to run but I added a feature that, on windows 7, required the function ChangeWindowMessageFilter. The error Windows XP gives is

"Cannot find import; DLL may be missing, corrupt, or wrong version File "USER32.dll", function "ChangeWindowMessageFilter" (error 0)"

The weird part is that I have that function surrounded by an if statement that makes sure the OS version is Vista or Higher so it's not even being called. Yet there is an error. How is this happening?

开发者_Go百科

What's going on here?


Imports are resolved at load time, not execution time.


Sounds like you're doing static linking instead of dynamic linking.

Try this instead:

In the header file:

typedef BOOL (WINAPI *PFN_CHANGEWINDOWMESSAGEFILTER) (UINT, DWORD);

In the C/CPP file:

PFN_CHANGEWINDOWMESSAGEFILTER pfnChangeWindowMessageFilter = (PFN_CHANGEWINDOWMESSAGEFILTER) GetProcAddress (hModule, "ChangeWindowMessageFilter");

if (pfnChangeWindowMessageFilter) { /* Do the stuff */ }
0

精彩评论

暂无评论...
验证码 换一张
取 消