Sign in to follow this  

SendInput() Not Recognized By Compiler

This topic is 4748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
in the winuser.h the guard is actually:


#if (_WIN32_WINNT > 0x0400)
...
WINUSERAPI UINT WINAPI
SendInput(
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.

Share this post


Link to post
Share on other sites

This topic is 4748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this