ホーム › Media.Multimedia › OpenDriver
OpenDriver
関数インストール可能ドライバーを開く。
シグネチャ
// WINMM.dll
#include <windows.h>
HDRVR OpenDriver(
LPCWSTR szDriverName,
LPCWSTR szSectionName,
LPARAM lParam2
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szDriverName | LPCWSTR | in |
| szSectionName | LPCWSTR | in |
| lParam2 | LPARAM | in |
戻り値の型: HDRVR
各言語での呼び出し定義
// WINMM.dll
#include <windows.h>
HDRVR OpenDriver(
LPCWSTR szDriverName,
LPCWSTR szSectionName,
LPARAM lParam2
);[DllImport("WINMM.dll", ExactSpelling = true)]
static extern IntPtr OpenDriver(
[MarshalAs(UnmanagedType.LPWStr)] string szDriverName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szSectionName, // LPCWSTR
IntPtr lParam2 // LPARAM
);<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function OpenDriver(
<MarshalAs(UnmanagedType.LPWStr)> szDriverName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szSectionName As String, ' LPCWSTR
lParam2 As IntPtr ' LPARAM
) As IntPtr
End Function' szDriverName : LPCWSTR
' szSectionName : LPCWSTR
' lParam2 : LPARAM
Declare PtrSafe Function OpenDriver Lib "winmm" ( _
ByVal szDriverName As LongPtr, _
ByVal szSectionName As LongPtr, _
ByVal lParam2 As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OpenDriver = ctypes.windll.winmm.OpenDriver
OpenDriver.restype = ctypes.c_void_p
OpenDriver.argtypes = [
wintypes.LPCWSTR, # szDriverName : LPCWSTR
wintypes.LPCWSTR, # szSectionName : LPCWSTR
ctypes.c_ssize_t, # lParam2 : LPARAM
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINMM.dll')
OpenDriver = Fiddle::Function.new(
lib['OpenDriver'],
[
Fiddle::TYPE_VOIDP, # szDriverName : LPCWSTR
Fiddle::TYPE_VOIDP, # szSectionName : LPCWSTR
Fiddle::TYPE_INTPTR_T, # lParam2 : LPARAM
],
Fiddle::TYPE_VOIDP)#[link(name = "winmm")]
extern "system" {
fn OpenDriver(
szDriverName: *const u16, // LPCWSTR
szSectionName: *const u16, // LPCWSTR
lParam2: isize // LPARAM
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WINMM.dll")]
public static extern IntPtr OpenDriver([MarshalAs(UnmanagedType.LPWStr)] string szDriverName, [MarshalAs(UnmanagedType.LPWStr)] string szSectionName, IntPtr lParam2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_OpenDriver' -Namespace Win32 -PassThru
# $api::OpenDriver(szDriverName, szSectionName, lParam2)#uselib "WINMM.dll"
#func global OpenDriver "OpenDriver" sptr, sptr, sptr
; OpenDriver szDriverName, szSectionName, lParam2 ; 戻り値は stat
; szDriverName : LPCWSTR -> "sptr"
; szSectionName : LPCWSTR -> "sptr"
; lParam2 : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WINMM.dll"
#cfunc global OpenDriver "OpenDriver" wstr, wstr, sptr
; res = OpenDriver(szDriverName, szSectionName, lParam2)
; szDriverName : LPCWSTR -> "wstr"
; szSectionName : LPCWSTR -> "wstr"
; lParam2 : LPARAM -> "sptr"; HDRVR OpenDriver(LPCWSTR szDriverName, LPCWSTR szSectionName, LPARAM lParam2)
#uselib "WINMM.dll"
#cfunc global OpenDriver "OpenDriver" wstr, wstr, intptr
; res = OpenDriver(szDriverName, szSectionName, lParam2)
; szDriverName : LPCWSTR -> "wstr"
; szSectionName : LPCWSTR -> "wstr"
; lParam2 : LPARAM -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winmm = windows.NewLazySystemDLL("WINMM.dll")
procOpenDriver = winmm.NewProc("OpenDriver")
)
// szDriverName (LPCWSTR), szSectionName (LPCWSTR), lParam2 (LPARAM)
r1, _, err := procOpenDriver.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szDriverName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szSectionName))),
uintptr(lParam2),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HDRVRfunction OpenDriver(
szDriverName: PWideChar; // LPCWSTR
szSectionName: PWideChar; // LPCWSTR
lParam2: NativeInt // LPARAM
): THandle; stdcall;
external 'WINMM.dll' name 'OpenDriver';result := DllCall("WINMM\OpenDriver"
, "WStr", szDriverName ; LPCWSTR
, "WStr", szSectionName ; LPCWSTR
, "Ptr", lParam2 ; LPARAM
, "Ptr") ; return: HDRVR●OpenDriver(szDriverName, szSectionName, lParam2) = DLL("WINMM.dll", "void* OpenDriver(char*, char*, int)")
# 呼び出し: OpenDriver(szDriverName, szSectionName, lParam2)
# szDriverName : LPCWSTR -> "char*"
# szSectionName : LPCWSTR -> "char*"
# lParam2 : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。