test_charfilter.cpp

来自「Windows 2000/XP WDM設備驅動程式開發 使用 Numega 公」· C++ 代码 · 共 52 行

CPP
52
字号
// Test_CharFilter.cpp
//
// Generated by DriverWizard version DriverStudio 2.6.0 (Build 336)
//
// This console application demonstrates how to open a handle
// to a device in your driver, and communicate with the driver
// using Read, Write, and DeviceIoControl calls, as appropriate.
//
// This test program attempts to open the device using the
// GUID defined in "..\CharSampleDeviceinterface.h"

#include <stdio.h>
#include <conio.h>
#include <windows.h>

#include "..\CharSampleioctl.h"

#include "..\CharSampleDeviceinterface.h"	// Has class GUID definition

// This function is found in module OpenByIntf.cpp
HANDLE OpenByInterface(GUID* pClassGuid, DWORD instance, PDWORD pError);

// Handle to device opened in driver.
//
HANDLE	hDevice = INVALID_HANDLE_VALUE;

// Class GUID used to open device
//
GUID ClassGuid = CharSampleDevice_CLASS_GUID;

int __cdecl main(int argc, char *argv[])
{
	DWORD	Error;

	printf("Test application Test_CharFilter starting...\n");

	hDevice = OpenByInterface( &ClassGuid, 0, &Error);
	if (hDevice == INVALID_HANDLE_VALUE)
	{
		printf("ERROR opening device: (%0x) returned from CreateFile\n", GetLastError());
		exit(1);
	}
	else
	{
		printf("Device found, handle open.\n");
	}

	CHAR	bufInput[3];		// Input to device
	CHAR	bufOutput[6];	// Output from device
	ULONG	nOutput;						// Count written to bufOutput

	printf("叫块

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?