RegisterAppStateChangeNotification
関数アプリの状態変更通知コールバックを登録する。
シグネチャ
// api-ms-win-core-psm-appnotify-l1-1-0.dll
#include <windows.h>
DWORD RegisterAppStateChangeNotification(
PAPPSTATE_CHANGE_ROUTINE Routine,
void* Context, // optional
PAPPSTATE_REGISTRATION* Registration
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Routine | PAPPSTATE_CHANGE_ROUTINE | in |
| Context | void* | inoptional |
| Registration | PAPPSTATE_REGISTRATION* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// api-ms-win-core-psm-appnotify-l1-1-0.dll
#include <windows.h>
DWORD RegisterAppStateChangeNotification(
PAPPSTATE_CHANGE_ROUTINE Routine,
void* Context, // optional
PAPPSTATE_REGISTRATION* Registration
);[DllImport("api-ms-win-core-psm-appnotify-l1-1-0.dll", ExactSpelling = true)]
static extern uint RegisterAppStateChangeNotification(
IntPtr Routine, // PAPPSTATE_CHANGE_ROUTINE
IntPtr Context, // void* optional
out IntPtr Registration // PAPPSTATE_REGISTRATION* out
);<DllImport("api-ms-win-core-psm-appnotify-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function RegisterAppStateChangeNotification(
Routine As IntPtr, ' PAPPSTATE_CHANGE_ROUTINE
Context As IntPtr, ' void* optional
<Out> ByRef Registration As IntPtr ' PAPPSTATE_REGISTRATION* out
) As UInteger
End Function' Routine : PAPPSTATE_CHANGE_ROUTINE
' Context : void* optional
' Registration : PAPPSTATE_REGISTRATION* out
Declare PtrSafe Function RegisterAppStateChangeNotification Lib "api-ms-win-core-psm-appnotify-l1-1-0" ( _
ByVal Routine As LongPtr, _
ByVal Context As LongPtr, _
ByRef Registration As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterAppStateChangeNotification = ctypes.windll.LoadLibrary("api-ms-win-core-psm-appnotify-l1-1-0.dll").RegisterAppStateChangeNotification
RegisterAppStateChangeNotification.restype = wintypes.DWORD
RegisterAppStateChangeNotification.argtypes = [
ctypes.c_void_p, # Routine : PAPPSTATE_CHANGE_ROUTINE
ctypes.POINTER(None), # Context : void* optional
ctypes.c_void_p, # Registration : PAPPSTATE_REGISTRATION* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-psm-appnotify-l1-1-0.dll')
RegisterAppStateChangeNotification = Fiddle::Function.new(
lib['RegisterAppStateChangeNotification'],
[
Fiddle::TYPE_VOIDP, # Routine : PAPPSTATE_CHANGE_ROUTINE
Fiddle::TYPE_VOIDP, # Context : void* optional
Fiddle::TYPE_VOIDP, # Registration : PAPPSTATE_REGISTRATION* out
],
-Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-psm-appnotify-l1-1-0")]
extern "system" {
fn RegisterAppStateChangeNotification(
Routine: *const core::ffi::c_void, // PAPPSTATE_CHANGE_ROUTINE
Context: *mut (), // void* optional
Registration: *mut isize // PAPPSTATE_REGISTRATION* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-psm-appnotify-l1-1-0.dll")]
public static extern uint RegisterAppStateChangeNotification(IntPtr Routine, IntPtr Context, out IntPtr Registration);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-psm-appnotify-l1-1-0_RegisterAppStateChangeNotification' -Namespace Win32 -PassThru
# $api::RegisterAppStateChangeNotification(Routine, Context, Registration)#uselib "api-ms-win-core-psm-appnotify-l1-1-0.dll"
#func global RegisterAppStateChangeNotification "RegisterAppStateChangeNotification" sptr, sptr, sptr
; RegisterAppStateChangeNotification Routine, Context, Registration ; 戻り値は stat
; Routine : PAPPSTATE_CHANGE_ROUTINE -> "sptr"
; Context : void* optional -> "sptr"
; Registration : PAPPSTATE_REGISTRATION* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "api-ms-win-core-psm-appnotify-l1-1-0.dll"
#cfunc global RegisterAppStateChangeNotification "RegisterAppStateChangeNotification" sptr, sptr, int
; res = RegisterAppStateChangeNotification(Routine, Context, Registration)
; Routine : PAPPSTATE_CHANGE_ROUTINE -> "sptr"
; Context : void* optional -> "sptr"
; Registration : PAPPSTATE_REGISTRATION* out -> "int"; DWORD RegisterAppStateChangeNotification(PAPPSTATE_CHANGE_ROUTINE Routine, void* Context, PAPPSTATE_REGISTRATION* Registration)
#uselib "api-ms-win-core-psm-appnotify-l1-1-0.dll"
#cfunc global RegisterAppStateChangeNotification "RegisterAppStateChangeNotification" intptr, intptr, int
; res = RegisterAppStateChangeNotification(Routine, Context, Registration)
; Routine : PAPPSTATE_CHANGE_ROUTINE -> "intptr"
; Context : void* optional -> "intptr"
; Registration : PAPPSTATE_REGISTRATION* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_psm_appnotify_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-psm-appnotify-l1-1-0.dll")
procRegisterAppStateChangeNotification = api_ms_win_core_psm_appnotify_l1_1_0.NewProc("RegisterAppStateChangeNotification")
)
// Routine (PAPPSTATE_CHANGE_ROUTINE), Context (void* optional), Registration (PAPPSTATE_REGISTRATION* out)
r1, _, err := procRegisterAppStateChangeNotification.Call(
uintptr(Routine),
uintptr(Context),
uintptr(Registration),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RegisterAppStateChangeNotification(
Routine: Pointer; // PAPPSTATE_CHANGE_ROUTINE
Context: Pointer; // void* optional
Registration: Pointer // PAPPSTATE_REGISTRATION* out
): DWORD; stdcall;
external 'api-ms-win-core-psm-appnotify-l1-1-0.dll' name 'RegisterAppStateChangeNotification';result := DllCall("api-ms-win-core-psm-appnotify-l1-1-0\RegisterAppStateChangeNotification"
, "Ptr", Routine ; PAPPSTATE_CHANGE_ROUTINE
, "Ptr", Context ; void* optional
, "Ptr", Registration ; PAPPSTATE_REGISTRATION* out
, "UInt") ; return: DWORD●RegisterAppStateChangeNotification(Routine, Context, Registration) = DLL("api-ms-win-core-psm-appnotify-l1-1-0.dll", "dword RegisterAppStateChangeNotification(void*, void*, void*)")
# 呼び出し: RegisterAppStateChangeNotification(Routine, Context, Registration)
# Routine : PAPPSTATE_CHANGE_ROUTINE -> "void*"
# Context : void* optional -> "void*"
# Registration : PAPPSTATE_REGISTRATION* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。