ホーム › Media.Audio.DirectSound › DirectSoundCreate8
DirectSoundCreate8
関数DirectSound8再生デバイスオブジェクトを生成する。
シグネチャ
// DSOUND.dll
#include <windows.h>
HRESULT DirectSoundCreate8(
const GUID* pcGuidDevice, // optional
IDirectSound8** ppDS8,
IUnknown* pUnkOuter // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pcGuidDevice | GUID* | inoptional | 使用するサウンドデバイスのGUIDへのポインタ。NULLで既定デバイス。 |
| ppDS8 | IDirectSound8** | out | 生成されたIDirectSound8インターフェースを受け取るポインタ。 |
| pUnkOuter | IUnknown* | inoptional | アグリゲーション用の外側IUnknown。通常はNULL。 |
戻り値の型: 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 方式にも切替可。#uselib "DSOUND.dll" #cfunc global DirectSoundCreate8 "DirectSoundCreate8" sptr, sptr, sptr ; res = DirectSoundCreate8(varptr(pcGuidDevice), ppDS8, pUnkOuter) ; pcGuidDevice : GUID* optional -> "sptr" ; ppDS8 : IDirectSound8** out -> "sptr" ; pUnkOuter : IUnknown* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; HRESULT DirectSoundCreate8(GUID* pcGuidDevice, IDirectSound8** ppDS8, IUnknown* pUnkOuter) #uselib "DSOUND.dll" #cfunc global DirectSoundCreate8 "DirectSoundCreate8" intptr, intptr, intptr ; res = DirectSoundCreate8(varptr(pcGuidDevice), ppDS8, pUnkOuter) ; pcGuidDevice : GUID* optional -> "intptr" ; ppDS8 : IDirectSound8** out -> "intptr" ; pUnkOuter : IUnknown* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。const std = @import("std");
extern "dsound" fn DirectSoundCreate8(
pcGuidDevice: [*c]GUID, // GUID* optional
ppDS8: ?*anyopaque, // IDirectSound8** out
pUnkOuter: ?*anyopaque // IUnknown* optional
) callconv(std.os.windows.WINAPI) i32;proc DirectSoundCreate8(
pcGuidDevice: ptr GUID, # GUID* optional
ppDS8: pointer, # IDirectSound8** out
pUnkOuter: pointer # IUnknown* optional
): int32 {.importc: "DirectSoundCreate8", stdcall, dynlib: "DSOUND.dll".}pragma(lib, "dsound");
extern(Windows)
int DirectSoundCreate8(
GUID* pcGuidDevice, // GUID* optional
void* ppDS8, // IDirectSound8** out
void* pUnkOuter // IUnknown* optional
);ccall((:DirectSoundCreate8, "DSOUND.dll"), stdcall, Int32,
(Ptr{GUID}, Ptr{Cvoid}, Ptr{Cvoid}),
pcGuidDevice, ppDS8, pUnkOuter)
# pcGuidDevice : GUID* optional -> Ptr{GUID}
# ppDS8 : IDirectSound8** out -> Ptr{Cvoid}
# pUnkOuter : IUnknown* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DirectSoundCreate8(
void* pcGuidDevice,
void* ppDS8,
void* pUnkOuter);
]]
local dsound = ffi.load("dsound")
-- dsound.DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
-- pcGuidDevice : GUID* optional
-- ppDS8 : IDirectSound8** out
-- pUnkOuter : IUnknown* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DSOUND.dll');
const DirectSoundCreate8 = lib.func('__stdcall', 'DirectSoundCreate8', 'int32_t', ['void *', 'void *', 'void *']);
// DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
// pcGuidDevice : GUID* optional -> 'void *'
// ppDS8 : IDirectSound8** out -> 'void *'
// pUnkOuter : IUnknown* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DSOUND.dll", {
DirectSoundCreate8: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter)
// pcGuidDevice : GUID* optional -> "pointer"
// ppDS8 : IDirectSound8** out -> "pointer"
// pUnkOuter : IUnknown* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DirectSoundCreate8(
void* pcGuidDevice,
void* ppDS8,
void* pUnkOuter);
C, "DSOUND.dll");
// $ffi->DirectSoundCreate8(pcGuidDevice, ppDS8, pUnkOuter);
// pcGuidDevice : GUID* optional
// ppDS8 : IDirectSound8** out
// pUnkOuter : IUnknown* optional
// 構造体/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 Dsound extends StdCallLibrary {
Dsound INSTANCE = Native.load("dsound", Dsound.class);
int DirectSoundCreate8(
Pointer pcGuidDevice, // GUID* optional
Pointer ppDS8, // IDirectSound8** out
Pointer pUnkOuter // IUnknown* optional
);
}@[Link("dsound")]
lib LibDSOUND
fun DirectSoundCreate8 = DirectSoundCreate8(
pcGuidDevice : GUID*, # GUID* optional
ppDS8 : Void*, # IDirectSound8** out
pUnkOuter : Void* # IUnknown* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DirectSoundCreate8Native = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef DirectSoundCreate8Dart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final DirectSoundCreate8 = DynamicLibrary.open('DSOUND.dll')
.lookupFunction<DirectSoundCreate8Native, DirectSoundCreate8Dart>('DirectSoundCreate8');
// pcGuidDevice : GUID* optional -> Pointer<Void>
// ppDS8 : IDirectSound8** out -> Pointer<Void>
// pUnkOuter : IUnknown* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DirectSoundCreate8(
pcGuidDevice: PGUID; // GUID* optional
ppDS8: Pointer; // IDirectSound8** out
pUnkOuter: Pointer // IUnknown* optional
): Integer; stdcall;
external 'DSOUND.dll' name 'DirectSoundCreate8';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DirectSoundCreate8"
c_DirectSoundCreate8 :: Ptr () -> Ptr () -> Ptr () -> IO Int32
-- pcGuidDevice : GUID* optional -> Ptr ()
-- ppDS8 : IDirectSound8** out -> Ptr ()
-- pUnkOuter : IUnknown* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let directsoundcreate8 =
foreign "DirectSoundCreate8"
((ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pcGuidDevice : GUID* optional -> (ptr void) *)
(* ppDS8 : IDirectSound8** out -> (ptr void) *)
(* pUnkOuter : IUnknown* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dsound (t "DSOUND.dll"))
(cffi:use-foreign-library dsound)
(cffi:defcfun ("DirectSoundCreate8" direct-sound-create8 :convention :stdcall) :int32
(pc-guid-device :pointer) ; GUID* optional
(pp-ds8 :pointer) ; IDirectSound8** out
(p-unk-outer :pointer)) ; IUnknown* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DirectSoundCreate8 = Win32::API::More->new('DSOUND',
'int DirectSoundCreate8(LPVOID pcGuidDevice, LPVOID ppDS8, LPVOID pUnkOuter)');
# my $ret = $DirectSoundCreate8->Call($pcGuidDevice, $ppDS8, $pUnkOuter);
# pcGuidDevice : GUID* optional -> LPVOID
# ppDS8 : IDirectSound8** out -> LPVOID
# pUnkOuter : IUnknown* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f DirectSoundCreate — DirectSoundデバイスオブジェクトを生成して初期化する。