Win32 API 日本語リファレンス
ホームMedia.Multimedia › DriverCallback

DriverCallback

関数
メディアデバイスのコールバック通知を呼び出す。
DLLWINMM.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL DriverCallback(
    UINT_PTR dwCallback,
    DWORD dwFlags,
    HDRVR hDevice,
    DWORD dwMsg,
    UINT_PTR dwUser,
    UINT_PTR dwParam1,
    UINT_PTR dwParam2
);

パラメーター

名前方向
dwCallbackUINT_PTRin
dwFlagsDWORDin
hDeviceHDRVRin
dwMsgDWORDin
dwUserUINT_PTRin
dwParam1UINT_PTRin
dwParam2UINT_PTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DriverCallback(
    UINT_PTR dwCallback,
    DWORD dwFlags,
    HDRVR hDevice,
    DWORD dwMsg,
    UINT_PTR dwUser,
    UINT_PTR dwParam1,
    UINT_PTR dwParam2
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINMM.dll", ExactSpelling = true)]
static extern bool DriverCallback(
    UIntPtr dwCallback,   // UINT_PTR
    uint dwFlags,   // DWORD
    IntPtr hDevice,   // HDRVR
    uint dwMsg,   // DWORD
    UIntPtr dwUser,   // UINT_PTR
    UIntPtr dwParam1,   // UINT_PTR
    UIntPtr dwParam2   // UINT_PTR
);
<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function DriverCallback(
    dwCallback As UIntPtr,   ' UINT_PTR
    dwFlags As UInteger,   ' DWORD
    hDevice As IntPtr,   ' HDRVR
    dwMsg As UInteger,   ' DWORD
    dwUser As UIntPtr,   ' UINT_PTR
    dwParam1 As UIntPtr,   ' UINT_PTR
    dwParam2 As UIntPtr   ' UINT_PTR
) As Boolean
End Function
' dwCallback : UINT_PTR
' dwFlags : DWORD
' hDevice : HDRVR
' dwMsg : DWORD
' dwUser : UINT_PTR
' dwParam1 : UINT_PTR
' dwParam2 : UINT_PTR
Declare PtrSafe Function DriverCallback Lib "winmm" ( _
    ByVal dwCallback As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal hDevice As LongPtr, _
    ByVal dwMsg As Long, _
    ByVal dwUser As LongPtr, _
    ByVal dwParam1 As LongPtr, _
    ByVal dwParam2 As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DriverCallback = ctypes.windll.winmm.DriverCallback
DriverCallback.restype = wintypes.BOOL
DriverCallback.argtypes = [
    ctypes.c_size_t,  # dwCallback : UINT_PTR
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.HANDLE,  # hDevice : HDRVR
    wintypes.DWORD,  # dwMsg : DWORD
    ctypes.c_size_t,  # dwUser : UINT_PTR
    ctypes.c_size_t,  # dwParam1 : UINT_PTR
    ctypes.c_size_t,  # dwParam2 : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINMM.dll')
DriverCallback = Fiddle::Function.new(
  lib['DriverCallback'],
  [
    Fiddle::TYPE_UINTPTR_T,  # dwCallback : UINT_PTR
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # hDevice : HDRVR
    -Fiddle::TYPE_INT,  # dwMsg : DWORD
    Fiddle::TYPE_UINTPTR_T,  # dwUser : UINT_PTR
    Fiddle::TYPE_UINTPTR_T,  # dwParam1 : UINT_PTR
    Fiddle::TYPE_UINTPTR_T,  # dwParam2 : UINT_PTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "winmm")]
extern "system" {
    fn DriverCallback(
        dwCallback: usize,  // UINT_PTR
        dwFlags: u32,  // DWORD
        hDevice: *mut core::ffi::c_void,  // HDRVR
        dwMsg: u32,  // DWORD
        dwUser: usize,  // UINT_PTR
        dwParam1: usize,  // UINT_PTR
        dwParam2: usize  // UINT_PTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINMM.dll")]
public static extern bool DriverCallback(UIntPtr dwCallback, uint dwFlags, IntPtr hDevice, uint dwMsg, UIntPtr dwUser, UIntPtr dwParam1, UIntPtr dwParam2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_DriverCallback' -Namespace Win32 -PassThru
# $api::DriverCallback(dwCallback, dwFlags, hDevice, dwMsg, dwUser, dwParam1, dwParam2)
#uselib "WINMM.dll"
#func global DriverCallback "DriverCallback" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DriverCallback dwCallback, dwFlags, hDevice, dwMsg, dwUser, dwParam1, dwParam2   ; 戻り値は stat
; dwCallback : UINT_PTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; hDevice : HDRVR -> "sptr"
; dwMsg : DWORD -> "sptr"
; dwUser : UINT_PTR -> "sptr"
; dwParam1 : UINT_PTR -> "sptr"
; dwParam2 : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINMM.dll"
#cfunc global DriverCallback "DriverCallback" sptr, int, sptr, int, sptr, sptr, sptr
; res = DriverCallback(dwCallback, dwFlags, hDevice, dwMsg, dwUser, dwParam1, dwParam2)
; dwCallback : UINT_PTR -> "sptr"
; dwFlags : DWORD -> "int"
; hDevice : HDRVR -> "sptr"
; dwMsg : DWORD -> "int"
; dwUser : UINT_PTR -> "sptr"
; dwParam1 : UINT_PTR -> "sptr"
; dwParam2 : UINT_PTR -> "sptr"
; BOOL DriverCallback(UINT_PTR dwCallback, DWORD dwFlags, HDRVR hDevice, DWORD dwMsg, UINT_PTR dwUser, UINT_PTR dwParam1, UINT_PTR dwParam2)
#uselib "WINMM.dll"
#cfunc global DriverCallback "DriverCallback" intptr, int, intptr, int, intptr, intptr, intptr
; res = DriverCallback(dwCallback, dwFlags, hDevice, dwMsg, dwUser, dwParam1, dwParam2)
; dwCallback : UINT_PTR -> "intptr"
; dwFlags : DWORD -> "int"
; hDevice : HDRVR -> "intptr"
; dwMsg : DWORD -> "int"
; dwUser : UINT_PTR -> "intptr"
; dwParam1 : UINT_PTR -> "intptr"
; dwParam2 : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winmm = windows.NewLazySystemDLL("WINMM.dll")
	procDriverCallback = winmm.NewProc("DriverCallback")
)

// dwCallback (UINT_PTR), dwFlags (DWORD), hDevice (HDRVR), dwMsg (DWORD), dwUser (UINT_PTR), dwParam1 (UINT_PTR), dwParam2 (UINT_PTR)
r1, _, err := procDriverCallback.Call(
	uintptr(dwCallback),
	uintptr(dwFlags),
	uintptr(hDevice),
	uintptr(dwMsg),
	uintptr(dwUser),
	uintptr(dwParam1),
	uintptr(dwParam2),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DriverCallback(
  dwCallback: NativeUInt;   // UINT_PTR
  dwFlags: DWORD;   // DWORD
  hDevice: THandle;   // HDRVR
  dwMsg: DWORD;   // DWORD
  dwUser: NativeUInt;   // UINT_PTR
  dwParam1: NativeUInt;   // UINT_PTR
  dwParam2: NativeUInt   // UINT_PTR
): BOOL; stdcall;
  external 'WINMM.dll' name 'DriverCallback';
result := DllCall("WINMM\DriverCallback"
    , "UPtr", dwCallback   ; UINT_PTR
    , "UInt", dwFlags   ; DWORD
    , "Ptr", hDevice   ; HDRVR
    , "UInt", dwMsg   ; DWORD
    , "UPtr", dwUser   ; UINT_PTR
    , "UPtr", dwParam1   ; UINT_PTR
    , "UPtr", dwParam2   ; UINT_PTR
    , "Int")   ; return: BOOL
●DriverCallback(dwCallback, dwFlags, hDevice, dwMsg, dwUser, dwParam1, dwParam2) = DLL("WINMM.dll", "bool DriverCallback(int, dword, void*, dword, int, int, int)")
# 呼び出し: DriverCallback(dwCallback, dwFlags, hDevice, dwMsg, dwUser, dwParam1, dwParam2)
# dwCallback : UINT_PTR -> "int"
# dwFlags : DWORD -> "dword"
# hDevice : HDRVR -> "void*"
# dwMsg : DWORD -> "dword"
# dwUser : UINT_PTR -> "int"
# dwParam1 : UINT_PTR -> "int"
# dwParam2 : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。