📄 getd.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
Module Name:
getd.c
Abstract:
Power Manager util to query device power state.
Notes:
Revision History:
--*/
#include <windows.h>
#include <msgqueue.h>
#include <pm.h>
extern int CreateArgvArgc(TCHAR *pProgName, TCHAR *argv[20], TCHAR *pCmdLine);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpCmdLine, int nCmShow)
{
WCHAR device[1024] = {0};
TCHAR *argv[20];
int argc;
DWORD dwErr=0;
DWORD dwFlags = 0;
CEDEVICE_POWER_STATE dwState=PwrDeviceUnspecified;
UNREFERENCED_PARAMETER(hInst);
UNREFERENCED_PARAMETER(hPrevInst);
UNREFERENCED_PARAMETER(nCmShow);
//
// parse command line
//
argc = CreateArgvArgc(TEXT( "PMGETD" ), argv, lpCmdLine);
switch (argc) {
case 3:
if (!swscanf(argv[1], TEXT("%s"), &device))
dwErr = 1;
if (!swscanf(argv[2], TEXT("%x"), &dwFlags))
dwErr = 1;
break;
default:
dwErr=1;
break;
}
if (dwErr) {
RETAILMSG(1, (TEXT("PMGETD <Device> <HexDeviceFlags>\n")));
RETAILMSG(1, (TEXT(" where <Device> describes the device, e.g. DDI1:\n")));
RETAILMSG(1, (TEXT(" where <DeviceFlags> specify device flags, in hex, e.g. 1 (POWER_NAME)\n")));
RETAILMSG(1, (TEXT("Device names may be qualified with the device's class GUID. This is\n")));
RETAILMSG(1, (TEXT("required for devices that are not members of the default power-manageable\n")));
RETAILMSG(1, (TEXT("device class\n")));
RETAILMSG(1, (TEXT(" Example: PMGETD DDI1: 1001 (gets DDI1: device state, forcing an IOCTL to the driver)\n")));
RETAILMSG(1, (TEXT(" PMGETD DDI1: 1 (gets DDI1: device state)\n")));
RETAILMSG(1, (TEXT(" PMGETD {A32942B7-920C-486b-B0E6-92A702A99B35}\\DDI1: 1 (gets DDI1: device state)\n")));
RETAILMSG(1, (TEXT(" PMGETD {98C5250D-C29A-4985-AE5F-AFE5367E5006}\\NE20001 1 (gets the NDIS miniport NE20001 device state)\n")));
exit(1);
}
dwErr = GetDevicePower(device, dwFlags, &dwState);
if(dwErr != ERROR_SUCCESS) {
RETAILMSG(TRUE, (TEXT("PMSETD!GetDevicePower('%s', 0x%x) ERROR:%d\n"), device, dwFlags, dwErr));
} else {
RETAILMSG(TRUE, (TEXT("PMSETD!GetDevicePower('%s', 0x%x) succeeded, device state is %d\n"), device, dwFlags, dwState));
}
return 0;
}
// EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -