RegisterAppConstrainedChangeNotification
関数アプリの制約状態変更通知を登録する。
シグネチャ
// api-ms-win-core-psm-appnotify-l1-1-1.dll
#include <windows.h>
DWORD RegisterAppConstrainedChangeNotification(
PAPPCONSTRAIN_CHANGE_ROUTINE Routine,
void* Context, // optional
PAPPCONSTRAIN_REGISTRATION* Registration
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Routine | PAPPCONSTRAIN_CHANGE_ROUTINE | in | アプリの制約状態(constrained)変化時に呼ばれるコールバック関数。 |
| Context | void* | inoptional | コールバックに渡される任意のユーザーデータへのポインタ。NULL可。 |
| Registration | PAPPCONSTRAIN_REGISTRATION* | out | 登録ハンドルを受け取る出力先。解除時に使用する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// api-ms-win-core-psm-appnotify-l1-1-1.dll
#include <windows.h>
DWORD RegisterAppConstrainedChangeNotification(
PAPPCONSTRAIN_CHANGE_ROUTINE Routine,
void* Context, // optional
PAPPCONSTRAIN_REGISTRATION* Registration
);[DllImport("api-ms-win-core-psm-appnotify-l1-1-1.dll", ExactSpelling = true)]
static extern uint RegisterAppConstrainedChangeNotification(
IntPtr Routine, // PAPPCONSTRAIN_CHANGE_ROUTINE
IntPtr Context, // void* optional
out IntPtr Registration // PAPPCONSTRAIN_REGISTRATION* out
);<DllImport("api-ms-win-core-psm-appnotify-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function RegisterAppConstrainedChangeNotification(
Routine As IntPtr, ' PAPPCONSTRAIN_CHANGE_ROUTINE
Context As IntPtr, ' void* optional
<Out> ByRef Registration As IntPtr ' PAPPCONSTRAIN_REGISTRATION* out
) As UInteger
End Function' Routine : PAPPCONSTRAIN_CHANGE_ROUTINE
' Context : void* optional
' Registration : PAPPCONSTRAIN_REGISTRATION* out
Declare PtrSafe Function RegisterAppConstrainedChangeNotification Lib "api-ms-win-core-psm-appnotify-l1-1-1" ( _
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
RegisterAppConstrainedChangeNotification = ctypes.windll.LoadLibrary("api-ms-win-core-psm-appnotify-l1-1-1.dll").RegisterAppConstrainedChangeNotification
RegisterAppConstrainedChangeNotification.restype = wintypes.DWORD
RegisterAppConstrainedChangeNotification.argtypes = [
ctypes.c_void_p, # Routine : PAPPCONSTRAIN_CHANGE_ROUTINE
ctypes.POINTER(None), # Context : void* optional
ctypes.c_void_p, # Registration : PAPPCONSTRAIN_REGISTRATION* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-psm-appnotify-l1-1-1.dll')
RegisterAppConstrainedChangeNotification = Fiddle::Function.new(
lib['RegisterAppConstrainedChangeNotification'],
[
Fiddle::TYPE_VOIDP, # Routine : PAPPCONSTRAIN_CHANGE_ROUTINE
Fiddle::TYPE_VOIDP, # Context : void* optional
Fiddle::TYPE_VOIDP, # Registration : PAPPCONSTRAIN_REGISTRATION* out
],
-Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-psm-appnotify-l1-1-1")]
extern "system" {
fn RegisterAppConstrainedChangeNotification(
Routine: *const core::ffi::c_void, // PAPPCONSTRAIN_CHANGE_ROUTINE
Context: *mut (), // void* optional
Registration: *mut isize // PAPPCONSTRAIN_REGISTRATION* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-psm-appnotify-l1-1-1.dll")]
public static extern uint RegisterAppConstrainedChangeNotification(IntPtr Routine, IntPtr Context, out IntPtr Registration);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-psm-appnotify-l1-1-1_RegisterAppConstrainedChangeNotification' -Namespace Win32 -PassThru
# $api::RegisterAppConstrainedChangeNotification(Routine, Context, Registration)#uselib "api-ms-win-core-psm-appnotify-l1-1-1.dll"
#func global RegisterAppConstrainedChangeNotification "RegisterAppConstrainedChangeNotification" sptr, sptr, sptr
; RegisterAppConstrainedChangeNotification Routine, Context, varptr(Registration) ; 戻り値は stat
; Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "sptr"
; Context : void* optional -> "sptr"
; Registration : PAPPCONSTRAIN_REGISTRATION* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-psm-appnotify-l1-1-1.dll" #cfunc global RegisterAppConstrainedChangeNotification "RegisterAppConstrainedChangeNotification" sptr, sptr, var ; res = RegisterAppConstrainedChangeNotification(Routine, Context, Registration) ; Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "sptr" ; Context : void* optional -> "sptr" ; Registration : PAPPCONSTRAIN_REGISTRATION* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-psm-appnotify-l1-1-1.dll" #cfunc global RegisterAppConstrainedChangeNotification "RegisterAppConstrainedChangeNotification" sptr, sptr, sptr ; res = RegisterAppConstrainedChangeNotification(Routine, Context, varptr(Registration)) ; Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "sptr" ; Context : void* optional -> "sptr" ; Registration : PAPPCONSTRAIN_REGISTRATION* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD RegisterAppConstrainedChangeNotification(PAPPCONSTRAIN_CHANGE_ROUTINE Routine, void* Context, PAPPCONSTRAIN_REGISTRATION* Registration) #uselib "api-ms-win-core-psm-appnotify-l1-1-1.dll" #cfunc global RegisterAppConstrainedChangeNotification "RegisterAppConstrainedChangeNotification" intptr, intptr, var ; res = RegisterAppConstrainedChangeNotification(Routine, Context, Registration) ; Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "intptr" ; Context : void* optional -> "intptr" ; Registration : PAPPCONSTRAIN_REGISTRATION* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RegisterAppConstrainedChangeNotification(PAPPCONSTRAIN_CHANGE_ROUTINE Routine, void* Context, PAPPCONSTRAIN_REGISTRATION* Registration) #uselib "api-ms-win-core-psm-appnotify-l1-1-1.dll" #cfunc global RegisterAppConstrainedChangeNotification "RegisterAppConstrainedChangeNotification" intptr, intptr, intptr ; res = RegisterAppConstrainedChangeNotification(Routine, Context, varptr(Registration)) ; Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "intptr" ; Context : void* optional -> "intptr" ; Registration : PAPPCONSTRAIN_REGISTRATION* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_psm_appnotify_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-core-psm-appnotify-l1-1-1.dll")
procRegisterAppConstrainedChangeNotification = api_ms_win_core_psm_appnotify_l1_1_1.NewProc("RegisterAppConstrainedChangeNotification")
)
// Routine (PAPPCONSTRAIN_CHANGE_ROUTINE), Context (void* optional), Registration (PAPPCONSTRAIN_REGISTRATION* out)
r1, _, err := procRegisterAppConstrainedChangeNotification.Call(
uintptr(Routine),
uintptr(Context),
uintptr(Registration),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RegisterAppConstrainedChangeNotification(
Routine: Pointer; // PAPPCONSTRAIN_CHANGE_ROUTINE
Context: Pointer; // void* optional
Registration: Pointer // PAPPCONSTRAIN_REGISTRATION* out
): DWORD; stdcall;
external 'api-ms-win-core-psm-appnotify-l1-1-1.dll' name 'RegisterAppConstrainedChangeNotification';result := DllCall("api-ms-win-core-psm-appnotify-l1-1-1\RegisterAppConstrainedChangeNotification"
, "Ptr", Routine ; PAPPCONSTRAIN_CHANGE_ROUTINE
, "Ptr", Context ; void* optional
, "Ptr", Registration ; PAPPCONSTRAIN_REGISTRATION* out
, "UInt") ; return: DWORD●RegisterAppConstrainedChangeNotification(Routine, Context, Registration) = DLL("api-ms-win-core-psm-appnotify-l1-1-1.dll", "dword RegisterAppConstrainedChangeNotification(void*, void*, void*)")
# 呼び出し: RegisterAppConstrainedChangeNotification(Routine, Context, Registration)
# Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "void*"
# Context : void* optional -> "void*"
# Registration : PAPPCONSTRAIN_REGISTRATION* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-psm-appnotify-l1-1-1" fn RegisterAppConstrainedChangeNotification(
Routine: ?*anyopaque, // PAPPCONSTRAIN_CHANGE_ROUTINE
Context: ?*anyopaque, // void* optional
Registration: [*c]isize // PAPPCONSTRAIN_REGISTRATION* out
) callconv(std.os.windows.WINAPI) u32;proc RegisterAppConstrainedChangeNotification(
Routine: pointer, # PAPPCONSTRAIN_CHANGE_ROUTINE
Context: pointer, # void* optional
Registration: ptr int # PAPPCONSTRAIN_REGISTRATION* out
): uint32 {.importc: "RegisterAppConstrainedChangeNotification", stdcall, dynlib: "api-ms-win-core-psm-appnotify-l1-1-1.dll".}pragma(lib, "api-ms-win-core-psm-appnotify-l1-1-1");
extern(Windows)
uint RegisterAppConstrainedChangeNotification(
void* Routine, // PAPPCONSTRAIN_CHANGE_ROUTINE
void* Context, // void* optional
ptrdiff_t* Registration // PAPPCONSTRAIN_REGISTRATION* out
);ccall((:RegisterAppConstrainedChangeNotification, "api-ms-win-core-psm-appnotify-l1-1-1.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Int}),
Routine, Context, Registration)
# Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> Ptr{Cvoid}
# Context : void* optional -> Ptr{Cvoid}
# Registration : PAPPCONSTRAIN_REGISTRATION* out -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RegisterAppConstrainedChangeNotification(
void* Routine,
void* Context,
intptr_t* Registration);
]]
local api-ms-win-core-psm-appnotify-l1-1-1 = ffi.load("api-ms-win-core-psm-appnotify-l1-1-1")
-- api-ms-win-core-psm-appnotify-l1-1-1.RegisterAppConstrainedChangeNotification(Routine, Context, Registration)
-- Routine : PAPPCONSTRAIN_CHANGE_ROUTINE
-- Context : void* optional
-- Registration : PAPPCONSTRAIN_REGISTRATION* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-psm-appnotify-l1-1-1.dll');
const RegisterAppConstrainedChangeNotification = lib.func('__stdcall', 'RegisterAppConstrainedChangeNotification', 'uint32_t', ['void *', 'void *', 'intptr_t *']);
// RegisterAppConstrainedChangeNotification(Routine, Context, Registration)
// Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> 'void *'
// Context : void* optional -> 'void *'
// Registration : PAPPCONSTRAIN_REGISTRATION* out -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("api-ms-win-core-psm-appnotify-l1-1-1.dll", {
RegisterAppConstrainedChangeNotification: { parameters: ["pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.RegisterAppConstrainedChangeNotification(Routine, Context, Registration)
// Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> "pointer"
// Context : void* optional -> "pointer"
// Registration : PAPPCONSTRAIN_REGISTRATION* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RegisterAppConstrainedChangeNotification(
void* Routine,
void* Context,
intptr_t* Registration);
C, "api-ms-win-core-psm-appnotify-l1-1-1.dll");
// $ffi->RegisterAppConstrainedChangeNotification(Routine, Context, Registration);
// Routine : PAPPCONSTRAIN_CHANGE_ROUTINE
// Context : void* optional
// Registration : PAPPCONSTRAIN_REGISTRATION* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Api-ms-win-core-psm-appnotify-l1-1-1 extends StdCallLibrary {
Api-ms-win-core-psm-appnotify-l1-1-1 INSTANCE = Native.load("api-ms-win-core-psm-appnotify-l1-1-1", Api-ms-win-core-psm-appnotify-l1-1-1.class);
int RegisterAppConstrainedChangeNotification(
Callback Routine, // PAPPCONSTRAIN_CHANGE_ROUTINE
Pointer Context, // void* optional
LongByReference Registration // PAPPCONSTRAIN_REGISTRATION* out
);
}@[Link("api-ms-win-core-psm-appnotify-l1-1-1")]
lib Libapi-ms-win-core-psm-appnotify-l1-1-1
fun RegisterAppConstrainedChangeNotification = RegisterAppConstrainedChangeNotification(
Routine : Void*, # PAPPCONSTRAIN_CHANGE_ROUTINE
Context : Void*, # void* optional
Registration : LibC::SSizeT* # PAPPCONSTRAIN_REGISTRATION* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RegisterAppConstrainedChangeNotificationNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<IntPtr>);
typedef RegisterAppConstrainedChangeNotificationDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<IntPtr>);
final RegisterAppConstrainedChangeNotification = DynamicLibrary.open('api-ms-win-core-psm-appnotify-l1-1-1.dll')
.lookupFunction<RegisterAppConstrainedChangeNotificationNative, RegisterAppConstrainedChangeNotificationDart>('RegisterAppConstrainedChangeNotification');
// Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> Pointer<Void>
// Context : void* optional -> Pointer<Void>
// Registration : PAPPCONSTRAIN_REGISTRATION* out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RegisterAppConstrainedChangeNotification(
Routine: Pointer; // PAPPCONSTRAIN_CHANGE_ROUTINE
Context: Pointer; // void* optional
Registration: Pointer // PAPPCONSTRAIN_REGISTRATION* out
): DWORD; stdcall;
external 'api-ms-win-core-psm-appnotify-l1-1-1.dll' name 'RegisterAppConstrainedChangeNotification';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegisterAppConstrainedChangeNotification"
c_RegisterAppConstrainedChangeNotification :: Ptr () -> Ptr () -> Ptr CIntPtr -> IO Word32
-- Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> Ptr ()
-- Context : void* optional -> Ptr ()
-- Registration : PAPPCONSTRAIN_REGISTRATION* out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let registerappconstrainedchangenotification =
foreign "RegisterAppConstrainedChangeNotification"
((ptr void) @-> (ptr void) @-> (ptr intptr_t) @-> returning uint32_t)
(* Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> (ptr void) *)
(* Context : void* optional -> (ptr void) *)
(* Registration : PAPPCONSTRAIN_REGISTRATION* out -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-psm-appnotify-l1-1-1 (t "api-ms-win-core-psm-appnotify-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-core-psm-appnotify-l1-1-1)
(cffi:defcfun ("RegisterAppConstrainedChangeNotification" register-app-constrained-change-notification :convention :stdcall) :uint32
(routine :pointer) ; PAPPCONSTRAIN_CHANGE_ROUTINE
(context :pointer) ; void* optional
(registration :pointer)) ; PAPPCONSTRAIN_REGISTRATION* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegisterAppConstrainedChangeNotification = Win32::API::More->new('api-ms-win-core-psm-appnotify-l1-1-1',
'DWORD RegisterAppConstrainedChangeNotification(LPVOID Routine, LPVOID Context, LPVOID Registration)');
# my $ret = $RegisterAppConstrainedChangeNotification->Call($Routine, $Context, $Registration);
# Routine : PAPPCONSTRAIN_CHANGE_ROUTINE -> LPVOID
# Context : void* optional -> LPVOID
# Registration : PAPPCONSTRAIN_REGISTRATION* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。