ホーム › Media.Multimedia › capCreateCaptureWindowW
capCreateCaptureWindowW
関数ビデオキャプチャ用ウィンドウを作成する(Unicode版)。
シグネチャ
// AVICAP32.dll (Unicode / -W)
#include <windows.h>
HWND capCreateCaptureWindowW(
LPCWSTR lpszWindowName,
DWORD dwStyle,
INT x,
INT y,
INT nWidth,
INT nHeight,
HWND hwndParent, // optional
INT nID
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpszWindowName | LPCWSTR | in | キャプチャウィンドウに使用する名前を格納した、null で終わる文字列。 |
| dwStyle | DWORD | in | キャプチャウィンドウに使用するウィンドウスタイル。ウィンドウスタイルについては CreateWindowEx 関数で説明されています。 |
| x | INT | in | キャプチャウィンドウの左上隅の x 座標。 |
| y | INT | in | キャプチャウィンドウの左上隅の y 座標。 |
| nWidth | INT | in | キャプチャウィンドウの幅。 |
| nHeight | INT | in | キャプチャウィンドウの高さ。 |
| hwndParent | HWND | inoptional | 親ウィンドウへのハンドル。 |
| nID | INT | in | ウィンドウ識別子。 |
戻り値の型: HWND
公式ドキュメント
capCreateCaptureWindow 関数は、キャプチャウィンドウを作成します。(Unicode)
戻り値
成功した場合はキャプチャウィンドウのハンドルを返し、それ以外の場合は NULL を返します。
解説(Remarks)
メモ
vfw.h ヘッダーは、capCreateCaptureWindow を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在させて使用すると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// AVICAP32.dll (Unicode / -W)
#include <windows.h>
HWND capCreateCaptureWindowW(
LPCWSTR lpszWindowName,
DWORD dwStyle,
INT x,
INT y,
INT nWidth,
INT nHeight,
HWND hwndParent, // optional
INT nID
);[DllImport("AVICAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr capCreateCaptureWindowW(
[MarshalAs(UnmanagedType.LPWStr)] string lpszWindowName, // LPCWSTR
uint dwStyle, // DWORD
int x, // INT
int y, // INT
int nWidth, // INT
int nHeight, // INT
IntPtr hwndParent, // HWND optional
int nID // INT
);<DllImport("AVICAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function capCreateCaptureWindowW(
<MarshalAs(UnmanagedType.LPWStr)> lpszWindowName As String, ' LPCWSTR
dwStyle As UInteger, ' DWORD
x As Integer, ' INT
y As Integer, ' INT
nWidth As Integer, ' INT
nHeight As Integer, ' INT
hwndParent As IntPtr, ' HWND optional
nID As Integer ' INT
) As IntPtr
End Function' lpszWindowName : LPCWSTR
' dwStyle : DWORD
' x : INT
' y : INT
' nWidth : INT
' nHeight : INT
' hwndParent : HWND optional
' nID : INT
Declare PtrSafe Function capCreateCaptureWindowW Lib "avicap32" ( _
ByVal lpszWindowName As LongPtr, _
ByVal dwStyle As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hwndParent As LongPtr, _
ByVal nID As Long) 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
capCreateCaptureWindowW = ctypes.windll.avicap32.capCreateCaptureWindowW
capCreateCaptureWindowW.restype = ctypes.c_void_p
capCreateCaptureWindowW.argtypes = [
wintypes.LPCWSTR, # lpszWindowName : LPCWSTR
wintypes.DWORD, # dwStyle : DWORD
ctypes.c_int, # x : INT
ctypes.c_int, # y : INT
ctypes.c_int, # nWidth : INT
ctypes.c_int, # nHeight : INT
wintypes.HANDLE, # hwndParent : HWND optional
ctypes.c_int, # nID : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('AVICAP32.dll')
capCreateCaptureWindowW = Fiddle::Function.new(
lib['capCreateCaptureWindowW'],
[
Fiddle::TYPE_VOIDP, # lpszWindowName : LPCWSTR
-Fiddle::TYPE_INT, # dwStyle : DWORD
Fiddle::TYPE_INT, # x : INT
Fiddle::TYPE_INT, # y : INT
Fiddle::TYPE_INT, # nWidth : INT
Fiddle::TYPE_INT, # nHeight : INT
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
Fiddle::TYPE_INT, # nID : INT
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "avicap32")]
extern "system" {
fn capCreateCaptureWindowW(
lpszWindowName: *const u16, // LPCWSTR
dwStyle: u32, // DWORD
x: i32, // INT
y: i32, // INT
nWidth: i32, // INT
nHeight: i32, // INT
hwndParent: *mut core::ffi::c_void, // HWND optional
nID: i32 // INT
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("AVICAP32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr capCreateCaptureWindowW([MarshalAs(UnmanagedType.LPWStr)] string lpszWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hwndParent, int nID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVICAP32_capCreateCaptureWindowW' -Namespace Win32 -PassThru
# $api::capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)#uselib "AVICAP32.dll"
#func global capCreateCaptureWindowW "capCreateCaptureWindowW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; capCreateCaptureWindowW lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID ; 戻り値は stat
; lpszWindowName : LPCWSTR -> "wptr"
; dwStyle : DWORD -> "wptr"
; x : INT -> "wptr"
; y : INT -> "wptr"
; nWidth : INT -> "wptr"
; nHeight : INT -> "wptr"
; hwndParent : HWND optional -> "wptr"
; nID : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "AVICAP32.dll"
#cfunc global capCreateCaptureWindowW "capCreateCaptureWindowW" wstr, int, int, int, int, int, sptr, int
; res = capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
; lpszWindowName : LPCWSTR -> "wstr"
; dwStyle : DWORD -> "int"
; x : INT -> "int"
; y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hwndParent : HWND optional -> "sptr"
; nID : INT -> "int"; HWND capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x, INT y, INT nWidth, INT nHeight, HWND hwndParent, INT nID)
#uselib "AVICAP32.dll"
#cfunc global capCreateCaptureWindowW "capCreateCaptureWindowW" wstr, int, int, int, int, int, intptr, int
; res = capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
; lpszWindowName : LPCWSTR -> "wstr"
; dwStyle : DWORD -> "int"
; x : INT -> "int"
; y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hwndParent : HWND optional -> "intptr"
; nID : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
avicap32 = windows.NewLazySystemDLL("AVICAP32.dll")
proccapCreateCaptureWindowW = avicap32.NewProc("capCreateCaptureWindowW")
)
// lpszWindowName (LPCWSTR), dwStyle (DWORD), x (INT), y (INT), nWidth (INT), nHeight (INT), hwndParent (HWND optional), nID (INT)
r1, _, err := proccapCreateCaptureWindowW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszWindowName))),
uintptr(dwStyle),
uintptr(x),
uintptr(y),
uintptr(nWidth),
uintptr(nHeight),
uintptr(hwndParent),
uintptr(nID),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HWNDfunction capCreateCaptureWindowW(
lpszWindowName: PWideChar; // LPCWSTR
dwStyle: DWORD; // DWORD
x: Integer; // INT
y: Integer; // INT
nWidth: Integer; // INT
nHeight: Integer; // INT
hwndParent: THandle; // HWND optional
nID: Integer // INT
): THandle; stdcall;
external 'AVICAP32.dll' name 'capCreateCaptureWindowW';result := DllCall("AVICAP32\capCreateCaptureWindowW"
, "WStr", lpszWindowName ; LPCWSTR
, "UInt", dwStyle ; DWORD
, "Int", x ; INT
, "Int", y ; INT
, "Int", nWidth ; INT
, "Int", nHeight ; INT
, "Ptr", hwndParent ; HWND optional
, "Int", nID ; INT
, "Ptr") ; return: HWND●capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID) = DLL("AVICAP32.dll", "void* capCreateCaptureWindowW(char*, dword, int, int, int, int, void*, int)")
# 呼び出し: capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
# lpszWindowName : LPCWSTR -> "char*"
# dwStyle : DWORD -> "dword"
# x : INT -> "int"
# y : INT -> "int"
# nWidth : INT -> "int"
# nHeight : INT -> "int"
# hwndParent : HWND optional -> "void*"
# nID : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "avicap32" fn capCreateCaptureWindowW(
lpszWindowName: [*c]const u16, // LPCWSTR
dwStyle: u32, // DWORD
x: i32, // INT
y: i32, // INT
nWidth: i32, // INT
nHeight: i32, // INT
hwndParent: ?*anyopaque, // HWND optional
nID: i32 // INT
) callconv(std.os.windows.WINAPI) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc capCreateCaptureWindowW(
lpszWindowName: WideCString, # LPCWSTR
dwStyle: uint32, # DWORD
x: int32, # INT
y: int32, # INT
nWidth: int32, # INT
nHeight: int32, # INT
hwndParent: pointer, # HWND optional
nID: int32 # INT
): pointer {.importc: "capCreateCaptureWindowW", stdcall, dynlib: "AVICAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "avicap32");
extern(Windows)
void* capCreateCaptureWindowW(
const(wchar)* lpszWindowName, // LPCWSTR
uint dwStyle, // DWORD
int x, // INT
int y, // INT
int nWidth, // INT
int nHeight, // INT
void* hwndParent, // HWND optional
int nID // INT
);ccall((:capCreateCaptureWindowW, "AVICAP32.dll"), stdcall, Ptr{Cvoid},
(Cwstring, UInt32, Int32, Int32, Int32, Int32, Ptr{Cvoid}, Int32),
lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
# lpszWindowName : LPCWSTR -> Cwstring
# dwStyle : DWORD -> UInt32
# x : INT -> Int32
# y : INT -> Int32
# nWidth : INT -> Int32
# nHeight : INT -> Int32
# hwndParent : HWND optional -> Ptr{Cvoid}
# nID : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
void* capCreateCaptureWindowW(
const uint16_t* lpszWindowName,
uint32_t dwStyle,
int32_t x,
int32_t y,
int32_t nWidth,
int32_t nHeight,
void* hwndParent,
int32_t nID);
]]
local avicap32 = ffi.load("avicap32")
-- avicap32.capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
-- lpszWindowName : LPCWSTR
-- dwStyle : DWORD
-- x : INT
-- y : INT
-- nWidth : INT
-- nHeight : INT
-- hwndParent : HWND optional
-- nID : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('AVICAP32.dll');
const capCreateCaptureWindowW = lib.func('__stdcall', 'capCreateCaptureWindowW', 'void *', ['str16', 'uint32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'int32_t']);
// capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
// lpszWindowName : LPCWSTR -> 'str16'
// dwStyle : DWORD -> 'uint32_t'
// x : INT -> 'int32_t'
// y : INT -> 'int32_t'
// nWidth : INT -> 'int32_t'
// nHeight : INT -> 'int32_t'
// hwndParent : HWND optional -> 'void *'
// nID : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("AVICAP32.dll", {
capCreateCaptureWindowW: { parameters: ["buffer", "u32", "i32", "i32", "i32", "i32", "pointer", "i32"], result: "pointer" },
});
// lib.symbols.capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
// lpszWindowName : LPCWSTR -> "buffer"
// dwStyle : DWORD -> "u32"
// x : INT -> "i32"
// y : INT -> "i32"
// nWidth : INT -> "i32"
// nHeight : INT -> "i32"
// hwndParent : HWND optional -> "pointer"
// nID : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* capCreateCaptureWindowW(
const uint16_t* lpszWindowName,
uint32_t dwStyle,
int32_t x,
int32_t y,
int32_t nWidth,
int32_t nHeight,
void* hwndParent,
int32_t nID);
C, "AVICAP32.dll");
// $ffi->capCreateCaptureWindowW(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID);
// lpszWindowName : LPCWSTR
// dwStyle : DWORD
// x : INT
// y : INT
// nWidth : INT
// nHeight : INT
// hwndParent : HWND optional
// nID : INT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Avicap32 extends StdCallLibrary {
Avicap32 INSTANCE = Native.load("avicap32", Avicap32.class, W32APIOptions.UNICODE_OPTIONS);
Pointer capCreateCaptureWindowW(
WString lpszWindowName, // LPCWSTR
int dwStyle, // DWORD
int x, // INT
int y, // INT
int nWidth, // INT
int nHeight, // INT
Pointer hwndParent, // HWND optional
int nID // INT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("avicap32")]
lib LibAVICAP32
fun capCreateCaptureWindowW = capCreateCaptureWindowW(
lpszWindowName : UInt16*, # LPCWSTR
dwStyle : UInt32, # DWORD
x : Int32, # INT
y : Int32, # INT
nWidth : Int32, # INT
nHeight : Int32, # INT
hwndParent : Void*, # HWND optional
nID : Int32 # INT
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef capCreateCaptureWindowWNative = Pointer<Void> Function(Pointer<Utf16>, Uint32, Int32, Int32, Int32, Int32, Pointer<Void>, Int32);
typedef capCreateCaptureWindowWDart = Pointer<Void> Function(Pointer<Utf16>, int, int, int, int, int, Pointer<Void>, int);
final capCreateCaptureWindowW = DynamicLibrary.open('AVICAP32.dll')
.lookupFunction<capCreateCaptureWindowWNative, capCreateCaptureWindowWDart>('capCreateCaptureWindowW');
// lpszWindowName : LPCWSTR -> Pointer<Utf16>
// dwStyle : DWORD -> Uint32
// x : INT -> Int32
// y : INT -> Int32
// nWidth : INT -> Int32
// nHeight : INT -> Int32
// hwndParent : HWND optional -> Pointer<Void>
// nID : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function capCreateCaptureWindowW(
lpszWindowName: PWideChar; // LPCWSTR
dwStyle: DWORD; // DWORD
x: Integer; // INT
y: Integer; // INT
nWidth: Integer; // INT
nHeight: Integer; // INT
hwndParent: THandle; // HWND optional
nID: Integer // INT
): THandle; stdcall;
external 'AVICAP32.dll' name 'capCreateCaptureWindowW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "capCreateCaptureWindowW"
c_capCreateCaptureWindowW :: CWString -> Word32 -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> Int32 -> IO (Ptr ())
-- lpszWindowName : LPCWSTR -> CWString
-- dwStyle : DWORD -> Word32
-- x : INT -> Int32
-- y : INT -> Int32
-- nWidth : INT -> Int32
-- nHeight : INT -> Int32
-- hwndParent : HWND optional -> Ptr ()
-- nID : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let capcreatecapturewindoww =
foreign "capCreateCaptureWindowW"
((ptr uint16_t) @-> uint32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> returning (ptr void))
(* lpszWindowName : LPCWSTR -> (ptr uint16_t) *)
(* dwStyle : DWORD -> uint32_t *)
(* x : INT -> int32_t *)
(* y : INT -> int32_t *)
(* nWidth : INT -> int32_t *)
(* nHeight : INT -> int32_t *)
(* hwndParent : HWND optional -> (ptr void) *)
(* nID : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library avicap32 (t "AVICAP32.dll"))
(cffi:use-foreign-library avicap32)
(cffi:defcfun ("capCreateCaptureWindowW" cap-create-capture-window-w :convention :stdcall) :pointer
(lpsz-window-name (:string :encoding :utf-16le)) ; LPCWSTR
(dw-style :uint32) ; DWORD
(x :int32) ; INT
(y :int32) ; INT
(n-width :int32) ; INT
(n-height :int32) ; INT
(hwnd-parent :pointer) ; HWND optional
(n-id :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $capCreateCaptureWindowW = Win32::API::More->new('AVICAP32',
'HANDLE capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HANDLE hwndParent, int nID)');
# my $ret = $capCreateCaptureWindowW->Call($lpszWindowName, $dwStyle, $x, $y, $nWidth, $nHeight, $hwndParent, $nID);
# lpszWindowName : LPCWSTR -> LPCWSTR
# dwStyle : DWORD -> DWORD
# x : INT -> int
# y : INT -> int
# nWidth : INT -> int
# nHeight : INT -> int
# hwndParent : HWND optional -> HANDLE
# nID : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f capCreateCaptureWindowA (ANSI版) — ビデオキャプチャ用ウィンドウを作成する(ANSI版)。