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