Подскажите пожалуйста, как корректно объявить и использовать фунцию SetActivePwrScheme из dll: "powrprof.dll". Объявляю ёё через Declare и пытаюсь обявить все Enum и Type объекты я вляющиеся параметрами этой самой фунциию При выполнении Excel просто вылетает и ничего не выдает в качестве ошибки... Вот фрагмент кода как я это делаю:
Enum POWER_ACTION
PowerActionNone = 0
PowerActionReserved
PowerActionSleep
PowerActionHibernate
PowerActionShutdown
PowerActionShutdownReset
PowerActionShutdownOff
PowerActionWarmEject
End Enum
Type POWER_ACTION_POLICY
Action As POWER_ACTION
Flags As Long
EventCode As Long
End Type
Enum SYSTEM_POWER_STATE
PowerSystemUnspecified = 0
PowerSystemWorking = 1
PowerSystemSleeping1 = 2
PowerSystemSleeping2 = 3
PowerSystemSleeping3 = 4
PowerSystemHibernate = 5
PowerSystemShutdown = 6
PowerSystemMaximum = 7
End Enum
Public Type GLOBAL_USER_POWER_POLICY
Revisiov As Long
PowerButtonAc As POWER_ACTION_POLICY
PowerButtonDc As POWER_ACTION_POLICY
SleepButtonAc As POWER_ACTION_POLICY
SleepButtonDc As POWER_ACTION_POLICY
LidCloseAc As POWER_ACTION_POLICY
LidCloseDc As POWER_ACTION_POLICY
DischargePolicy() As SYSTEM_POWER_LEVEL
GlobalFlags As Long
End Type
Public Type GLOBAL_MACHINE_POWER_POLICY
Revision As Long
LidOpenWakeAc As SYSTEM_POWER_STATE
LidOpenWakeDc As SYSTEM_POWER_STATE
BroadcastCapacityResolution As Long
End Type
Public Type GLOBAL_POWER_POLICY
user As GLOBAL_USER_POWER_POLICY
mach As GLOBAL_MACHINE_POWER_POLICY
End Type
Public Declare Function SetActivePwrScheme Lib "powrprof.dll" (ByRef uiID As UINT, ByRef lpGlobalPowerPolicy As GLOBAL_POWER_POLICY, ByRef lpPowerPolicy As POWER_POLICY) As Long
Господа специалисты, помогите пожалуйста чайнику! Очень надо!
Ответить
|