Win32 API 日本語リファレンス
ホームMedia.Audio.DirectSound › DirectSoundCreate8

DirectSoundCreate8

関数
DirectSound8再生デバイスオブジェクトを生成する。
DLLDSOUND.dll呼出規約winapi

シグネチャ

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

HRESULT DirectSoundCreate8(
    const GUID* pcGuidDevice,   // optional
    IDirectSound8** ppDS8,
    IUnknown* pUnkOuter   // optional
);

パラメーター

名前方向
pcGuidDeviceGUID*inoptional
ppDS8IDirectSound8**out
pUnkOuterIUnknown*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DirectSoundCreate8(
    const GUID* pcGuidDevice,   // optional
    IDirectSound8** ppDS8,
    IUnknown* pUnkOuter   // optional
);
[DllImport("DSOUND.dll", ExactSpelling = true)]
static extern int DirectSoundCreate8(
    IntPtr pcGuidDevice,   // GUID* optional
    IntPtr ppDS8,   // IDirectSound8** out
    IntPtr pUnkOuter   // IUnknown* optional
);
<DllImport("DSOUND.dll", ExactSpelling:=True)>
Public Shared Function DirectSoundCreate8(
    pcGuidDevice As IntPtr,   ' GUID* optional
    ppDS8 As IntPtr,   ' IDirectSound8** out
    pUnkOuter As IntPtr   ' IUnknown* optional
) As Integer
End Function
' pcGuidDevice : GUID* optional
' ppDS8 : IDirectSound8** out
' pUnkOuter : IUnknown* optional
Declare PtrSafe Function DirectSoundCreate8 Lib "dsound" ( _
    ByVal pcGuidDevice As LongPtr, _
    ByVal ppDS8 As LongPtr, _
    ByVal pUnkOuter As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DirectSoundCreate8 = ctypes.windll.dsound.DirectSoundCreate8
DirectSoundCreate8.restype = ctypes.c_int
DirectSoundCreate8.argtypes = [
    ctypes.c_void_p,  # pcGuidDevice : GUID* optional
    ctypes.c_void_p,  # ppDS8 : IDirectSound8** out
    ctypes.c_void_p,  # pUnkOuter : IUnknown* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DSOUND.dll')
DirectSoundCreate8 = Fiddle::Function.new(
  lib['DirectSoundCreate8'],
  [
    Fiddle::TYPE_VOIDP,  # pcGuidDevice : GUID* optional
    Fiddle::TYPE_VOIDP,  # ppDS8 : IDirectSound8** out
    Fiddle::TYPE_VOIDP,  # pUnkOuter : IUnknown* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "dsound")]
extern "system" {
    fn DirectSoundCreate8(
        pcGuidDevice: *const GUID,  // GUID* optional
        ppDS8: *mut *mut core::ffi::c_void,  // IDirectSound8** out
        pUnkOuter: *mut core::ffi::c_void  // IUnknown* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DSOUND.dll")]
public static extern int DirectSoundCreate8(IntPtr pcGuidDevice, IntPtr ppDS8, IntPtr pUnkOuter);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DSOUND_DirectSoundCreate8' -Namespace Win32 -PassThru
# $api::DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
#uselib "DSOUND.dll"
#func global DirectSoundCreate8 "DirectSoundCreate8" sptr, sptr, sptr
; DirectSoundCreate8 varptr(pcGuidDevice), ppDS8, pUnkOuter   ; 戻り値は stat
; pcGuidDevice : GUID* optional -> "sptr"
; ppDS8 : IDirectSound8** out -> "sptr"
; pUnkOuter : IUnknown* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DSOUND.dll"
#cfunc global DirectSoundCreate8 "DirectSoundCreate8" var, sptr, sptr
; res = DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
; pcGuidDevice : GUID* optional -> "var"
; ppDS8 : IDirectSound8** out -> "sptr"
; pUnkOuter : IUnknown* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT DirectSoundCreate8(GUID* pcGuidDevice, IDirectSound8** ppDS8, IUnknown* pUnkOuter)
#uselib "DSOUND.dll"
#cfunc global DirectSoundCreate8 "DirectSoundCreate8" var, intptr, intptr
; res = DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
; pcGuidDevice : GUID* optional -> "var"
; ppDS8 : IDirectSound8** out -> "intptr"
; pUnkOuter : IUnknown* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dsound = windows.NewLazySystemDLL("DSOUND.dll")
	procDirectSoundCreate8 = dsound.NewProc("DirectSoundCreate8")
)

// pcGuidDevice (GUID* optional), ppDS8 (IDirectSound8** out), pUnkOuter (IUnknown* optional)
r1, _, err := procDirectSoundCreate8.Call(
	uintptr(pcGuidDevice),
	uintptr(ppDS8),
	uintptr(pUnkOuter),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DirectSoundCreate8(
  pcGuidDevice: PGUID;   // GUID* optional
  ppDS8: Pointer;   // IDirectSound8** out
  pUnkOuter: Pointer   // IUnknown* optional
): Integer; stdcall;
  external 'DSOUND.dll' name 'DirectSoundCreate8';
result := DllCall("DSOUND\DirectSoundCreate8"
    , "Ptr", pcGuidDevice   ; GUID* optional
    , "Ptr", ppDS8   ; IDirectSound8** out
    , "Ptr", pUnkOuter   ; IUnknown* optional
    , "Int")   ; return: HRESULT
●DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter) = DLL("DSOUND.dll", "int DirectSoundCreate8(void*, void*, void*)")
# 呼び出し: DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
# pcGuidDevice : GUID* optional -> "void*"
# ppDS8 : IDirectSound8** out -> "void*"
# pUnkOuter : IUnknown* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。