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

waveOutGetVolume

関数
波形出力デバイスの現在の音量を取得する。
DLLWINMM.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD waveOutGetVolume(
    HWAVEOUT hwo,   // optional
    DWORD* pdwVolume
);

パラメーター

名前方向
hwoHWAVEOUTinoptional
pdwVolumeDWORD*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD waveOutGetVolume(
    HWAVEOUT hwo,   // optional
    DWORD* pdwVolume
);
[DllImport("WINMM.dll", ExactSpelling = true)]
static extern uint waveOutGetVolume(
    IntPtr hwo,   // HWAVEOUT optional
    out uint pdwVolume   // DWORD* out
);
<DllImport("WINMM.dll", ExactSpelling:=True)>
Public Shared Function waveOutGetVolume(
    hwo As IntPtr,   ' HWAVEOUT optional
    <Out> ByRef pdwVolume As UInteger   ' DWORD* out
) As UInteger
End Function
' hwo : HWAVEOUT optional
' pdwVolume : DWORD* out
Declare PtrSafe Function waveOutGetVolume Lib "winmm" ( _
    ByVal hwo As LongPtr, _
    ByRef pdwVolume As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

waveOutGetVolume = ctypes.windll.winmm.waveOutGetVolume
waveOutGetVolume.restype = wintypes.DWORD
waveOutGetVolume.argtypes = [
    wintypes.HANDLE,  # hwo : HWAVEOUT optional
    ctypes.POINTER(wintypes.DWORD),  # pdwVolume : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winmm = windows.NewLazySystemDLL("WINMM.dll")
	procwaveOutGetVolume = winmm.NewProc("waveOutGetVolume")
)

// hwo (HWAVEOUT optional), pdwVolume (DWORD* out)
r1, _, err := procwaveOutGetVolume.Call(
	uintptr(hwo),
	uintptr(pdwVolume),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function waveOutGetVolume(
  hwo: THandle;   // HWAVEOUT optional
  pdwVolume: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'WINMM.dll' name 'waveOutGetVolume';
result := DllCall("WINMM\waveOutGetVolume"
    , "Ptr", hwo   ; HWAVEOUT optional
    , "Ptr", pdwVolume   ; DWORD* out
    , "UInt")   ; return: DWORD
●waveOutGetVolume(hwo, pdwVolume) = DLL("WINMM.dll", "dword waveOutGetVolume(void*, void*)")
# 呼び出し: waveOutGetVolume(hwo, pdwVolume)
# hwo : HWAVEOUT optional -> "void*"
# pdwVolume : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。