ホーム › Media.Audio.DirectSound › GetDeviceID
GetDeviceID
関数既定のサウンドデバイス指定子から実デバイスのGUIDを取得する。
シグネチャ
// DSOUND.dll
#include <windows.h>
HRESULT GetDeviceID(
const GUID* pGuidSrc, // optional
GUID* pGuidDest
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pGuidSrc | GUID* | inoptional |
| pGuidDest | GUID* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// DSOUND.dll
#include <windows.h>
HRESULT GetDeviceID(
const GUID* pGuidSrc, // optional
GUID* pGuidDest
);[DllImport("DSOUND.dll", ExactSpelling = true)]
static extern int GetDeviceID(
IntPtr pGuidSrc, // GUID* optional
out Guid pGuidDest // GUID* out
);<DllImport("DSOUND.dll", ExactSpelling:=True)>
Public Shared Function GetDeviceID(
pGuidSrc As IntPtr, ' GUID* optional
<Out> ByRef pGuidDest As Guid ' GUID* out
) As Integer
End Function' pGuidSrc : GUID* optional
' pGuidDest : GUID* out
Declare PtrSafe Function GetDeviceID Lib "dsound" ( _
ByVal pGuidSrc As LongPtr, _
ByVal pGuidDest As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetDeviceID = ctypes.windll.dsound.GetDeviceID
GetDeviceID.restype = ctypes.c_int
GetDeviceID.argtypes = [
ctypes.c_void_p, # pGuidSrc : GUID* optional
ctypes.c_void_p, # pGuidDest : GUID* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DSOUND.dll')
GetDeviceID = Fiddle::Function.new(
lib['GetDeviceID'],
[
Fiddle::TYPE_VOIDP, # pGuidSrc : GUID* optional
Fiddle::TYPE_VOIDP, # pGuidDest : GUID* out
],
Fiddle::TYPE_INT)#[link(name = "dsound")]
extern "system" {
fn GetDeviceID(
pGuidSrc: *const GUID, // GUID* optional
pGuidDest: *mut GUID // GUID* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DSOUND.dll")]
public static extern int GetDeviceID(IntPtr pGuidSrc, out Guid pGuidDest);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DSOUND_GetDeviceID' -Namespace Win32 -PassThru
# $api::GetDeviceID(pGuidSrc, pGuidDest)#uselib "DSOUND.dll"
#func global GetDeviceID "GetDeviceID" sptr, sptr
; GetDeviceID varptr(pGuidSrc), varptr(pGuidDest) ; 戻り値は stat
; pGuidSrc : GUID* optional -> "sptr"
; pGuidDest : GUID* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DSOUND.dll" #cfunc global GetDeviceID "GetDeviceID" var, var ; res = GetDeviceID(pGuidSrc, pGuidDest) ; pGuidSrc : GUID* optional -> "var" ; pGuidDest : GUID* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DSOUND.dll" #cfunc global GetDeviceID "GetDeviceID" sptr, sptr ; res = GetDeviceID(varptr(pGuidSrc), varptr(pGuidDest)) ; pGuidSrc : GUID* optional -> "sptr" ; pGuidDest : GUID* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetDeviceID(GUID* pGuidSrc, GUID* pGuidDest) #uselib "DSOUND.dll" #cfunc global GetDeviceID "GetDeviceID" var, var ; res = GetDeviceID(pGuidSrc, pGuidDest) ; pGuidSrc : GUID* optional -> "var" ; pGuidDest : GUID* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetDeviceID(GUID* pGuidSrc, GUID* pGuidDest) #uselib "DSOUND.dll" #cfunc global GetDeviceID "GetDeviceID" intptr, intptr ; res = GetDeviceID(varptr(pGuidSrc), varptr(pGuidDest)) ; pGuidSrc : GUID* optional -> "intptr" ; pGuidDest : GUID* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dsound = windows.NewLazySystemDLL("DSOUND.dll")
procGetDeviceID = dsound.NewProc("GetDeviceID")
)
// pGuidSrc (GUID* optional), pGuidDest (GUID* out)
r1, _, err := procGetDeviceID.Call(
uintptr(pGuidSrc),
uintptr(pGuidDest),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetDeviceID(
pGuidSrc: PGUID; // GUID* optional
pGuidDest: PGUID // GUID* out
): Integer; stdcall;
external 'DSOUND.dll' name 'GetDeviceID';result := DllCall("DSOUND\GetDeviceID"
, "Ptr", pGuidSrc ; GUID* optional
, "Ptr", pGuidDest ; GUID* out
, "Int") ; return: HRESULT●GetDeviceID(pGuidSrc, pGuidDest) = DLL("DSOUND.dll", "int GetDeviceID(void*, void*)")
# 呼び出し: GetDeviceID(pGuidSrc, pGuidDest)
# pGuidSrc : GUID* optional -> "void*"
# pGuidDest : GUID* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。