Возникает ошибка 458,а иногда 48.
Все типы данных вроде без ошибок.
Что в этом коде я сделал неправильно?
Заранее благодарен.
- Код: Выделить всё
Option Explicit
Public Enum POWER_ACTION
PowerActionNone = 0
PowerActionReserved
PowerActionSleep
PowerActionHibernate
PowerActionShutdown
PowerActionShutdownReset
PowerActionShutdownOff
PowerActionWarmEject
End Enum
Public Enum SYSTEM_POWER_STATE
PowerSystemUnspecified = 0
PowerSystemWorking = 1
PowerSystemSleeping1 = 2
PowerSystemSleeping2 = 3
PowerSystemSleeping3 = 4
PowerSystemHibernate = 5
PowerSystemShutdown = 6
PowerSystemMaximum = 7
End Enum
Public Type POWER_ACTION_POLICY
Action As POWER_ACTION
Flags As Long
EventCode As Long
End Type
Public Type USER_POWER_POLICY
Revision As Long
IdleAc As POWER_ACTION_POLICY
IdleDc As POWER_ACTION_POLICY
IdleTimeoutAc As Long
IdleTimeoutDc As Long
IdleSensitivityAc As Byte
IdleSensitivityDc As Byte
ThrottlePolicyAc As Byte
ThrottlePolicyDc As Byte
MaxSleepAc As SYSTEM_POWER_STATE
MaxSleepDc As SYSTEM_POWER_STATE
Reserved As Long
VideoTimeoutAc As Long
VideoTimeoutDc As Long
SpindownTimeoutAc As Long
SpindownTimeoutDc As Long
OptimizeForPowerAc As Boolean
OptimizeForPowerDc As Boolean
FanThrottleToleranceAc As Byte
FanThrottleToleranceDc As Byte
ForcedThrottleAc As Byte
ForcedThrottleDc As Byte
End Type
Public Type MACHINE_POWER_POLICY
Revision As Byte
MinSleepAc As SYSTEM_POWER_STATE
MinSleepDc As SYSTEM_POWER_STATE
ReducedLatencySleepAc As SYSTEM_POWER_STATE
ReducedLatencySleepDc As SYSTEM_POWER_STATE
DozeTimeoutAc As Long
DozeTimeoutDc As Long
DozeS4TimeoutAc As Long
DozeS4TimeoutDc As Long
MinThrottleAc As Byte
MinThrottleDc As Byte
pad1 As Byte
OverThrottledAc As POWER_ACTION_POLICY
OverThrottledDc As POWER_ACTION_POLICY
End Type
Public Type POWER_POLICY
user As USER_POWER_POLICY
machine As MACHINE_POWER_POLICY
End Type
Declare Function EnumPwrSchemes Lib "PowrProf.dll" (ByVal lpfnPwrSchemesEnumProc As Long, ByVal lParam As Long) As Boolean
Dim sName As String * 256
Dim sDesc As String * 256
Public Function PwrSchemesEnumProcFunction(ByVal uiIndex As Long, ByVal dwName As Long, ByRef sName, ByVal dwDesc As Long, ByRef sDesc, ByRef pp As POWER_POLICY, ByVal lParam As Long) As Boolean
PwrSchemesEnumProcFunction = False
'......
End Function
Sub Main()
sName = String(255, vbNullChar)
sDesc = String(255, vbNullChar)
Dim ret As Boolean
ret = EnumPwrSchemes(AddressOf PwrSchemesEnumProcFunction, 0)
End Sub