SendInput() Not Recognized By Compiler

Started by
6 comments, last by LlamaFood 19 years, 4 months ago
For some reason, when I type in:
SendInput(1,0,sizeof INPUT);//Parameters invalid (just for testing purposes)
the compiler spits this in my face:
C:\...\main.cpp(259) : error C2065: 'SendInput' : undeclared identifier
C:\...\main.cpp(259) : error C2065: 'INPUT' : undeclared identifier
I'm using MSVC++ 6 on WindowsXP. Is it missing in the library or something? I'm including windows.h and I link to user32.lib. Can someone tell me what is going on?
Advertisement
Try putting

#define _WIN32_WINNT 0x0400

before you include any header files. I forget what VC6 defaulted to. The windows headers have various guards in them to not let you use api's unless you promise that you don't care if your app doesn't run on old versions. In this case SendInput doesn't exist on versions of Windows before NT 4.0 so you need to use the above #define.
-Mike
It still doesn't work. Is it possible that my version of MSVC++ just doesn't have that function? Do I need to get an update or something?
Try making a new project with just:
#include <windows.h>int main(){	SendInput(0, 0, 0);}


and see if it compiles.

Enigma
Same thing-
main.cpp(5) : error C2065: 'SendInput' : undeclared identifier
It might work if you do

#define _WIN32_WINNT 0x0500

instead of 0x0400.
in the winuser.h the guard is actually:

#if (_WIN32_WINNT > 0x0400)...WINUSERAPI UINT WINAPISendInput(    IN UINT    cInputs,     // number of input in the array    IN LPINPUT pInputs,     // array of inputs    IN int     cbSize);     // sizeof(INPUT)...#endif // (_WIN32_WINNT > 0x0400)


Try doing it like this:

#define _WIN32_WINNT 0x0500#include <windows.h>


I suggest you have a study what those defines are for. You dont want to enable/disable unwanted stuff.
oh wow. thanks- 0x0500 works

This topic is closed to new replies.

Advertisement