www.pudn.com > Windows 2000设备驱动程序设计指南 .zip > Testor.cpp


// Testor for Chapter 13 WMI Example Parallel Port Driver 
 
#include  
#include  
 
int main() { 
	HANDLE hDevice; 
	BOOL status; 
 
	printf("Beginning test of Event Logging Parallel Port Driver (CH13)...\n"); 
 
	hDevice = 
		CreateFile("\\\\.\\EVLPP1", 
					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", 
			"EVLPP1", GetLastError() ); 
		return 1; 
	} 
 
	printf("Succeeded in obtaining handle to EVLPP1 device.\n"); 
 
	printf("Attempting write to device...\n"); 
	char outBuffer[20]; 
	for (DWORD i=0; i