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

mciSendCommandW

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

シグネチャ

// WINMM.dll  (Unicode / -W)
#include <windows.h>

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

パラメーター

名前方向
mciIdDWORDin
uMsgDWORDin
dwParam1UINT_PTRinoptional
dwParam2UINT_PTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

// WINMM.dll  (Unicode / -W)
#include <windows.h>

DWORD mciSendCommandW(
    DWORD mciId,
    DWORD uMsg,
    UINT_PTR dwParam1,   // optional
    UINT_PTR dwParam2   // optional
);
[DllImport("WINMM.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint mciSendCommandW(
    uint mciId,   // DWORD
    uint uMsg,   // DWORD
    UIntPtr dwParam1,   // UINT_PTR optional
    UIntPtr dwParam2   // UINT_PTR optional
);
<DllImport("WINMM.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function mciSendCommandW(
    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 mciSendCommandW Lib "winmm" ( _
    ByVal mciId As Long, _
    ByVal uMsg As Long, _
    ByVal dwParam1 As LongPtr, _
    ByVal dwParam2 As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

mciSendCommandW = ctypes.windll.winmm.mciSendCommandW
mciSendCommandW.restype = wintypes.DWORD
mciSendCommandW.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')
mciSendCommandW = Fiddle::Function.new(
  lib['mciSendCommandW'],
  [
    -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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "winmm")]
extern "system" {
    fn mciSendCommandW(
        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.Unicode)]
public static extern uint mciSendCommandW(uint mciId, uint uMsg, UIntPtr dwParam1, UIntPtr dwParam2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINMM_mciSendCommandW' -Namespace Win32 -PassThru
# $api::mciSendCommandW(mciId, uMsg, dwParam1, dwParam2)
#uselib "WINMM.dll"
#func global mciSendCommandW "mciSendCommandW" wptr, wptr, wptr, wptr
; mciSendCommandW mciId, uMsg, dwParam1, dwParam2   ; 戻り値は stat
; mciId : DWORD -> "wptr"
; uMsg : DWORD -> "wptr"
; dwParam1 : UINT_PTR optional -> "wptr"
; dwParam2 : UINT_PTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINMM.dll"
#cfunc global mciSendCommandW "mciSendCommandW" int, int, sptr, sptr
; res = mciSendCommandW(mciId, uMsg, dwParam1, dwParam2)
; mciId : DWORD -> "int"
; uMsg : DWORD -> "int"
; dwParam1 : UINT_PTR optional -> "sptr"
; dwParam2 : UINT_PTR optional -> "sptr"
; DWORD mciSendCommandW(DWORD mciId, DWORD uMsg, UINT_PTR dwParam1, UINT_PTR dwParam2)
#uselib "WINMM.dll"
#cfunc global mciSendCommandW "mciSendCommandW" int, int, intptr, intptr
; res = mciSendCommandW(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")
	procmciSendCommandW = winmm.NewProc("mciSendCommandW")
)

// mciId (DWORD), uMsg (DWORD), dwParam1 (UINT_PTR optional), dwParam2 (UINT_PTR optional)
r1, _, err := procmciSendCommandW.Call(
	uintptr(mciId),
	uintptr(uMsg),
	uintptr(dwParam1),
	uintptr(dwParam2),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function mciSendCommandW(
  mciId: DWORD;   // DWORD
  uMsg: DWORD;   // DWORD
  dwParam1: NativeUInt;   // UINT_PTR optional
  dwParam2: NativeUInt   // UINT_PTR optional
): DWORD; stdcall;
  external 'WINMM.dll' name 'mciSendCommandW';
result := DllCall("WINMM\mciSendCommandW"
    , "UInt", mciId   ; DWORD
    , "UInt", uMsg   ; DWORD
    , "UPtr", dwParam1   ; UINT_PTR optional
    , "UPtr", dwParam2   ; UINT_PTR optional
    , "UInt")   ; return: DWORD
●mciSendCommandW(mciId, uMsg, dwParam1, dwParam2) = DLL("WINMM.dll", "dword mciSendCommandW(dword, dword, int, int)")
# 呼び出し: mciSendCommandW(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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。