⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_poweridle.cpp

📁 windows 2000/xpWDM设备驱动程序开发光盘代码
💻 CPP
字号:
// Test_PowerIdle.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 "..\PowerIdleDeviceinterface.h"

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

#include <winioctl.h>
#include "..\PowerIdleioctl.h"

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

GUID ClassGuid = PowerIdleDevice_CLASS_GUID;
// This function is found in module OpenByIntf.cpp

HANDLE OpenByInterface(
		GUID* pClassGuid, 
		DWORD instance, 
		PDWORD pError
		);

void __cdecl main(int ac, char* av[])
{
	DWORD Error;
	HANDLE hDevice;

	printf("Test application Test_PowerIdle 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");
	}

	DWORD nRet;
	BOOL status = 
		DeviceIoControl(hDevice, POWERIDLE_IOCTL_800, NULL, 0, NULL, 0, &nRet, NULL);

	if ( ! status )
	{
		printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
		exit(1);
	}
	else
		printf("DeviceIoControl Now");

	CloseHandle(hDevice);		

	exit(0);
}


⌨️ 快捷键说明

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