阅读:1438回复:3
有哪位好汉来救我呀!!
在学习WDM编程时,我使用书中给的一个例子进行调试,但总是出现一个错误,报告信息为:
Testor.obj : error LNK2001: unresolved external symbol __chkesp debug\\testor.exe : fatal error LNK1120: 1 unresolved externals 另附调试程序的文件源代码: /************************** #include <windows.h> #include <stdio.h> int main() { HANDLE hDevice; BOOL status; printf(\"Beginning test of Minimal PnP Parallel Port Driver (CH9)...\\n\"); hDevice = CreateFile(\"\\\\\\\\.\\\\MPNP1\", GENERIC_READ | GENERIC_WRITE, 0, // share mode none NULL, // no security OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); // no template if (hDevice == INVALID_HANDLE_VALUE) { printf(\"Failed to obtain file handle to device: \" \"%s with Win32 error code: %d\\n\", \"MPNP1\", GetLastError() ); return 1; } printf(\"Succeeded in obtaining handle to MPNP1 device.\\n\"); printf(\"Attempting write to device...\\n\"); char outBuffer[20]; for (DWORD i=0; i<sizeof(outBuffer); i++) outBuffer = (char)i; DWORD outCount = sizeof(outBuffer); DWORD bW; status = WriteFile(hDevice, outBuffer, outCount, &bW, NULL); if (!status) { printf(\"Failed on call to WriteFile - error: %d\\n\", GetLastError() ); return 2; } if (outCount == bW) { printf(\"Succeeded in writing %d bytes\\n\", outCount); printf(\"OutBuffer was: \\n\"); for (i=0; i<bW; i++) printf(\"%02X \", (UCHAR)outBuffer); printf(\"\\n\"); } else { printf(\"Failed to write the correct number of bytes.\\n\" \"Attempted to write %d bytes, but WriteFile reported %d bytes.\\n\", outCount, bW); return 3; } printf(\"Attempting to read from device...\\n\"); char inBuffer[80]; DWORD inCount = sizeof(inBuffer); DWORD bR; status = ReadFile(hDevice, inBuffer, inCount, &bR, NULL); if (!status) { printf(\"Failed on call to ReadFile - error: %d\\n\", GetLastError() ); return 4; } if (bR == bW) { printf(\"Succeeded in reading %d bytes\\n\", bR); printf(\"Buffer was: \\n\"); for (i=0; i<bR; i++) printf(\"%02X \", (UCHAR)inBuffer); printf(\"\\n\"); } else { printf(\"Failed to read the correct number of bytes.\\n\" \"Should have read %d bytes, but ReadFile reported %d bytes.\\n\", bW, inCount); return 5; } printf(\"Attempting to close device MPNP1...\\n\"); status = CloseHandle(hDevice); if (!status) { printf(\"Failed on call to CloseHandle - error: %d\\n\", GetLastError() ); return 6; } printf(\"Succeeded in closing device...exiting normally\\n\"); return 0; } ****************/ 我自己认为是VC6.0的Setting没有设好,有哪位高手知道,快告诉我,谢谢你了!! |
|
最新喜欢:samxiu |
沙发#
发布于:2002-03-02 11:09
建议贴到驱动的论坛比较好,那里有关软件方面的专家更多一点,这里还都是做硬件为主的,软件上的经验比较少。
|
|
|
板凳#
发布于:2002-03-07 08:56
你可以将以前编译得obj文件全部删掉。重新编译一下试试。
|
|
|
地板#
发布于:2002-03-08 21:52
出现这情况多半是你有一个库文件没有加到工程里去!!!!
|
|