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