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

mciSendCommandA

関数
MCIデバイスにコマンドメッセージを送信する(ANSI版)。
DLLWINMM.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// WINMM.dll  (ANSI / -A)
#include <windows.h>

DWORD mciSendCommandA(
    DWORD mciId,
    DWORD uMsg,
    UINT_PTR dwParam1,   // optional
    UINT_PTR dwParam2   // optional
);

パラメーター

名前方向
mciIdDWORDin
uMsgDWORDin
dwParam1UINT_PTRinoptional
dwParam2UINT_PTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

// WINMM.dll  (ANSI / -A)
#include <windows.h>

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

mciSendCommandA = ctypes.windll.winmm.mciSendCommandA
mciSendCommandA.restype = wintypes.DWORD
mciSendCommandA.argtypes = [
    wintypes.DWORD,  # mciId : DWORD
    wintypes.DWORD,  # uMsg : DWORD
    ctypes.c_size_t,  # dwParam1 : UINT_PTR optional
    ctypes.c_size_t,  # dwParam2 : UINT_PTR optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	winmm = windows.NewLazySystemDLL("WINMM.dll")
	procmciSendCommandA = winmm.NewProc("mciSendCommandA")
)

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