简体   繁体   中英

visual c++ 2010 errors importing User32.dll into 64bit win7

Running visual c++ 2010 on 64bit win7, this line

#include "C:\Windows\SysWOW64\user32.dll"

its the correct path, the errors however include variations of

1>C:\Windows\SysWOW64\user32.dll(1): error C2018: unknown character '0x3'
1>C:\Windows\SysWOW64\user32.dll(1): error C2018: unknown character '0x4'
1>C:\Windows\SysWOW64\user32.dll(1): error C2018: unknown character '0x40'
1>C:\Windows\SysWOW64\user32.dll(1): error C2146: syntax error : missing ';' before identifier 'ÿÿ¸'
1>C:\Windows\SysWOW64\user32.dll(1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I am using it to get keybd_event() working as msdn says User32.dll is a requirement. Thanks ! *Note: The errors are in a code format block because it wouldn't let me submit it otherwise

That's not how you import libraries. You just tried to include a binary. This has nothing to do with 32/64 bits.

What you need to do it add user32.lib to your library path.

You can import a library in Visual Studio by:

Project -> Properties -> Linker -> Additional Dependencies

Add "user32.lib" to the list.

使用#include <windows.h>代替

u通过需要“ windows.h”的LoadLibrary()函数加载dll文件,但是Visual Studio在运行时默认添加重要的lib文件(例如“ user32.lib”和“ kernal32.lib”等),因此您只需要包含头文件使该功能起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM