SHChangeNotifyRegister
関数シェル変更通知の受信をウィンドウに登録する。
シグネチャ
// SHELL32.dll
#include <windows.h>
DWORD SHChangeNotifyRegister(
HWND hwnd,
SHCNRF_SOURCE fSources,
INT fEvents,
DWORD wMsg,
INT cEntries,
const SHChangeNotifyEntry* pshcne
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | in |
| fSources | SHCNRF_SOURCE | in |
| fEvents | INT | in |
| wMsg | DWORD | in |
| cEntries | INT | in |
| pshcne | SHChangeNotifyEntry* | in |
戻り値の型: DWORD
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
DWORD SHChangeNotifyRegister(
HWND hwnd,
SHCNRF_SOURCE fSources,
INT fEvents,
DWORD wMsg,
INT cEntries,
const SHChangeNotifyEntry* pshcne
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern uint SHChangeNotifyRegister(
IntPtr hwnd, // HWND
int fSources, // SHCNRF_SOURCE
int fEvents, // INT
uint wMsg, // DWORD
int cEntries, // INT
IntPtr pshcne // SHChangeNotifyEntry*
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHChangeNotifyRegister(
hwnd As IntPtr, ' HWND
fSources As Integer, ' SHCNRF_SOURCE
fEvents As Integer, ' INT
wMsg As UInteger, ' DWORD
cEntries As Integer, ' INT
pshcne As IntPtr ' SHChangeNotifyEntry*
) As UInteger
End Function' hwnd : HWND
' fSources : SHCNRF_SOURCE
' fEvents : INT
' wMsg : DWORD
' cEntries : INT
' pshcne : SHChangeNotifyEntry*
Declare PtrSafe Function SHChangeNotifyRegister Lib "shell32" ( _
ByVal hwnd As LongPtr, _
ByVal fSources As Long, _
ByVal fEvents As Long, _
ByVal wMsg As Long, _
ByVal cEntries As Long, _
ByVal pshcne As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHChangeNotifyRegister = ctypes.windll.shell32.SHChangeNotifyRegister
SHChangeNotifyRegister.restype = wintypes.DWORD
SHChangeNotifyRegister.argtypes = [
wintypes.HANDLE, # hwnd : HWND
ctypes.c_int, # fSources : SHCNRF_SOURCE
ctypes.c_int, # fEvents : INT
wintypes.DWORD, # wMsg : DWORD
ctypes.c_int, # cEntries : INT
ctypes.c_void_p, # pshcne : SHChangeNotifyEntry*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHChangeNotifyRegister = Fiddle::Function.new(
lib['SHChangeNotifyRegister'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_INT, # fSources : SHCNRF_SOURCE
Fiddle::TYPE_INT, # fEvents : INT
-Fiddle::TYPE_INT, # wMsg : DWORD
Fiddle::TYPE_INT, # cEntries : INT
Fiddle::TYPE_VOIDP, # pshcne : SHChangeNotifyEntry*
],
-Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHChangeNotifyRegister(
hwnd: *mut core::ffi::c_void, // HWND
fSources: i32, // SHCNRF_SOURCE
fEvents: i32, // INT
wMsg: u32, // DWORD
cEntries: i32, // INT
pshcne: *const SHChangeNotifyEntry // SHChangeNotifyEntry*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern uint SHChangeNotifyRegister(IntPtr hwnd, int fSources, int fEvents, uint wMsg, int cEntries, IntPtr pshcne);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHChangeNotifyRegister' -Namespace Win32 -PassThru
# $api::SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, pshcne)#uselib "SHELL32.dll"
#func global SHChangeNotifyRegister "SHChangeNotifyRegister" sptr, sptr, sptr, sptr, sptr, sptr
; SHChangeNotifyRegister hwnd, fSources, fEvents, wMsg, cEntries, varptr(pshcne) ; 戻り値は stat
; hwnd : HWND -> "sptr"
; fSources : SHCNRF_SOURCE -> "sptr"
; fEvents : INT -> "sptr"
; wMsg : DWORD -> "sptr"
; cEntries : INT -> "sptr"
; pshcne : SHChangeNotifyEntry* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global SHChangeNotifyRegister "SHChangeNotifyRegister" sptr, int, int, int, int, var ; res = SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, pshcne) ; hwnd : HWND -> "sptr" ; fSources : SHCNRF_SOURCE -> "int" ; fEvents : INT -> "int" ; wMsg : DWORD -> "int" ; cEntries : INT -> "int" ; pshcne : SHChangeNotifyEntry* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global SHChangeNotifyRegister "SHChangeNotifyRegister" sptr, int, int, int, int, sptr ; res = SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, varptr(pshcne)) ; hwnd : HWND -> "sptr" ; fSources : SHCNRF_SOURCE -> "int" ; fEvents : INT -> "int" ; wMsg : DWORD -> "int" ; cEntries : INT -> "int" ; pshcne : SHChangeNotifyEntry* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SHChangeNotifyRegister(HWND hwnd, SHCNRF_SOURCE fSources, INT fEvents, DWORD wMsg, INT cEntries, SHChangeNotifyEntry* pshcne) #uselib "SHELL32.dll" #cfunc global SHChangeNotifyRegister "SHChangeNotifyRegister" intptr, int, int, int, int, var ; res = SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, pshcne) ; hwnd : HWND -> "intptr" ; fSources : SHCNRF_SOURCE -> "int" ; fEvents : INT -> "int" ; wMsg : DWORD -> "int" ; cEntries : INT -> "int" ; pshcne : SHChangeNotifyEntry* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SHChangeNotifyRegister(HWND hwnd, SHCNRF_SOURCE fSources, INT fEvents, DWORD wMsg, INT cEntries, SHChangeNotifyEntry* pshcne) #uselib "SHELL32.dll" #cfunc global SHChangeNotifyRegister "SHChangeNotifyRegister" intptr, int, int, int, int, intptr ; res = SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, varptr(pshcne)) ; hwnd : HWND -> "intptr" ; fSources : SHCNRF_SOURCE -> "int" ; fEvents : INT -> "int" ; wMsg : DWORD -> "int" ; cEntries : INT -> "int" ; pshcne : SHChangeNotifyEntry* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHChangeNotifyRegister = shell32.NewProc("SHChangeNotifyRegister")
)
// hwnd (HWND), fSources (SHCNRF_SOURCE), fEvents (INT), wMsg (DWORD), cEntries (INT), pshcne (SHChangeNotifyEntry*)
r1, _, err := procSHChangeNotifyRegister.Call(
uintptr(hwnd),
uintptr(fSources),
uintptr(fEvents),
uintptr(wMsg),
uintptr(cEntries),
uintptr(pshcne),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SHChangeNotifyRegister(
hwnd: THandle; // HWND
fSources: Integer; // SHCNRF_SOURCE
fEvents: Integer; // INT
wMsg: DWORD; // DWORD
cEntries: Integer; // INT
pshcne: Pointer // SHChangeNotifyEntry*
): DWORD; stdcall;
external 'SHELL32.dll' name 'SHChangeNotifyRegister';result := DllCall("SHELL32\SHChangeNotifyRegister"
, "Ptr", hwnd ; HWND
, "Int", fSources ; SHCNRF_SOURCE
, "Int", fEvents ; INT
, "UInt", wMsg ; DWORD
, "Int", cEntries ; INT
, "Ptr", pshcne ; SHChangeNotifyEntry*
, "UInt") ; return: DWORD●SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, pshcne) = DLL("SHELL32.dll", "dword SHChangeNotifyRegister(void*, int, int, dword, int, void*)")
# 呼び出し: SHChangeNotifyRegister(hwnd, fSources, fEvents, wMsg, cEntries, pshcne)
# hwnd : HWND -> "void*"
# fSources : SHCNRF_SOURCE -> "int"
# fEvents : INT -> "int"
# wMsg : DWORD -> "dword"
# cEntries : INT -> "int"
# pshcne : SHChangeNotifyEntry* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。