阅读:870回复:0
请教各位大虾,急!!!
我在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\");} 我一运行就死机,是什么问题? |
|