ホーム › System.SecurityCenter › WscRegisterForChanges
WscRegisterForChanges
関数セキュリティセンターの状態変化通知のコールバックを登録する。
シグネチャ
// WSCAPI.dll
#include <windows.h>
HRESULT WscRegisterForChanges(
void* Reserved,
HANDLE* phCallbackRegistration,
LPTHREAD_START_ROUTINE lpCallbackAddress,
void* pContext
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Reserved | void* | inout |
| phCallbackRegistration | HANDLE* | inout |
| lpCallbackAddress | LPTHREAD_START_ROUTINE | in |
| pContext | void* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// WSCAPI.dll
#include <windows.h>
HRESULT WscRegisterForChanges(
void* Reserved,
HANDLE* phCallbackRegistration,
LPTHREAD_START_ROUTINE lpCallbackAddress,
void* pContext
);[DllImport("WSCAPI.dll", ExactSpelling = true)]
static extern int WscRegisterForChanges(
IntPtr Reserved, // void* in/out
IntPtr phCallbackRegistration, // HANDLE* in/out
IntPtr lpCallbackAddress, // LPTHREAD_START_ROUTINE
IntPtr pContext // void* in/out
);<DllImport("WSCAPI.dll", ExactSpelling:=True)>
Public Shared Function WscRegisterForChanges(
Reserved As IntPtr, ' void* in/out
phCallbackRegistration As IntPtr, ' HANDLE* in/out
lpCallbackAddress As IntPtr, ' LPTHREAD_START_ROUTINE
pContext As IntPtr ' void* in/out
) As Integer
End Function' Reserved : void* in/out
' phCallbackRegistration : HANDLE* in/out
' lpCallbackAddress : LPTHREAD_START_ROUTINE
' pContext : void* in/out
Declare PtrSafe Function WscRegisterForChanges Lib "wscapi" ( _
ByVal Reserved As LongPtr, _
ByVal phCallbackRegistration As LongPtr, _
ByVal lpCallbackAddress As LongPtr, _
ByVal pContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WscRegisterForChanges = ctypes.windll.wscapi.WscRegisterForChanges
WscRegisterForChanges.restype = ctypes.c_int
WscRegisterForChanges.argtypes = [
ctypes.POINTER(None), # Reserved : void* in/out
ctypes.c_void_p, # phCallbackRegistration : HANDLE* in/out
ctypes.c_void_p, # lpCallbackAddress : LPTHREAD_START_ROUTINE
ctypes.POINTER(None), # pContext : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WSCAPI.dll')
WscRegisterForChanges = Fiddle::Function.new(
lib['WscRegisterForChanges'],
[
Fiddle::TYPE_VOIDP, # Reserved : void* in/out
Fiddle::TYPE_VOIDP, # phCallbackRegistration : HANDLE* in/out
Fiddle::TYPE_VOIDP, # lpCallbackAddress : LPTHREAD_START_ROUTINE
Fiddle::TYPE_VOIDP, # pContext : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "wscapi")]
extern "system" {
fn WscRegisterForChanges(
Reserved: *mut (), // void* in/out
phCallbackRegistration: *mut *mut core::ffi::c_void, // HANDLE* in/out
lpCallbackAddress: *const core::ffi::c_void, // LPTHREAD_START_ROUTINE
pContext: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WSCAPI.dll")]
public static extern int WscRegisterForChanges(IntPtr Reserved, IntPtr phCallbackRegistration, IntPtr lpCallbackAddress, IntPtr pContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WSCAPI_WscRegisterForChanges' -Namespace Win32 -PassThru
# $api::WscRegisterForChanges(Reserved, phCallbackRegistration, lpCallbackAddress, pContext)#uselib "WSCAPI.dll"
#func global WscRegisterForChanges "WscRegisterForChanges" sptr, sptr, sptr, sptr
; WscRegisterForChanges Reserved, phCallbackRegistration, lpCallbackAddress, pContext ; 戻り値は stat
; Reserved : void* in/out -> "sptr"
; phCallbackRegistration : HANDLE* in/out -> "sptr"
; lpCallbackAddress : LPTHREAD_START_ROUTINE -> "sptr"
; pContext : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WSCAPI.dll"
#cfunc global WscRegisterForChanges "WscRegisterForChanges" sptr, sptr, sptr, sptr
; res = WscRegisterForChanges(Reserved, phCallbackRegistration, lpCallbackAddress, pContext)
; Reserved : void* in/out -> "sptr"
; phCallbackRegistration : HANDLE* in/out -> "sptr"
; lpCallbackAddress : LPTHREAD_START_ROUTINE -> "sptr"
; pContext : void* in/out -> "sptr"; HRESULT WscRegisterForChanges(void* Reserved, HANDLE* phCallbackRegistration, LPTHREAD_START_ROUTINE lpCallbackAddress, void* pContext)
#uselib "WSCAPI.dll"
#cfunc global WscRegisterForChanges "WscRegisterForChanges" intptr, intptr, intptr, intptr
; res = WscRegisterForChanges(Reserved, phCallbackRegistration, lpCallbackAddress, pContext)
; Reserved : void* in/out -> "intptr"
; phCallbackRegistration : HANDLE* in/out -> "intptr"
; lpCallbackAddress : LPTHREAD_START_ROUTINE -> "intptr"
; pContext : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wscapi = windows.NewLazySystemDLL("WSCAPI.dll")
procWscRegisterForChanges = wscapi.NewProc("WscRegisterForChanges")
)
// Reserved (void* in/out), phCallbackRegistration (HANDLE* in/out), lpCallbackAddress (LPTHREAD_START_ROUTINE), pContext (void* in/out)
r1, _, err := procWscRegisterForChanges.Call(
uintptr(Reserved),
uintptr(phCallbackRegistration),
uintptr(lpCallbackAddress),
uintptr(pContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WscRegisterForChanges(
Reserved: Pointer; // void* in/out
phCallbackRegistration: Pointer; // HANDLE* in/out
lpCallbackAddress: Pointer; // LPTHREAD_START_ROUTINE
pContext: Pointer // void* in/out
): Integer; stdcall;
external 'WSCAPI.dll' name 'WscRegisterForChanges';result := DllCall("WSCAPI\WscRegisterForChanges"
, "Ptr", Reserved ; void* in/out
, "Ptr", phCallbackRegistration ; HANDLE* in/out
, "Ptr", lpCallbackAddress ; LPTHREAD_START_ROUTINE
, "Ptr", pContext ; void* in/out
, "Int") ; return: HRESULT●WscRegisterForChanges(Reserved, phCallbackRegistration, lpCallbackAddress, pContext) = DLL("WSCAPI.dll", "int WscRegisterForChanges(void*, void*, void*, void*)")
# 呼び出し: WscRegisterForChanges(Reserved, phCallbackRegistration, lpCallbackAddress, pContext)
# Reserved : void* in/out -> "void*"
# phCallbackRegistration : HANDLE* in/out -> "void*"
# lpCallbackAddress : LPTHREAD_START_ROUTINE -> "void*"
# pContext : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。