我想在VB6中使用RegisterPowerSettingNotification。
它需要一个GUID作为参数:
HPOWERNOTIFY RegisterPowerSettingNotification(
HANDLE hRecipient,
LPCGUID PowerSettingGuid,
DWORD Flags
);
我没有找到任何有关在VB6中如何实现这个的例子。具体来说,我不明白如何定义这个GUID,我猜它不只是一个字符串。
这是我目前能想到的:
Private hPowerSrc&
Private hBattCapacity&
Private hMonitorOn&
Private hPowerScheme&
Private Const DEVICE_NOTIFY_WINDOW_HANDLE As Long = 0
Private Sub pInitPower()
hPowerSrc = RegisterPowerSettingNotification(Me.hWnd, GUID_ACDC_POWER_SOURCE, DEVICE_NOTIFY_WINDOW_HANDLE)
hBattCapacity = RegisterPowerSettingNotification(Me.hWnd, GUID_BATTERY_PERCENTAGE_REMAINING, DEVICE_NOTIFY_WINDOW_HANDLE)
hMonitorOn = RegisterPowerSettingNotification(Me.hWnd, GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE)
hPowerScheme = RegisterPowerSettingNotification(Me.hWnd, GUID_POWERSCHEME_PERSONALITY, DEVICE_NOTIFY_WINDOW_HANDLE)
End Sub
我该如何完成这个示例,包括API声明和GUID的调用?
谢谢!
(byval long, byref GUID, byval long) as long
:https://learn.microsoft.com/en-us/windows/win32/api/guiddef/ns-guiddef-guid。 - GSerg