ホーム › Media.Audio › PlaySoundA
PlaySoundA
関数ファイル・リソース・別名からサウンドを再生する(ANSI版)。
シグネチャ
// WINMM.dll (ANSI / -A)
#include <windows.h>
BOOL PlaySoundA(
LPCSTR pszSound, // optional
HMODULE hmod, // optional
SND_FLAGS fdwSound
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszSound | LPCSTR | inoptional |
| hmod | HMODULE | inoptional |
| fdwSound | SND_FLAGS | in |
戻り値の型: BOOL
各言語での呼び出し定義
// WINMM.dll (ANSI / -A)
#include <windows.h>
BOOL PlaySoundA(
LPCSTR pszSound, // optional
HMODULE hmod, // optional
SND_FLAGS fdwSound
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINMM.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool PlaySoundA(
[MarshalAs(UnmanagedType.LPStr)] string pszSound, // LPCSTR optional
IntPtr hmod, // HMODULE optional
uint fdwSound // SND_FLAGS
);<DllImport("WINMM.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PlaySoundA(
<MarshalAs(UnmanagedType.LPStr)> pszSound As String, ' LPCSTR optional
hmod As IntPtr, ' HMODULE optional
fdwSound As UInteger ' SND_FLAGS
) As Boolean
End Function' pszSound : LPCSTR optional
' hmod : HMODULE optional
' fdwSound : SND_FLAGS
Declare PtrSafe Function PlaySoundA Lib "winmm" ( _
ByVal pszSound As String, _
ByVal hmod As LongPtr, _
ByVal fdwSound As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PlaySoundA = ctypes.windll.winmm.PlaySoundA
PlaySoundA.restype = wintypes.BOOL
PlaySoundA.argtypes = [
wintypes.LPCSTR, # pszSound : LPCSTR optional
wintypes.HANDLE, # hmod : HMODULE optional
wintypes.DWORD, # fdwSound : SND_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WINMM.dll')
PlaySoundA = Fiddle::Function.new(
lib['PlaySoundA'],
[
Fiddle::TYPE_VOIDP, # pszSound : LPCSTR optional
Fiddle::TYPE_VOIDP, # hmod : HMODULE optional
-Fiddle::TYPE_INT, # fdwSound : SND_FLAGS
],
Fiddle::TYPE_INT)#[link(name = "winmm")]
extern "system" {
fn PlaySoundA(
pszSound: *const u8, // LPCSTR optional
hmod: *mut core::ffi::c_void, // HMODULE optional
fdwSound: u32 // SND_FLAGS
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINMM.dll", CharSet = CharSet.Ansi)]
public static extern bool PlaySoundA([MarshalAs(UnmanagedType.LPStr)] string pszSound, IntPtr hmod, uint fdwSound);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_PlaySoundA' -Namespace Win32 -PassThru
# $api::PlaySoundA(pszSound, hmod, fdwSound)#uselib "WINMM.dll"
#func global PlaySoundA "PlaySoundA" sptr, sptr, sptr
; PlaySoundA pszSound, hmod, fdwSound ; 戻り値は stat
; pszSound : LPCSTR optional -> "sptr"
; hmod : HMODULE optional -> "sptr"
; fdwSound : SND_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WINMM.dll"
#cfunc global PlaySoundA "PlaySoundA" str, sptr, int
; res = PlaySoundA(pszSound, hmod, fdwSound)
; pszSound : LPCSTR optional -> "str"
; hmod : HMODULE optional -> "sptr"
; fdwSound : SND_FLAGS -> "int"; BOOL PlaySoundA(LPCSTR pszSound, HMODULE hmod, SND_FLAGS fdwSound)
#uselib "WINMM.dll"
#cfunc global PlaySoundA "PlaySoundA" str, intptr, int
; res = PlaySoundA(pszSound, hmod, fdwSound)
; pszSound : LPCSTR optional -> "str"
; hmod : HMODULE optional -> "intptr"
; fdwSound : SND_FLAGS -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winmm = windows.NewLazySystemDLL("WINMM.dll")
procPlaySoundA = winmm.NewProc("PlaySoundA")
)
// pszSound (LPCSTR optional), hmod (HMODULE optional), fdwSound (SND_FLAGS)
r1, _, err := procPlaySoundA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszSound))),
uintptr(hmod),
uintptr(fdwSound),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction PlaySoundA(
pszSound: PAnsiChar; // LPCSTR optional
hmod: THandle; // HMODULE optional
fdwSound: DWORD // SND_FLAGS
): BOOL; stdcall;
external 'WINMM.dll' name 'PlaySoundA';result := DllCall("WINMM\PlaySoundA"
, "AStr", pszSound ; LPCSTR optional
, "Ptr", hmod ; HMODULE optional
, "UInt", fdwSound ; SND_FLAGS
, "Int") ; return: BOOL●PlaySoundA(pszSound, hmod, fdwSound) = DLL("WINMM.dll", "bool PlaySoundA(char*, void*, dword)")
# 呼び出し: PlaySoundA(pszSound, hmod, fdwSound)
# pszSound : LPCSTR optional -> "char*"
# hmod : HMODULE optional -> "void*"
# fdwSound : SND_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。