test_powersleep.cpp
来自「usb wdm开发的电源管理 电源处于休眠状态的例程。」· C++ 代码 · 共 66 行
CPP
66 行
// Test_PowerSleep.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 "..\PowerSleepDeviceinterface.h"
#include <stdio.h>
#include <windows.h>
#include <winioctl.h>
#include "..\PowerSleepioctl.h"
#include "..\PowerSleepDeviceinterface.h" // Has class GUID definition
GUID ClassGuid = PowerSleepDevice_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;
hDevice = OpenByInterface( &ClassGuid, 0, &Error);
printf("Test application Test_PowerSleep 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, POWERSLEEP_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 + =
减小字号Ctrl + -
显示快捷键?