Jump to content
  • Advertisement
Sign in to follow this  
LlamaFood

SendInput() Not Recognized By Compiler

This topic is 4912 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
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.

Share this post


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

Share this post


Link to post
Share on other sites
Try making a new project with just:
#include <windows.h>

int main()
{
SendInput(0, 0, 0);
}


and see if it compiles.

Enigma

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!