我把打开设备那一部分程序贴出来,各位帮着看看:
/*
打开设备
*/
BOOL bOpenDriver (HANDLE * phDeviceHandle, PCHAR devname)
{
char completeDeviceName[64] = "";
char pcMsg[64] = "";
strcat_s(completeDeviceName,
"\\\\.\\"
);
strcat_s(completeDeviceName,
devname);
*phDeviceHandle = CreateFile( completeDeviceName,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if (*phDeviceHandle == INVALID_HANDLE_VALUE) {
return (FALSE);
} else {
return (TRUE);
}
}
if(!bOpenDriver(&hDevice,strDevname.GetBuffer(strDevname.GetLength())))
{
m_strOutput+="打开设备失败,请检查设备名是正确\r\n";
//m_btnStart.EnableWindow(FALSE);
//m_btnStop.EnableWindow(FALSE);
}
else
{
m_strOutput+="打开设备成功\r\n";
//m_btnStart.EnableWindow(TRUE);
//m_btnStop.EnableWindow(FALSE);
}