navyjack
驱动牛犊
驱动牛犊
  • 注册日期2003-01-04
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:870回复:0

请教各位大虾,急!!!

楼主#
更多 发布于:2003-01-08 13:00
我在WIN2000,如下代码:
DWORD outCount;
unsigned int inBuffer;
unsigned int outBuffer;
DWORD bW;
BOOL status;
HANDLE hDevice;

hDevice = CreateFile(\"\\\\\\\\.\\\\LPT1\",
GENERIC_READ | GENERIC_WRITE,
0, // share mode none
NULL, // no security
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL ); // no template
if (hDevice == INVALID_HANDLE_VALUE) {
AfxMessageBox(\"Failed to obtain file handle to device: \");}

outBuffer=0xFF;
outCount=sizeof(outBuffer);
status = WriteFile(hDevice, &outBuffer, outCount, &bW, NULL);
if (!status) {AfxMessageBox(\"Failed on call to WriteFile - error: \");}
else{AfxMessageBox(\"Succeeded in writing bytes\");}

status = CloseHandle(hDevice);
if (!status)  {
AfxMessageBox(\"Failed on call to CloseHandle - error:\");}
else{
AfxMessageBox(\"Succeeded in closing device...exiting normally\");}

我一运行就死机,是什么问题?
游客

返回顶部