Win32 API 日本語リファレンス
ホームSystem.Power › PowerSetUserConfiguredDCPowerMode

PowerSetUserConfiguredDCPowerMode

関数
ユーザー構成のDC電源時の電源モードを設定する。
DLLPOWRPROF.dll呼出規約winapi

シグネチャ

// POWRPROF.dll
#include <windows.h>

DWORD PowerSetUserConfiguredDCPowerMode(
    const GUID* PowerModeGuid
);

パラメーター

名前方向
PowerModeGuidGUID*in

戻り値の型: DWORD

各言語での呼び出し定義

// POWRPROF.dll
#include <windows.h>

DWORD PowerSetUserConfiguredDCPowerMode(
    const GUID* PowerModeGuid
);
[DllImport("POWRPROF.dll", ExactSpelling = true)]
static extern uint PowerSetUserConfiguredDCPowerMode(
    ref Guid PowerModeGuid   // GUID*
);
<DllImport("POWRPROF.dll", ExactSpelling:=True)>
Public Shared Function PowerSetUserConfiguredDCPowerMode(
    ByRef PowerModeGuid As Guid   ' GUID*
) As UInteger
End Function
' PowerModeGuid : GUID*
Declare PtrSafe Function PowerSetUserConfiguredDCPowerMode Lib "powrprof" ( _
    ByVal PowerModeGuid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PowerSetUserConfiguredDCPowerMode = ctypes.windll.powrprof.PowerSetUserConfiguredDCPowerMode
PowerSetUserConfiguredDCPowerMode.restype = wintypes.DWORD
PowerSetUserConfiguredDCPowerMode.argtypes = [
    ctypes.c_void_p,  # PowerModeGuid : GUID*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('POWRPROF.dll')
PowerSetUserConfiguredDCPowerMode = Fiddle::Function.new(
  lib['PowerSetUserConfiguredDCPowerMode'],
  [
    Fiddle::TYPE_VOIDP,  # PowerModeGuid : GUID*
  ],
  -Fiddle::TYPE_INT)
#[link(name = "powrprof")]
extern "system" {
    fn PowerSetUserConfiguredDCPowerMode(
        PowerModeGuid: *const GUID  // GUID*
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("POWRPROF.dll")]
public static extern uint PowerSetUserConfiguredDCPowerMode(ref Guid PowerModeGuid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'POWRPROF_PowerSetUserConfiguredDCPowerMode' -Namespace Win32 -PassThru
# $api::PowerSetUserConfiguredDCPowerMode(PowerModeGuid)
#uselib "POWRPROF.dll"
#func global PowerSetUserConfiguredDCPowerMode "PowerSetUserConfiguredDCPowerMode" sptr
; PowerSetUserConfiguredDCPowerMode varptr(PowerModeGuid)   ; 戻り値は stat
; PowerModeGuid : GUID* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "POWRPROF.dll"
#cfunc global PowerSetUserConfiguredDCPowerMode "PowerSetUserConfiguredDCPowerMode" var
; res = PowerSetUserConfiguredDCPowerMode(PowerModeGuid)
; PowerModeGuid : GUID* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PowerSetUserConfiguredDCPowerMode(GUID* PowerModeGuid)
#uselib "POWRPROF.dll"
#cfunc global PowerSetUserConfiguredDCPowerMode "PowerSetUserConfiguredDCPowerMode" var
; res = PowerSetUserConfiguredDCPowerMode(PowerModeGuid)
; PowerModeGuid : GUID* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	powrprof = windows.NewLazySystemDLL("POWRPROF.dll")
	procPowerSetUserConfiguredDCPowerMode = powrprof.NewProc("PowerSetUserConfiguredDCPowerMode")
)

// PowerModeGuid (GUID*)
r1, _, err := procPowerSetUserConfiguredDCPowerMode.Call(
	uintptr(PowerModeGuid),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PowerSetUserConfiguredDCPowerMode(
  PowerModeGuid: PGUID   // GUID*
): DWORD; stdcall;
  external 'POWRPROF.dll' name 'PowerSetUserConfiguredDCPowerMode';
result := DllCall("POWRPROF\PowerSetUserConfiguredDCPowerMode"
    , "Ptr", PowerModeGuid   ; GUID*
    , "UInt")   ; return: DWORD
●PowerSetUserConfiguredDCPowerMode(PowerModeGuid) = DLL("POWRPROF.dll", "dword PowerSetUserConfiguredDCPowerMode(void*)")
# 呼び出し: PowerSetUserConfiguredDCPowerMode(PowerModeGuid)
# PowerModeGuid : GUID* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。