谢谢Veabol,现在能打开流驱动了,只是我在应用程序里检测按键好像还是没有反应,下面是代码
void CDrivertestDlg::OnButton6()
{
// TODO: Add your control notification handler code here
DWORD IDThread;
HANDLE hReadKeyThread;
hFille = CreateFile(TEXT("DKS1:"),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,0);
if(hFille==INVALID_HANDLE_VALUE)
{
MessageBox(_T("打开KEY驱动失败!"));
return;
}
else
{
MessageBox(_T("打开成功!"));
}
//创建读KEY状态线程
hReadKeyThread = CreateThread(0,0,ReadKeyThread,this,0,&IDThread);
if(hReadKeyThread ==NULL)
{
CloseHandle(hReadKeyThread);
hFille = INVALID_HANDLE_VALUE;
MessageBox(_T("创建线程失败!"));
return;
}
CloseHandle(hReadKeyThread);
}
//读KEY状态线程代码,
DWORD CDrivertestDlg::ReadKeyThread(LPVOID lparam)
{
int status;
DWORD actlen;
CString strCount;
CDrivertestDlg *pDlg = (CDrivertestDlg*)lparam;
CStatic *pCountStatic = (CStatic *)pDlg->GetDlgItem(IDC_STATIC);
// KeyCount++;
// strCount.Format(_T("%d"),KeyCount);
// pCountStatic->SetWindowText(strCount);
while(TRUE)
{
if(hFille == INVALID_HANDLE_VALUE)
{
break;
}
if(ReadFile(hFille,&status,1,&actlen,NULL)==TRUE)
{
if(status==1)
{
KeyCount++;
strCount.Format(_T("%d"),KeyCount);
pCountStatic->SetWindowText(strCount);
}
else
{
break;
}
}
else break;
}
return 1;
}
按下按键以后没有反应,是不是应用程序有问题啊?我检查了一下驱动里的IO配置,没有错误;另外对ReadFile()和XXX_Read()之间的参数传递不是很了解?哪位讲解一下,函数原型在哪儿找啊 |