资源简介

windows2000设备驱动程序设计指南(配套光盘),老资料,看论坛有人要5分,现免费提供给大家。

资源截图

代码片段和文件信息

// Testor for Chapter 11 Timer-based Parallel Port Driver

#include 
#include 

int main() {
HANDLE hDevice;
BOOL status;
printf(“Beginning test of Timer-based Parallel Port Driver (CH11)...\n“);
hDevice =CreateFile(“\\\\.\\TMRPP1“
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“
“TMRPP1“ GetLastError() );
return 1;
}

printf(“Succeeded in obtaining handle to TMRPP1 device.\n“);

printf(“Attempting write to device...\n“);
char outBuffer[20];
for (DWORD i=0; i outBuffer[i] = (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 printf(“%02X “ (UCHAR)outBuffer[i]);
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 printf(“%02X “ (UCHAR)inBuffer[i]);
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 TMRPP1...\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;
}



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-04-02 13:09  Chap11\
     目录           0  2008-04-02 13:09  Chap11\Testor\
     目录           0  2008-04-02 13:09  Chap11\Testor\Debug\
     文件      155711  2000-09-08 13:33  Chap11\Testor\Debug\Testor.exe
     文件        2369  2004-08-17 21:17  Chap11\Testor\Testor.cpp
     文件        4284  2000-04-25 06:12  Chap11\Testor\Testor.dsp
     文件         535  2000-04-25 05:49  Chap11\Testor\Testor.dsw
     文件       33792  2004-08-17 21:17  Chap11\Testor\Testor.ncb
     文件       53760  2004-08-17 21:17  Chap11\Testor\Testor.opt
     目录           0  2008-04-02 13:09  Chap11\TimerPP\
     目录           0  2008-04-02 13:09  Chap11\TimerPP\Debug\
     文件      148480  2000-09-10 12:33  Chap11\TimerPP\Debug\TimerPP.pdb
     文件        8258  2000-09-10 12:33  Chap11\TimerPP\Debug\TimerPP.SYS
     文件       19883  2000-09-12 05:42  Chap11\TimerPP\Driver.cpp
     文件        2186  2000-09-08 13:43  Chap11\TimerPP\Driver.h
     文件         269  1995-07-17 20:59  Chap11\TimerPP\MAKEFILE
     文件         117  2000-09-12 05:42  Chap11\TimerPP\Sources
     文件        4376  2000-09-09 00:04  Chap11\TimerPP\TimerPP.dsp
     文件         732  2000-09-08 13:33  Chap11\TimerPP\TimerPP.dsw
     文件         312  2000-09-08 13:25  Chap11\TimerPP\TimerPP.reg
     文件        3667  2000-09-04 03:25  Chap11\TimerPP\Unicode.cpp
     文件        1308  2000-09-04 03:24  Chap11\TimerPP\Unicode.h
     目录           0  2008-04-02 13:09  Chap12\
     目录           0  2008-04-02 13:09  Chap12\DMASlave\
     目录           0  2008-04-02 13:09  Chap12\DMASlave\Debug\
     文件      148480  2000-09-11 07:06  Chap12\DMASlave\Debug\DMASlave.pdb
     文件        7748  2000-09-11 07:06  Chap12\DMASlave\Debug\DMASlave.SYS
     文件        4256  2000-09-09 02:24  Chap12\DMASlave\DMASlave.dsp
     文件         539  2000-09-09 00:56  Chap12\DMASlave\DMASlave.dsw
     文件       21747  2000-09-12 05:46  Chap12\DMASlave\Driver.cpp
     文件        1224  2000-09-09 02:23  Chap12\DMASlave\Driver.h
............此处省略278个文件信息

评论

共有 条评论