Undeclared identifier: KEYBDINPUT

Status
Not open for further replies.
This is a pure win32 program. I've defined the winver and included windows.h but I still get the error.

error C2065: 'KEYBDINPUT' : undeclared identifier

Code:
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500

#include <windows.h>
#include "stdafx.h"
#include "resource.h"

BOOL CALLBACK LanTalkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	LoadLibrary("riched32.dll");
	DialogBox(hInstance, (char*)IDD_MAINDLG, NULL, LanTalkProc);
	return 0;
}

BOOL CALLBACK LanTalkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND hEditSend = GetDlgItem(hDlg, IDC_EDITSEND);
	HWND hChat = GetDlgItem(hDlg, IDC_CHAT);



	KEYBDINPUT ki;
	ki.wVk = VK_RETURN;
	ki.wScan = MapVirtualKeyEx(VK_RETURN, 0, GetKeyboardLayout(0));
	ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
        ki.time = 0;
	ki.dwExtraInfo = 0;
	INPUT ipEvent;
	ipEvent.type = INPUT_KEYBOARD;
	ipEvent.ki = ki;
	UINT nNumEvents = SendInput(1, &ipEvent, sizeof(INPUT));


		
	switch(message)
	{
	case WM_INITDIALOG :
		SetFocus(hEditSend);
		return FALSE;

	case WM_COMMAND :
		switch (LOWORD(wParam))
		{
		case IDOK :
		case IDCANCEL :
			EndDialog(hDlg, 0);
			return TRUE;
		case IDC_SEND :
			return TRUE;
		}
		break;
	}
	return FALSE;
}
 
Yeah my SDK paths are listed before the visual c++ ones. I noticed this same exact problem when I tried to use the GETTEXTEX structure. Is there anything else I can check? I can even zip up my whole project and upload it to my web space. I've been stuck on this problem all for a while, and I'll do anything to get past it, I'm dying to know what I'm doing wrong. Thanks for the help.
 

dereferenced

Ars Scholae Palatinae
706
It don't know what else to suggest now. You could check your winuser.h file. For mine, starting on line 4952 is this:
Code:
#if (_WIN32_WINNT > 0x0400)

typedef struct tagMOUSEINPUT {
    LONG    dx;
    LONG    dy;
    DWORD   mouseData;
    DWORD   dwFlags;
    DWORD   time;
    ULONG_PTR dwExtraInfo;
} MOUSEINPUT, *PMOUSEINPUT, FAR* LPMOUSEINPUT;

typedef struct tagKEYBDINPUT {
    WORD    wVk;
    WORD    wScan;
    DWORD   dwFlags;
    DWORD   time;
    ULONG_PTR dwExtraInfo;
} KEYBDINPUT, *PKEYBDINPUT, FAR* LPKEYBDINPUT;

typedef struct tagHARDWAREINPUT {
    DWORD   uMsg;
    WORD    wParamL;
    WORD    wParamH;
} HARDWAREINPUT, *PHARDWAREINPUT, FAR* LPHARDWAREINPUT;

#define INPUT_MOUSE     0
#define INPUT_KEYBOARD  1
#define INPUT_HARDWARE  2

typedef struct tagINPUT {
    DWORD   type;

    union
    {
        MOUSEINPUT      mi;
        KEYBDINPUT      ki;
        HARDWAREINPUT   hi;
    };
} INPUT, *PINPUT, FAR* LPINPUT;

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)
By setting _WIN32_WINNT to 0x0500 as you are the above text should be included.

Are you using the command line or the IDE? You could try just pre-processing the file and looking at the output. With the command line you just type cl /E filename.c>filename.i Then search though filename.i for KEYBDINPUT.

If you really want to upload it somewhere, I'll try to compile it and see what happens.

Good luck
 
Ok I don't know what I did different except.. I started an empty win32 app (the first project was a "simple win32 app" in the app wizard) and added a source file and pasted everything into it from the first project, and made a default dialog with ok and cancel and added stdafx.h to the project and compiled and built it with no errors. Can you explain it? I'm very curious, thanks.
 
Status
Not open for further replies.