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

waveOutSetVolume

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

シグネチャ

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

DWORD waveOutSetVolume(
    HWAVEOUT hwo,   // optional
    DWORD dwVolume
);

パラメーター

名前方向
hwoHWAVEOUTinoptional
dwVolumeDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

waveOutSetVolume = ctypes.windll.winmm.waveOutSetVolume
waveOutSetVolume.restype = wintypes.DWORD
waveOutSetVolume.argtypes = [
    wintypes.HANDLE,  # hwo : HWAVEOUT optional
    wintypes.DWORD,  # dwVolume : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINMM.dll')
waveOutSetVolume = Fiddle::Function.new(
  lib['waveOutSetVolume'],
  [
    Fiddle::TYPE_VOIDP,  # hwo : HWAVEOUT optional
    -Fiddle::TYPE_INT,  # dwVolume : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "winmm")]
extern "system" {
    fn waveOutSetVolume(
        hwo: *mut core::ffi::c_void,  // HWAVEOUT optional
        dwVolume: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WINMM.dll")]
public static extern uint waveOutSetVolume(IntPtr hwo, uint dwVolume);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_waveOutSetVolume' -Namespace Win32 -PassThru
# $api::waveOutSetVolume(hwo, dwVolume)
#uselib "WINMM.dll"
#func global waveOutSetVolume "waveOutSetVolume" sptr, sptr
; waveOutSetVolume hwo, dwVolume   ; 戻り値は stat
; hwo : HWAVEOUT optional -> "sptr"
; dwVolume : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINMM.dll"
#cfunc global waveOutSetVolume "waveOutSetVolume" sptr, int
; res = waveOutSetVolume(hwo, dwVolume)
; hwo : HWAVEOUT optional -> "sptr"
; dwVolume : DWORD -> "int"
; DWORD waveOutSetVolume(HWAVEOUT hwo, DWORD dwVolume)
#uselib "WINMM.dll"
#cfunc global waveOutSetVolume "waveOutSetVolume" intptr, int
; res = waveOutSetVolume(hwo, dwVolume)
; hwo : HWAVEOUT optional -> "intptr"
; dwVolume : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winmm = windows.NewLazySystemDLL("WINMM.dll")
	procwaveOutSetVolume = winmm.NewProc("waveOutSetVolume")
)

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