ホーム › Media.Audio › acmDriverAddW
acmDriverAddW
関数ACMドライバーをシステムに追加登録する(Unicode版)。
シグネチャ
// MSACM32.dll (Unicode / -W)
#include <windows.h>
DWORD acmDriverAddW(
HACMDRIVERID* phadid,
HINSTANCE hinstModule,
LPARAM lParam,
DWORD dwPriority,
DWORD fdwAdd
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| phadid | HACMDRIVERID* | inout | インストールされたドライバーを識別するハンドルを受け取るバッファーへのポインター。このハンドルは、他の ACM 関数の呼び出しでドライバーを識別するために使用されます。 | ||||||||||||
| hinstModule | HINSTANCE | in | ドライバーのエントリ関数を含む実行可能ファイルまたはダイナミックリンクライブラリ (DLL) を持つモジュールのインスタンスへのハンドル。 | ||||||||||||
| lParam | LPARAM | in | fdwAdd フラグに応じて、ドライバー関数のアドレスまたは通知ウィンドウのハンドルを指定します。 | ||||||||||||
| dwPriority | DWORD | in | 通知ブロードキャストのために送信するウィンドウメッセージ。このパラメーターは ACM_DRIVERADDF_NOTIFYHWND フラグでのみ使用されます。それ以外のフラグでは、このメンバーをゼロに設定する必要があります。 | ||||||||||||
| fdwAdd | DWORD | in | ACM ドライバーを追加するためのフラグ。次の値が定義されています。
|
戻り値の型: DWORD
公式ドキュメント
acmDriverAddW (Unicode) 関数 (msacm.h) は、利用可能な ACM ドライバーの一覧にドライバーを追加します。(acmDriverAddW)
戻り値
成功した場合はゼロを返し、それ以外の場合はエラーを返します。発生する可能性のあるエラー値には次のものがあります。
| 戻り値 | 説明 |
|---|---|
| 少なくとも 1 つのフラグが無効です。 | |
| 少なくとも 1 つのパラメーターが無効です。 | |
| システムがリソースを割り当てられません。 |
解説(Remarks)
メモ
msacm.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして acmDriverAdd を定義しています。エンコーディング非依存のエイリアスの使用と、エンコーディング非依存ではないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーを引き起こすおそれがあります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MSACM32.dll (Unicode / -W)
#include <windows.h>
DWORD acmDriverAddW(
HACMDRIVERID* phadid,
HINSTANCE hinstModule,
LPARAM lParam,
DWORD dwPriority,
DWORD fdwAdd
);[DllImport("MSACM32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint acmDriverAddW(
IntPtr phadid, // HACMDRIVERID* in/out
IntPtr hinstModule, // HINSTANCE
IntPtr lParam, // LPARAM
uint dwPriority, // DWORD
uint fdwAdd // DWORD
);<DllImport("MSACM32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function acmDriverAddW(
phadid As IntPtr, ' HACMDRIVERID* in/out
hinstModule As IntPtr, ' HINSTANCE
lParam As IntPtr, ' LPARAM
dwPriority As UInteger, ' DWORD
fdwAdd As UInteger ' DWORD
) As UInteger
End Function' phadid : HACMDRIVERID* in/out
' hinstModule : HINSTANCE
' lParam : LPARAM
' dwPriority : DWORD
' fdwAdd : DWORD
Declare PtrSafe Function acmDriverAddW Lib "msacm32" ( _
ByVal phadid As LongPtr, _
ByVal hinstModule As LongPtr, _
ByVal lParam As LongPtr, _
ByVal dwPriority As Long, _
ByVal fdwAdd As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
acmDriverAddW = ctypes.windll.msacm32.acmDriverAddW
acmDriverAddW.restype = wintypes.DWORD
acmDriverAddW.argtypes = [
ctypes.c_void_p, # phadid : HACMDRIVERID* in/out
wintypes.HANDLE, # hinstModule : HINSTANCE
ctypes.c_ssize_t, # lParam : LPARAM
wintypes.DWORD, # dwPriority : DWORD
wintypes.DWORD, # fdwAdd : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSACM32.dll')
acmDriverAddW = Fiddle::Function.new(
lib['acmDriverAddW'],
[
Fiddle::TYPE_VOIDP, # phadid : HACMDRIVERID* in/out
Fiddle::TYPE_VOIDP, # hinstModule : HINSTANCE
Fiddle::TYPE_INTPTR_T, # lParam : LPARAM
-Fiddle::TYPE_INT, # dwPriority : DWORD
-Fiddle::TYPE_INT, # fdwAdd : DWORD
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msacm32")]
extern "system" {
fn acmDriverAddW(
phadid: *mut *mut core::ffi::c_void, // HACMDRIVERID* in/out
hinstModule: *mut core::ffi::c_void, // HINSTANCE
lParam: isize, // LPARAM
dwPriority: u32, // DWORD
fdwAdd: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSACM32.dll", CharSet = CharSet.Unicode)]
public static extern uint acmDriverAddW(IntPtr phadid, IntPtr hinstModule, IntPtr lParam, uint dwPriority, uint fdwAdd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSACM32_acmDriverAddW' -Namespace Win32 -PassThru
# $api::acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)#uselib "MSACM32.dll"
#func global acmDriverAddW "acmDriverAddW" wptr, wptr, wptr, wptr, wptr
; acmDriverAddW phadid, hinstModule, lParam, dwPriority, fdwAdd ; 戻り値は stat
; phadid : HACMDRIVERID* in/out -> "wptr"
; hinstModule : HINSTANCE -> "wptr"
; lParam : LPARAM -> "wptr"
; dwPriority : DWORD -> "wptr"
; fdwAdd : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MSACM32.dll"
#cfunc global acmDriverAddW "acmDriverAddW" sptr, sptr, sptr, int, int
; res = acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)
; phadid : HACMDRIVERID* in/out -> "sptr"
; hinstModule : HINSTANCE -> "sptr"
; lParam : LPARAM -> "sptr"
; dwPriority : DWORD -> "int"
; fdwAdd : DWORD -> "int"; DWORD acmDriverAddW(HACMDRIVERID* phadid, HINSTANCE hinstModule, LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
#uselib "MSACM32.dll"
#cfunc global acmDriverAddW "acmDriverAddW" intptr, intptr, intptr, int, int
; res = acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)
; phadid : HACMDRIVERID* in/out -> "intptr"
; hinstModule : HINSTANCE -> "intptr"
; lParam : LPARAM -> "intptr"
; dwPriority : DWORD -> "int"
; fdwAdd : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msacm32 = windows.NewLazySystemDLL("MSACM32.dll")
procacmDriverAddW = msacm32.NewProc("acmDriverAddW")
)
// phadid (HACMDRIVERID* in/out), hinstModule (HINSTANCE), lParam (LPARAM), dwPriority (DWORD), fdwAdd (DWORD)
r1, _, err := procacmDriverAddW.Call(
uintptr(phadid),
uintptr(hinstModule),
uintptr(lParam),
uintptr(dwPriority),
uintptr(fdwAdd),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction acmDriverAddW(
phadid: Pointer; // HACMDRIVERID* in/out
hinstModule: THandle; // HINSTANCE
lParam: NativeInt; // LPARAM
dwPriority: DWORD; // DWORD
fdwAdd: DWORD // DWORD
): DWORD; stdcall;
external 'MSACM32.dll' name 'acmDriverAddW';result := DllCall("MSACM32\acmDriverAddW"
, "Ptr", phadid ; HACMDRIVERID* in/out
, "Ptr", hinstModule ; HINSTANCE
, "Ptr", lParam ; LPARAM
, "UInt", dwPriority ; DWORD
, "UInt", fdwAdd ; DWORD
, "UInt") ; return: DWORD●acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd) = DLL("MSACM32.dll", "dword acmDriverAddW(void*, void*, int, dword, dword)")
# 呼び出し: acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)
# phadid : HACMDRIVERID* in/out -> "void*"
# hinstModule : HINSTANCE -> "void*"
# lParam : LPARAM -> "int"
# dwPriority : DWORD -> "dword"
# fdwAdd : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "msacm32" fn acmDriverAddW(
phadid: ?*anyopaque, // HACMDRIVERID* in/out
hinstModule: ?*anyopaque, // HINSTANCE
lParam: isize, // LPARAM
dwPriority: u32, // DWORD
fdwAdd: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc acmDriverAddW(
phadid: pointer, # HACMDRIVERID* in/out
hinstModule: pointer, # HINSTANCE
lParam: int, # LPARAM
dwPriority: uint32, # DWORD
fdwAdd: uint32 # DWORD
): uint32 {.importc: "acmDriverAddW", stdcall, dynlib: "MSACM32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "msacm32");
extern(Windows)
uint acmDriverAddW(
void* phadid, // HACMDRIVERID* in/out
void* hinstModule, // HINSTANCE
ptrdiff_t lParam, // LPARAM
uint dwPriority, // DWORD
uint fdwAdd // DWORD
);ccall((:acmDriverAddW, "MSACM32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{Cvoid}, Int, UInt32, UInt32),
phadid, hinstModule, lParam, dwPriority, fdwAdd)
# phadid : HACMDRIVERID* in/out -> Ptr{Cvoid}
# hinstModule : HINSTANCE -> Ptr{Cvoid}
# lParam : LPARAM -> Int
# dwPriority : DWORD -> UInt32
# fdwAdd : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t acmDriverAddW(
void* phadid,
void* hinstModule,
intptr_t lParam,
uint32_t dwPriority,
uint32_t fdwAdd);
]]
local msacm32 = ffi.load("msacm32")
-- msacm32.acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)
-- phadid : HACMDRIVERID* in/out
-- hinstModule : HINSTANCE
-- lParam : LPARAM
-- dwPriority : DWORD
-- fdwAdd : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('MSACM32.dll');
const acmDriverAddW = lib.func('__stdcall', 'acmDriverAddW', 'uint32_t', ['void *', 'void *', 'intptr_t', 'uint32_t', 'uint32_t']);
// acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)
// phadid : HACMDRIVERID* in/out -> 'void *'
// hinstModule : HINSTANCE -> 'void *'
// lParam : LPARAM -> 'intptr_t'
// dwPriority : DWORD -> 'uint32_t'
// fdwAdd : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSACM32.dll", {
acmDriverAddW: { parameters: ["pointer", "pointer", "isize", "u32", "u32"], result: "u32" },
});
// lib.symbols.acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd)
// phadid : HACMDRIVERID* in/out -> "pointer"
// hinstModule : HINSTANCE -> "pointer"
// lParam : LPARAM -> "isize"
// dwPriority : DWORD -> "u32"
// fdwAdd : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t acmDriverAddW(
void* phadid,
void* hinstModule,
intptr_t lParam,
uint32_t dwPriority,
uint32_t fdwAdd);
C, "MSACM32.dll");
// $ffi->acmDriverAddW(phadid, hinstModule, lParam, dwPriority, fdwAdd);
// phadid : HACMDRIVERID* in/out
// hinstModule : HINSTANCE
// lParam : LPARAM
// dwPriority : DWORD
// fdwAdd : DWORD
// 構造体/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 Msacm32 extends StdCallLibrary {
Msacm32 INSTANCE = Native.load("msacm32", Msacm32.class, W32APIOptions.UNICODE_OPTIONS);
int acmDriverAddW(
Pointer phadid, // HACMDRIVERID* in/out
Pointer hinstModule, // HINSTANCE
long lParam, // LPARAM
int dwPriority, // DWORD
int fdwAdd // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("msacm32")]
lib LibMSACM32
fun acmDriverAddW = acmDriverAddW(
phadid : Void*, # HACMDRIVERID* in/out
hinstModule : Void*, # HINSTANCE
lParam : LibC::SSizeT, # LPARAM
dwPriority : UInt32, # DWORD
fdwAdd : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef acmDriverAddWNative = Uint32 Function(Pointer<Void>, Pointer<Void>, IntPtr, Uint32, Uint32);
typedef acmDriverAddWDart = int Function(Pointer<Void>, Pointer<Void>, int, int, int);
final acmDriverAddW = DynamicLibrary.open('MSACM32.dll')
.lookupFunction<acmDriverAddWNative, acmDriverAddWDart>('acmDriverAddW');
// phadid : HACMDRIVERID* in/out -> Pointer<Void>
// hinstModule : HINSTANCE -> Pointer<Void>
// lParam : LPARAM -> IntPtr
// dwPriority : DWORD -> Uint32
// fdwAdd : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function acmDriverAddW(
phadid: Pointer; // HACMDRIVERID* in/out
hinstModule: THandle; // HINSTANCE
lParam: NativeInt; // LPARAM
dwPriority: DWORD; // DWORD
fdwAdd: DWORD // DWORD
): DWORD; stdcall;
external 'MSACM32.dll' name 'acmDriverAddW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "acmDriverAddW"
c_acmDriverAddW :: Ptr () -> Ptr () -> CIntPtr -> Word32 -> Word32 -> IO Word32
-- phadid : HACMDRIVERID* in/out -> Ptr ()
-- hinstModule : HINSTANCE -> Ptr ()
-- lParam : LPARAM -> CIntPtr
-- dwPriority : DWORD -> Word32
-- fdwAdd : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let acmdriveraddw =
foreign "acmDriverAddW"
((ptr void) @-> (ptr void) @-> intptr_t @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* phadid : HACMDRIVERID* in/out -> (ptr void) *)
(* hinstModule : HINSTANCE -> (ptr void) *)
(* lParam : LPARAM -> intptr_t *)
(* dwPriority : DWORD -> uint32_t *)
(* fdwAdd : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msacm32 (t "MSACM32.dll"))
(cffi:use-foreign-library msacm32)
(cffi:defcfun ("acmDriverAddW" acm-driver-add-w :convention :stdcall) :uint32
(phadid :pointer) ; HACMDRIVERID* in/out
(hinst-module :pointer) ; HINSTANCE
(l-param :int64) ; LPARAM
(dw-priority :uint32) ; DWORD
(fdw-add :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $acmDriverAddW = Win32::API::More->new('MSACM32',
'DWORD acmDriverAddW(HANDLE phadid, HANDLE hinstModule, LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)');
# my $ret = $acmDriverAddW->Call($phadid, $hinstModule, $lParam, $dwPriority, $fdwAdd);
# phadid : HACMDRIVERID* in/out -> HANDLE
# hinstModule : HINSTANCE -> HANDLE
# lParam : LPARAM -> LPARAM
# dwPriority : DWORD -> DWORD
# fdwAdd : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f acmDriverAddA (ANSI版) — ACMドライバーをシステムに追加登録する(ANSI版)。