ホーム › Media.Audio › acmDriverPriority
acmDriverPriority
関数ACMドライバーの優先順位を設定し有効化や無効化を制御する。
シグネチャ
// MSACM32.dll
#include <windows.h>
DWORD acmDriverPriority(
HACMDRIVERID hadid,
DWORD dwPriority,
DWORD fdwPriority
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hadid | HACMDRIVERID | in | インストール済みの ACM ドライバーのドライバー識別子へのハンドル。ACM_DRIVERPRIORITYF_BEGIN フラグおよび ACM_DRIVERPRIORITYF_END フラグを指定する場合、このパラメーターは NULL でなければなりません。 | ||||||||||
| dwPriority | DWORD | in | グローバル ACM ドライバー識別子の新しい優先度。0 を指定すると、ドライバー識別子の優先度は変更されません。1 を指定すると、ドライバーは検索優先度が最も高いドライバーとして配置されます。–1 を指定すると、ドライバーは検索優先度が最も低いドライバーとして配置されます。優先度はグローバル ドライバーに対してのみ使用されます。 | ||||||||||
| fdwPriority | DWORD | in | ACM ドライバーの優先度を設定するためのフラグ。次の値が定義されています。
|
戻り値の型: DWORD
公式ドキュメント
acmDriverPriority 関数は、ACM ドライバーの優先度と状態を変更します。
戻り値
成功した場合は 0 を返し、そうでない場合はエラーを返します。考えられるエラー値には次のものがあります。
| 戻り値 | 説明 |
|---|---|
| 延期されたブロードキャスト ロックが別のタスクによって所有されています。 | |
| 少なくとも 1 つのフラグが無効です。 | |
| 指定されたハンドルが無効です。 | |
| 少なくとも 1 つのパラメーターが無効です。 | |
| 要求された操作は指定されたドライバーではサポートされていません。たとえば、ローカルおよび通知ドライバー識別子は優先度をサポートしていません(ただし有効化および無効化は可能です)。アプリケーションがローカルおよび通知ドライバー識別子に対して dwPriority に 0 以外の値を指定した場合、このエラーが返されます。 |
解説(Remarks)
グローバル、ローカル、通知ドライバー識別子を含むすべてのドライバー識別子は、有効化および無効化できます。
複数のグローバル ドライバー識別子を有効化、無効化、または優先度の変更を行う必要がある場合、アプリケーションは ACM_DRIVERPRIORITYF_BEGIN フラグを使用して変更通知のブロードキャストを延期する必要があります。ACM_DRIVERPRIORITYF_END フラグを指定すると、単一の変更通知がブロードキャストされます。
アプリケーションは、acmMetrics の ACM_METRIC_DRIVER_PRIORITY メトリック インデックスとともにこの関数を使用して、グローバル ドライバーの現在の優先度を取得できます。ドライバーは acmDriverEnum 関数によって、常に優先度の高いものから低いものへと列挙されます。
有効なすべてのドライバー識別子は変更通知を受け取ります。アプリケーションは、acmDriverAdd 関数を ACM_DRIVERADDF_NOTIFYHWND フラグとともに使用して通知メッセージを登録できます。非グローバル ドライバー識別子への変更はブロードキャストされません。
優先度は、アプリケーションがドライバーを指定しない場合の検索順序に使用されるだけです。ドライバーの優先度を上げても、ドライバーのパフォーマンスには影響しません。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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
#include <windows.h>
DWORD acmDriverPriority(
HACMDRIVERID hadid,
DWORD dwPriority,
DWORD fdwPriority
);[DllImport("MSACM32.dll", ExactSpelling = true)]
static extern uint acmDriverPriority(
IntPtr hadid, // HACMDRIVERID
uint dwPriority, // DWORD
uint fdwPriority // DWORD
);<DllImport("MSACM32.dll", ExactSpelling:=True)>
Public Shared Function acmDriverPriority(
hadid As IntPtr, ' HACMDRIVERID
dwPriority As UInteger, ' DWORD
fdwPriority As UInteger ' DWORD
) As UInteger
End Function' hadid : HACMDRIVERID
' dwPriority : DWORD
' fdwPriority : DWORD
Declare PtrSafe Function acmDriverPriority Lib "msacm32" ( _
ByVal hadid As LongPtr, _
ByVal dwPriority As Long, _
ByVal fdwPriority As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
acmDriverPriority = ctypes.windll.msacm32.acmDriverPriority
acmDriverPriority.restype = wintypes.DWORD
acmDriverPriority.argtypes = [
wintypes.HANDLE, # hadid : HACMDRIVERID
wintypes.DWORD, # dwPriority : DWORD
wintypes.DWORD, # fdwPriority : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSACM32.dll')
acmDriverPriority = Fiddle::Function.new(
lib['acmDriverPriority'],
[
Fiddle::TYPE_VOIDP, # hadid : HACMDRIVERID
-Fiddle::TYPE_INT, # dwPriority : DWORD
-Fiddle::TYPE_INT, # fdwPriority : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "msacm32")]
extern "system" {
fn acmDriverPriority(
hadid: *mut core::ffi::c_void, // HACMDRIVERID
dwPriority: u32, // DWORD
fdwPriority: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSACM32.dll")]
public static extern uint acmDriverPriority(IntPtr hadid, uint dwPriority, uint fdwPriority);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSACM32_acmDriverPriority' -Namespace Win32 -PassThru
# $api::acmDriverPriority(hadid, dwPriority, fdwPriority)#uselib "MSACM32.dll"
#func global acmDriverPriority "acmDriverPriority" sptr, sptr, sptr
; acmDriverPriority hadid, dwPriority, fdwPriority ; 戻り値は stat
; hadid : HACMDRIVERID -> "sptr"
; dwPriority : DWORD -> "sptr"
; fdwPriority : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MSACM32.dll"
#cfunc global acmDriverPriority "acmDriverPriority" sptr, int, int
; res = acmDriverPriority(hadid, dwPriority, fdwPriority)
; hadid : HACMDRIVERID -> "sptr"
; dwPriority : DWORD -> "int"
; fdwPriority : DWORD -> "int"; DWORD acmDriverPriority(HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
#uselib "MSACM32.dll"
#cfunc global acmDriverPriority "acmDriverPriority" intptr, int, int
; res = acmDriverPriority(hadid, dwPriority, fdwPriority)
; hadid : HACMDRIVERID -> "intptr"
; dwPriority : DWORD -> "int"
; fdwPriority : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msacm32 = windows.NewLazySystemDLL("MSACM32.dll")
procacmDriverPriority = msacm32.NewProc("acmDriverPriority")
)
// hadid (HACMDRIVERID), dwPriority (DWORD), fdwPriority (DWORD)
r1, _, err := procacmDriverPriority.Call(
uintptr(hadid),
uintptr(dwPriority),
uintptr(fdwPriority),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction acmDriverPriority(
hadid: THandle; // HACMDRIVERID
dwPriority: DWORD; // DWORD
fdwPriority: DWORD // DWORD
): DWORD; stdcall;
external 'MSACM32.dll' name 'acmDriverPriority';result := DllCall("MSACM32\acmDriverPriority"
, "Ptr", hadid ; HACMDRIVERID
, "UInt", dwPriority ; DWORD
, "UInt", fdwPriority ; DWORD
, "UInt") ; return: DWORD●acmDriverPriority(hadid, dwPriority, fdwPriority) = DLL("MSACM32.dll", "dword acmDriverPriority(void*, dword, dword)")
# 呼び出し: acmDriverPriority(hadid, dwPriority, fdwPriority)
# hadid : HACMDRIVERID -> "void*"
# dwPriority : DWORD -> "dword"
# fdwPriority : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msacm32" fn acmDriverPriority(
hadid: ?*anyopaque, // HACMDRIVERID
dwPriority: u32, // DWORD
fdwPriority: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc acmDriverPriority(
hadid: pointer, # HACMDRIVERID
dwPriority: uint32, # DWORD
fdwPriority: uint32 # DWORD
): uint32 {.importc: "acmDriverPriority", stdcall, dynlib: "MSACM32.dll".}pragma(lib, "msacm32");
extern(Windows)
uint acmDriverPriority(
void* hadid, // HACMDRIVERID
uint dwPriority, // DWORD
uint fdwPriority // DWORD
);ccall((:acmDriverPriority, "MSACM32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, UInt32),
hadid, dwPriority, fdwPriority)
# hadid : HACMDRIVERID -> Ptr{Cvoid}
# dwPriority : DWORD -> UInt32
# fdwPriority : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t acmDriverPriority(
void* hadid,
uint32_t dwPriority,
uint32_t fdwPriority);
]]
local msacm32 = ffi.load("msacm32")
-- msacm32.acmDriverPriority(hadid, dwPriority, fdwPriority)
-- hadid : HACMDRIVERID
-- dwPriority : DWORD
-- fdwPriority : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSACM32.dll');
const acmDriverPriority = lib.func('__stdcall', 'acmDriverPriority', 'uint32_t', ['void *', 'uint32_t', 'uint32_t']);
// acmDriverPriority(hadid, dwPriority, fdwPriority)
// hadid : HACMDRIVERID -> 'void *'
// dwPriority : DWORD -> 'uint32_t'
// fdwPriority : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSACM32.dll", {
acmDriverPriority: { parameters: ["pointer", "u32", "u32"], result: "u32" },
});
// lib.symbols.acmDriverPriority(hadid, dwPriority, fdwPriority)
// hadid : HACMDRIVERID -> "pointer"
// dwPriority : DWORD -> "u32"
// fdwPriority : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t acmDriverPriority(
void* hadid,
uint32_t dwPriority,
uint32_t fdwPriority);
C, "MSACM32.dll");
// $ffi->acmDriverPriority(hadid, dwPriority, fdwPriority);
// hadid : HACMDRIVERID
// dwPriority : DWORD
// fdwPriority : 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);
int acmDriverPriority(
Pointer hadid, // HACMDRIVERID
int dwPriority, // DWORD
int fdwPriority // DWORD
);
}@[Link("msacm32")]
lib LibMSACM32
fun acmDriverPriority = acmDriverPriority(
hadid : Void*, # HACMDRIVERID
dwPriority : UInt32, # DWORD
fdwPriority : 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 acmDriverPriorityNative = Uint32 Function(Pointer<Void>, Uint32, Uint32);
typedef acmDriverPriorityDart = int Function(Pointer<Void>, int, int);
final acmDriverPriority = DynamicLibrary.open('MSACM32.dll')
.lookupFunction<acmDriverPriorityNative, acmDriverPriorityDart>('acmDriverPriority');
// hadid : HACMDRIVERID -> Pointer<Void>
// dwPriority : DWORD -> Uint32
// fdwPriority : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function acmDriverPriority(
hadid: THandle; // HACMDRIVERID
dwPriority: DWORD; // DWORD
fdwPriority: DWORD // DWORD
): DWORD; stdcall;
external 'MSACM32.dll' name 'acmDriverPriority';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "acmDriverPriority"
c_acmDriverPriority :: Ptr () -> Word32 -> Word32 -> IO Word32
-- hadid : HACMDRIVERID -> Ptr ()
-- dwPriority : DWORD -> Word32
-- fdwPriority : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let acmdriverpriority =
foreign "acmDriverPriority"
((ptr void) @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* hadid : HACMDRIVERID -> (ptr void) *)
(* dwPriority : DWORD -> uint32_t *)
(* fdwPriority : 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 ("acmDriverPriority" acm-driver-priority :convention :stdcall) :uint32
(hadid :pointer) ; HACMDRIVERID
(dw-priority :uint32) ; DWORD
(fdw-priority :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $acmDriverPriority = Win32::API::More->new('MSACM32',
'DWORD acmDriverPriority(HANDLE hadid, DWORD dwPriority, DWORD fdwPriority)');
# my $ret = $acmDriverPriority->Call($hadid, $dwPriority, $fdwPriority);
# hadid : HACMDRIVERID -> HANDLE
# dwPriority : DWORD -> DWORD
# fdwPriority : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。