MCIWndCreateW
関数シグネチャ
// MSVFW32.dll (Unicode / -W)
#include <windows.h>
HWND MCIWndCreateW(
HWND hwndParent, // optional
HINSTANCE hInstance, // optional
DWORD dwStyle,
LPCWSTR szFile // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hwndParent | HWND | inoptional | 親ウィンドウのハンドルです。 | ||||||||||||||||||||||||||||||||||||||
| hInstance | HINSTANCE | inoptional | MCIWnd ウィンドウに関連付けるモジュールインスタンスのハンドルです。 | ||||||||||||||||||||||||||||||||||||||
| dwStyle | DWORD | in | ウィンドウスタイルを定義するフラグです。CreateWindowEx 関数で使用するウィンドウスタイルを指定できるほか、MCIWnd ウィンドウで使用する次のスタイルを指定できます。
| ||||||||||||||||||||||||||||||||||||||
| szFile | LPCWSTR | inoptional | 開く MCI デバイスまたはデータファイルの名前を示す、null で終わる文字列です。 |
戻り値の型: HWND
公式ドキュメント
MCIWndCreate 関数は MCIWnd ウィンドウクラスを登録し、MCI サービスを利用するための MCIWnd ウィンドウを作成します。MCIWndCreate は、MCI デバイスやファイル(AVI ファイルなど)を開いて MCIWnd ウィンドウに関連付けることもできます。(Unicode)
戻り値
成功した場合は MCI ウィンドウへのハンドルを返し、それ以外の場合はゼロを返します。
解説(Remarks)
子ウィンドウの既定のウィンドウスタイルは WS_CHILD、WS_BORDER、WS_VISIBLE です。親ウィンドウのハンドルとして NULL 以外の値が指定された場合、MCIWndCreate は子ウィンドウとみなします。
親ウィンドウの既定のウィンドウスタイルは WS_OVERLAPPEDWINDOW および WS_VISIBLE です。親ウィンドウのハンドルとして NULL が指定された場合、MCIWndCreate は親ウィンドウとみなします。
MCIWnd マクロでウィンドウハンドルを指定する際は、この関数が返すウィンドウハンドルを使用してください。アプリケーションがこの関数を使用する場合、MCIWndRegisterClass 関数を使用する必要はありません。
vfw.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MCIWndCreate を定義します。エンコーディング中立のエイリアスの使用とエンコーディング中立でないコードを混在させると、不一致が生じ、コンパイルエラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規約 を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MSVFW32.dll (Unicode / -W)
#include <windows.h>
HWND MCIWndCreateW(
HWND hwndParent, // optional
HINSTANCE hInstance, // optional
DWORD dwStyle,
LPCWSTR szFile // optional
);[DllImport("MSVFW32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr MCIWndCreateW(
IntPtr hwndParent, // HWND optional
IntPtr hInstance, // HINSTANCE optional
uint dwStyle, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string szFile // LPCWSTR optional
);<DllImport("MSVFW32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function MCIWndCreateW(
hwndParent As IntPtr, ' HWND optional
hInstance As IntPtr, ' HINSTANCE optional
dwStyle As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> szFile As String ' LPCWSTR optional
) As IntPtr
End Function' hwndParent : HWND optional
' hInstance : HINSTANCE optional
' dwStyle : DWORD
' szFile : LPCWSTR optional
Declare PtrSafe Function MCIWndCreateW Lib "msvfw32" ( _
ByVal hwndParent As LongPtr, _
ByVal hInstance As LongPtr, _
ByVal dwStyle As Long, _
ByVal szFile As LongPtr) As LongPtr
' 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
MCIWndCreateW = ctypes.cdll.msvfw32.MCIWndCreateW
MCIWndCreateW.restype = ctypes.c_void_p
MCIWndCreateW.argtypes = [
wintypes.HANDLE, # hwndParent : HWND optional
wintypes.HANDLE, # hInstance : HINSTANCE optional
wintypes.DWORD, # dwStyle : DWORD
wintypes.LPCWSTR, # szFile : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSVFW32.dll')
MCIWndCreateW = Fiddle::Function.new(
lib['MCIWndCreateW'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE optional
-Fiddle::TYPE_INT, # dwStyle : DWORD
Fiddle::TYPE_VOIDP, # szFile : LPCWSTR optional
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msvfw32")]
extern "C" {
fn MCIWndCreateW(
hwndParent: *mut core::ffi::c_void, // HWND optional
hInstance: *mut core::ffi::c_void, // HINSTANCE optional
dwStyle: u32, // DWORD
szFile: *const u16 // LPCWSTR optional
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSVFW32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr MCIWndCreateW(IntPtr hwndParent, IntPtr hInstance, uint dwStyle, [MarshalAs(UnmanagedType.LPWStr)] string szFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSVFW32_MCIWndCreateW' -Namespace Win32 -PassThru
# $api::MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)#uselib "MSVFW32.dll"
#func global MCIWndCreateW "MCIWndCreateW" wptr, wptr, wptr, wptr
; MCIWndCreateW hwndParent, hInstance, dwStyle, szFile ; 戻り値は stat
; hwndParent : HWND optional -> "wptr"
; hInstance : HINSTANCE optional -> "wptr"
; dwStyle : DWORD -> "wptr"
; szFile : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MSVFW32.dll"
#cfunc global MCIWndCreateW "MCIWndCreateW" sptr, sptr, int, wstr
; res = MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)
; hwndParent : HWND optional -> "sptr"
; hInstance : HINSTANCE optional -> "sptr"
; dwStyle : DWORD -> "int"
; szFile : LPCWSTR optional -> "wstr"; HWND MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCWSTR szFile)
#uselib "MSVFW32.dll"
#cfunc global MCIWndCreateW "MCIWndCreateW" intptr, intptr, int, wstr
; res = MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)
; hwndParent : HWND optional -> "intptr"
; hInstance : HINSTANCE optional -> "intptr"
; dwStyle : DWORD -> "int"
; szFile : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msvfw32 = windows.NewLazySystemDLL("MSVFW32.dll")
procMCIWndCreateW = msvfw32.NewProc("MCIWndCreateW")
)
// hwndParent (HWND optional), hInstance (HINSTANCE optional), dwStyle (DWORD), szFile (LPCWSTR optional)
r1, _, err := procMCIWndCreateW.Call(
uintptr(hwndParent),
uintptr(hInstance),
uintptr(dwStyle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFile))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HWNDfunction MCIWndCreateW(
hwndParent: THandle; // HWND optional
hInstance: THandle; // HINSTANCE optional
dwStyle: DWORD; // DWORD
szFile: PWideChar // LPCWSTR optional
): THandle; cdecl;
external 'MSVFW32.dll' name 'MCIWndCreateW';result := DllCall("MSVFW32\MCIWndCreateW"
, "Ptr", hwndParent ; HWND optional
, "Ptr", hInstance ; HINSTANCE optional
, "UInt", dwStyle ; DWORD
, "WStr", szFile ; LPCWSTR optional
, "Cdecl Ptr") ; return: HWND●MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile) = DLL("MSVFW32.dll", "void* MCIWndCreateW(void*, void*, dword, char*)")
# 呼び出し: MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)
# hwndParent : HWND optional -> "void*"
# hInstance : HINSTANCE optional -> "void*"
# dwStyle : DWORD -> "dword"
# szFile : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "msvfw32" fn MCIWndCreateW(
hwndParent: ?*anyopaque, // HWND optional
hInstance: ?*anyopaque, // HINSTANCE optional
dwStyle: u32, // DWORD
szFile: [*c]const u16 // LPCWSTR optional
) callconv(.c) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc MCIWndCreateW(
hwndParent: pointer, # HWND optional
hInstance: pointer, # HINSTANCE optional
dwStyle: uint32, # DWORD
szFile: WideCString # LPCWSTR optional
): pointer {.importc: "MCIWndCreateW", cdecl, dynlib: "MSVFW32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "msvfw32");
extern(C)
void* MCIWndCreateW(
void* hwndParent, // HWND optional
void* hInstance, // HINSTANCE optional
uint dwStyle, // DWORD
const(wchar)* szFile // LPCWSTR optional
);ccall((:MCIWndCreateW, "MSVFW32.dll"), Ptr{Cvoid},
(Ptr{Cvoid}, Ptr{Cvoid}, UInt32, Cwstring),
hwndParent, hInstance, dwStyle, szFile)
# hwndParent : HWND optional -> Ptr{Cvoid}
# hInstance : HINSTANCE optional -> Ptr{Cvoid}
# dwStyle : DWORD -> UInt32
# szFile : LPCWSTR optional -> Cwstring
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
void* MCIWndCreateW(
void* hwndParent,
void* hInstance,
uint32_t dwStyle,
const uint16_t* szFile);
]]
local msvfw32 = ffi.load("msvfw32")
-- msvfw32.MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)
-- hwndParent : HWND optional
-- hInstance : HINSTANCE optional
-- dwStyle : DWORD
-- szFile : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('MSVFW32.dll');
const MCIWndCreateW = lib.func('__cdecl', 'MCIWndCreateW', 'void *', ['void *', 'void *', 'uint32_t', 'str16']);
// MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)
// hwndParent : HWND optional -> 'void *'
// hInstance : HINSTANCE optional -> 'void *'
// dwStyle : DWORD -> 'uint32_t'
// szFile : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSVFW32.dll", {
MCIWndCreateW: { parameters: ["pointer", "pointer", "u32", "buffer"], result: "pointer" },
});
// lib.symbols.MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile)
// hwndParent : HWND optional -> "pointer"
// hInstance : HINSTANCE optional -> "pointer"
// dwStyle : DWORD -> "u32"
// szFile : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* MCIWndCreateW(
void* hwndParent,
void* hInstance,
uint32_t dwStyle,
const uint16_t* szFile);
C, "MSVFW32.dll");
// $ffi->MCIWndCreateW(hwndParent, hInstance, dwStyle, szFile);
// hwndParent : HWND optional
// hInstance : HINSTANCE optional
// dwStyle : DWORD
// szFile : LPCWSTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Msvfw32 extends Library {
Msvfw32 INSTANCE = Native.load("msvfw32", Msvfw32.class, W32APIOptions.UNICODE_OPTIONS);
Pointer MCIWndCreateW(
Pointer hwndParent, // HWND optional
Pointer hInstance, // HINSTANCE optional
int dwStyle, // DWORD
WString szFile // LPCWSTR optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("msvfw32")]
lib LibMSVFW32
fun MCIWndCreateW = MCIWndCreateW(
hwndParent : Void*, # HWND optional
hInstance : Void*, # HINSTANCE optional
dwStyle : UInt32, # DWORD
szFile : UInt16* # LPCWSTR optional
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MCIWndCreateWNative = Pointer<Void> Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Utf16>);
typedef MCIWndCreateWDart = Pointer<Void> Function(Pointer<Void>, Pointer<Void>, int, Pointer<Utf16>);
final MCIWndCreateW = DynamicLibrary.open('MSVFW32.dll')
.lookupFunction<MCIWndCreateWNative, MCIWndCreateWDart>('MCIWndCreateW');
// hwndParent : HWND optional -> Pointer<Void>
// hInstance : HINSTANCE optional -> Pointer<Void>
// dwStyle : DWORD -> Uint32
// szFile : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MCIWndCreateW(
hwndParent: THandle; // HWND optional
hInstance: THandle; // HINSTANCE optional
dwStyle: DWORD; // DWORD
szFile: PWideChar // LPCWSTR optional
): THandle; cdecl;
external 'MSVFW32.dll' name 'MCIWndCreateW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "MCIWndCreateW"
c_MCIWndCreateW :: Ptr () -> Ptr () -> Word32 -> CWString -> IO (Ptr ())
-- hwndParent : HWND optional -> Ptr ()
-- hInstance : HINSTANCE optional -> Ptr ()
-- dwStyle : DWORD -> Word32
-- szFile : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mciwndcreatew =
foreign "MCIWndCreateW"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint16_t) @-> returning (ptr void))
(* hwndParent : HWND optional -> (ptr void) *)
(* hInstance : HINSTANCE optional -> (ptr void) *)
(* dwStyle : DWORD -> uint32_t *)
(* szFile : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msvfw32 (t "MSVFW32.dll"))
(cffi:use-foreign-library msvfw32)
(cffi:defcfun ("MCIWndCreateW" mciwnd-create-w :convention :cdecl) :pointer
(hwnd-parent :pointer) ; HWND optional
(h-instance :pointer) ; HINSTANCE optional
(dw-style :uint32) ; DWORD
(sz-file (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MCIWndCreateW = Win32::API::More->new('MSVFW32',
'HANDLE MCIWndCreateW(HANDLE hwndParent, HANDLE hInstance, DWORD dwStyle, LPCWSTR szFile)');
# my $ret = $MCIWndCreateW->Call($hwndParent, $hInstance, $dwStyle, $szFile);
# hwndParent : HWND optional -> HANDLE
# hInstance : HINSTANCE optional -> HANDLE
# dwStyle : DWORD -> DWORD
# szFile : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f MCIWndCreateA (ANSI版) — MCIメディア再生用のウィンドウを作成する(ANSI版)。
- f MCIWndRegisterClass — MCIWndウィンドウクラスを登録する。