ホーム › System.Power › SetSuspendState
SetSuspendState
関数システムをサスペンドまたは休止状態に移行させる。
シグネチャ
// POWRPROF.dll
#include <windows.h>
BOOLEAN SetSuspendState(
BOOLEAN bHibernate,
BOOLEAN bForce,
BOOLEAN bWakeupEventsDisabled
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| bHibernate | BOOLEAN | in |
| bForce | BOOLEAN | in |
| bWakeupEventsDisabled | BOOLEAN | in |
戻り値の型: BOOLEAN
各言語での呼び出し定義
// POWRPROF.dll
#include <windows.h>
BOOLEAN SetSuspendState(
BOOLEAN bHibernate,
BOOLEAN bForce,
BOOLEAN bWakeupEventsDisabled
);[DllImport("POWRPROF.dll", SetLastError = true, ExactSpelling = true)]
static extern byte SetSuspendState(
[MarshalAs(UnmanagedType.U1)] bool bHibernate, // BOOLEAN
[MarshalAs(UnmanagedType.U1)] bool bForce, // BOOLEAN
[MarshalAs(UnmanagedType.U1)] bool bWakeupEventsDisabled // BOOLEAN
);<DllImport("POWRPROF.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetSuspendState(
<MarshalAs(UnmanagedType.U1)> bHibernate As Boolean, ' BOOLEAN
<MarshalAs(UnmanagedType.U1)> bForce As Boolean, ' BOOLEAN
<MarshalAs(UnmanagedType.U1)> bWakeupEventsDisabled As Boolean ' BOOLEAN
) As Byte
End Function' bHibernate : BOOLEAN
' bForce : BOOLEAN
' bWakeupEventsDisabled : BOOLEAN
Declare PtrSafe Function SetSuspendState Lib "powrprof" ( _
ByVal bHibernate As Byte, _
ByVal bForce As Byte, _
ByVal bWakeupEventsDisabled As Byte) As Byte
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetSuspendState = ctypes.windll.powrprof.SetSuspendState
SetSuspendState.restype = ctypes.c_byte
SetSuspendState.argtypes = [
ctypes.c_byte, # bHibernate : BOOLEAN
ctypes.c_byte, # bForce : BOOLEAN
ctypes.c_byte, # bWakeupEventsDisabled : BOOLEAN
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('POWRPROF.dll')
SetSuspendState = Fiddle::Function.new(
lib['SetSuspendState'],
[
Fiddle::TYPE_CHAR, # bHibernate : BOOLEAN
Fiddle::TYPE_CHAR, # bForce : BOOLEAN
Fiddle::TYPE_CHAR, # bWakeupEventsDisabled : BOOLEAN
],
Fiddle::TYPE_CHAR)#[link(name = "powrprof")]
extern "system" {
fn SetSuspendState(
bHibernate: u8, // BOOLEAN
bForce: u8, // BOOLEAN
bWakeupEventsDisabled: u8 // BOOLEAN
) -> u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("POWRPROF.dll", SetLastError = true)]
public static extern byte SetSuspendState([MarshalAs(UnmanagedType.U1)] bool bHibernate, [MarshalAs(UnmanagedType.U1)] bool bForce, [MarshalAs(UnmanagedType.U1)] bool bWakeupEventsDisabled);
"@
$api = Add-Type -MemberDefinition $sig -Name 'POWRPROF_SetSuspendState' -Namespace Win32 -PassThru
# $api::SetSuspendState(bHibernate, bForce, bWakeupEventsDisabled)#uselib "POWRPROF.dll"
#func global SetSuspendState "SetSuspendState" sptr, sptr, sptr
; SetSuspendState bHibernate, bForce, bWakeupEventsDisabled ; 戻り値は stat
; bHibernate : BOOLEAN -> "sptr"
; bForce : BOOLEAN -> "sptr"
; bWakeupEventsDisabled : BOOLEAN -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "POWRPROF.dll"
#cfunc global SetSuspendState "SetSuspendState" int, int, int
; res = SetSuspendState(bHibernate, bForce, bWakeupEventsDisabled)
; bHibernate : BOOLEAN -> "int"
; bForce : BOOLEAN -> "int"
; bWakeupEventsDisabled : BOOLEAN -> "int"; BOOLEAN SetSuspendState(BOOLEAN bHibernate, BOOLEAN bForce, BOOLEAN bWakeupEventsDisabled)
#uselib "POWRPROF.dll"
#cfunc global SetSuspendState "SetSuspendState" int, int, int
; res = SetSuspendState(bHibernate, bForce, bWakeupEventsDisabled)
; bHibernate : BOOLEAN -> "int"
; bForce : BOOLEAN -> "int"
; bWakeupEventsDisabled : BOOLEAN -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
procSetSuspendState = powrprof.NewProc("SetSuspendState")
)
// bHibernate (BOOLEAN), bForce (BOOLEAN), bWakeupEventsDisabled (BOOLEAN)
r1, _, err := procSetSuspendState.Call(
uintptr(bHibernate),
uintptr(bForce),
uintptr(bWakeupEventsDisabled),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLEANfunction SetSuspendState(
bHibernate: ByteBool; // BOOLEAN
bForce: ByteBool; // BOOLEAN
bWakeupEventsDisabled: ByteBool // BOOLEAN
): ByteBool; stdcall;
external 'POWRPROF.dll' name 'SetSuspendState';result := DllCall("POWRPROF\SetSuspendState"
, "Char", bHibernate ; BOOLEAN
, "Char", bForce ; BOOLEAN
, "Char", bWakeupEventsDisabled ; BOOLEAN
, "Char") ; return: BOOLEAN●SetSuspendState(bHibernate, bForce, bWakeupEventsDisabled) = DLL("POWRPROF.dll", "byte SetSuspendState(byte, byte, byte)")
# 呼び出し: SetSuspendState(bHibernate, bForce, bWakeupEventsDisabled)
# bHibernate : BOOLEAN -> "byte"
# bForce : BOOLEAN -> "byte"
# bWakeupEventsDisabled : BOOLEAN -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。