|
|
#define DIRECTINPUT_VERSION 0x0800
#include <windows.h>
#include <dinput.h>
LPDIRECTINPUT8 pDI = NULL;
HINSTANCE hinst;
HWND hd;
void InitInput()
{
HRESULT result;
result = DirectInput8Create(hinst,DIRECTINPUT_VERSION,
IID_IDirectInput8,(void**)&pDI,NULL);
if(result != DI_OK)
MessageBox(hd,"建立DirectInput对象失败!","建立DirectInput对象失败!",NULL);
LPDIRECTINPUTDEVICE8 pDKB;
result = pDKB->CreateDevice(GUID_SysKeyboard,
IID_IDirectInputDevice8,
(void**)&pDKB,
NULL);
if(result != DI_OK)
MessageBox(hd,"建立键盘对象失败!","建立键盘对象失败!",NULL);
result = pDKB->SetDataForMat(&c_dfDIKeyboard);
if(result != DI_OK)
MessageBox(hd,"设置数据格式失败!","设置数据格式失败!",NULL);
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam);
HWND hWndMain;
//定义窗口类
BOOL InitWindowsCLass(HINSTANCE hInstance)
{
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,"END");
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = "键盘操作";
WndClass.lpszMenuName = "键盘操作";
WndClass.style = 0;
return RegisterClass(&WndClass);
}
//初始化窗口
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd = CreateWindow("键盘操作",//窗口类名
"键盘操作",//窗口实例的标题名
WS_OVERLAPPEDWINDOW,//窗口的风格
CW_USEDEFAULT,CW_USEDEFAULT,//窗口左上角坐标为默认
CW_USEDEFAULT,CW_USEDEFAULT,//窗口的高和宽为默认值
NULL,//此窗口无父窗口
NULL,//窗口无主菜单
hInstance,//应用程序的当前句柄
NULL);//不使用该值
if(!hWnd)
return FALSE;
hd = hWnd;
hWndMain = hWnd;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//主函数
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)//WinMain函数说明
{
MSG Message;
if(!InitWindowsCLass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
hinst = hInstance;
while(GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam)
{
switch(iMessage)
{
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hWnd, iMessage, wParam, lParam) ;
}
--------------------Configuration: D3DInput - Win32 Debug--------------------
Compiling...
D3DInput.cpp
c:\documents and settings\xzc\桌面\3dinput\d3dinput.cpp(21) : error C2039: 'CreateDevice' : is not a member of 'IDirectInputDevice8A'
d:\program files\d3dsdk\include\dinput.h(1855) : see declaration of 'IDirectInputDevice8A'
c:\documents and settings\xzc\桌面\3dinput\d3dinput.cpp(32) : error C2039: 'SetDataForMat' : is not a member of 'IDirectInputDevice8A'
d:\program files\d3dsdk\include\dinput.h(1855) : see declaration of 'IDirectInputDevice8A'
执行 cl.exe 时出错.
出现这个错误是为什么?
我用vc6.0链接了dxguid.lib dinput.lib,就是不知道问题出现在哪. |
|