ホーム › Media.Multimedia › capCreateCaptureWindowA
capCreateCaptureWindowA
関数ビデオキャプチャ用ウィンドウを作成する(ANSI版)。
シグネチャ
// AVICAP32.dll (ANSI / -A)
#include <windows.h>
HWND capCreateCaptureWindowA(
LPCSTR lpszWindowName,
DWORD dwStyle,
INT x,
INT y,
INT nWidth,
INT nHeight,
HWND hwndParent, // optional
INT nID
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpszWindowName | LPCSTR | 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 関数はキャプチャウィンドウを作成します。(ANSI)
戻り値
成功した場合はキャプチャウィンドウのハンドルを返し、それ以外の場合は 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 (ANSI / -A)
#include <windows.h>
HWND capCreateCaptureWindowA(
LPCSTR lpszWindowName,
DWORD dwStyle,
INT x,
INT y,
INT nWidth,
INT nHeight,
HWND hwndParent, // optional
INT nID
);[DllImport("AVICAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr capCreateCaptureWindowA(
[MarshalAs(UnmanagedType.LPStr)] string lpszWindowName, // LPCSTR
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.Ansi, ExactSpelling:=True)>
Public Shared Function capCreateCaptureWindowA(
<MarshalAs(UnmanagedType.LPStr)> lpszWindowName As String, ' LPCSTR
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 : LPCSTR
' dwStyle : DWORD
' x : INT
' y : INT
' nWidth : INT
' nHeight : INT
' hwndParent : HWND optional
' nID : INT
Declare PtrSafe Function capCreateCaptureWindowA Lib "avicap32" ( _
ByVal lpszWindowName As String, _
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
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
capCreateCaptureWindowA = ctypes.windll.avicap32.capCreateCaptureWindowA
capCreateCaptureWindowA.restype = ctypes.c_void_p
capCreateCaptureWindowA.argtypes = [
wintypes.LPCSTR, # lpszWindowName : LPCSTR
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')
capCreateCaptureWindowA = Fiddle::Function.new(
lib['capCreateCaptureWindowA'],
[
Fiddle::TYPE_VOIDP, # lpszWindowName : LPCSTR
-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)#[link(name = "avicap32")]
extern "system" {
fn capCreateCaptureWindowA(
lpszWindowName: *const u8, // LPCSTR
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.Ansi)]
public static extern IntPtr capCreateCaptureWindowA([MarshalAs(UnmanagedType.LPStr)] string lpszWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hwndParent, int nID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVICAP32_capCreateCaptureWindowA' -Namespace Win32 -PassThru
# $api::capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)#uselib "AVICAP32.dll"
#func global capCreateCaptureWindowA "capCreateCaptureWindowA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; capCreateCaptureWindowA lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID ; 戻り値は stat
; lpszWindowName : LPCSTR -> "sptr"
; dwStyle : DWORD -> "sptr"
; x : INT -> "sptr"
; y : INT -> "sptr"
; nWidth : INT -> "sptr"
; nHeight : INT -> "sptr"
; hwndParent : HWND optional -> "sptr"
; nID : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "AVICAP32.dll"
#cfunc global capCreateCaptureWindowA "capCreateCaptureWindowA" str, int, int, int, int, int, sptr, int
; res = capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
; lpszWindowName : LPCSTR -> "str"
; dwStyle : DWORD -> "int"
; x : INT -> "int"
; y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hwndParent : HWND optional -> "sptr"
; nID : INT -> "int"; HWND capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, INT x, INT y, INT nWidth, INT nHeight, HWND hwndParent, INT nID)
#uselib "AVICAP32.dll"
#cfunc global capCreateCaptureWindowA "capCreateCaptureWindowA" str, int, int, int, int, int, intptr, int
; res = capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
; lpszWindowName : LPCSTR -> "str"
; 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")
proccapCreateCaptureWindowA = avicap32.NewProc("capCreateCaptureWindowA")
)
// lpszWindowName (LPCSTR), dwStyle (DWORD), x (INT), y (INT), nWidth (INT), nHeight (INT), hwndParent (HWND optional), nID (INT)
r1, _, err := proccapCreateCaptureWindowA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(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 capCreateCaptureWindowA(
lpszWindowName: PAnsiChar; // LPCSTR
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 'capCreateCaptureWindowA';result := DllCall("AVICAP32\capCreateCaptureWindowA"
, "AStr", lpszWindowName ; LPCSTR
, "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●capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID) = DLL("AVICAP32.dll", "void* capCreateCaptureWindowA(char*, dword, int, int, int, int, void*, int)")
# 呼び出し: capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
# lpszWindowName : LPCSTR -> "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)。const std = @import("std");
extern "avicap32" fn capCreateCaptureWindowA(
lpszWindowName: [*c]const u8, // LPCSTR
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;proc capCreateCaptureWindowA(
lpszWindowName: cstring, # LPCSTR
dwStyle: uint32, # DWORD
x: int32, # INT
y: int32, # INT
nWidth: int32, # INT
nHeight: int32, # INT
hwndParent: pointer, # HWND optional
nID: int32 # INT
): pointer {.importc: "capCreateCaptureWindowA", stdcall, dynlib: "AVICAP32.dll".}pragma(lib, "avicap32");
extern(Windows)
void* capCreateCaptureWindowA(
const(char)* lpszWindowName, // LPCSTR
uint dwStyle, // DWORD
int x, // INT
int y, // INT
int nWidth, // INT
int nHeight, // INT
void* hwndParent, // HWND optional
int nID // INT
);ccall((:capCreateCaptureWindowA, "AVICAP32.dll"), stdcall, Ptr{Cvoid},
(Cstring, UInt32, Int32, Int32, Int32, Int32, Ptr{Cvoid}, Int32),
lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
# lpszWindowName : LPCSTR -> Cstring
# 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 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* capCreateCaptureWindowA(
const char* 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.capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
-- lpszWindowName : LPCSTR
-- dwStyle : DWORD
-- x : INT
-- y : INT
-- nWidth : INT
-- nHeight : INT
-- hwndParent : HWND optional
-- nID : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('AVICAP32.dll');
const capCreateCaptureWindowA = lib.func('__stdcall', 'capCreateCaptureWindowA', 'void *', ['str', 'uint32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'int32_t']);
// capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
// lpszWindowName : LPCSTR -> 'str'
// 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", {
capCreateCaptureWindowA: { parameters: ["buffer", "u32", "i32", "i32", "i32", "i32", "pointer", "i32"], result: "pointer" },
});
// lib.symbols.capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID)
// lpszWindowName : LPCSTR -> "buffer"
// dwStyle : DWORD -> "u32"
// x : INT -> "i32"
// y : INT -> "i32"
// nWidth : INT -> "i32"
// nHeight : INT -> "i32"
// hwndParent : HWND optional -> "pointer"
// nID : INT -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* capCreateCaptureWindowA(
const char* 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->capCreateCaptureWindowA(lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, nID);
// lpszWindowName : LPCSTR
// 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.ASCII_OPTIONS);
Pointer capCreateCaptureWindowA(
String lpszWindowName, // LPCSTR
int dwStyle, // DWORD
int x, // INT
int y, // INT
int nWidth, // INT
int nHeight, // INT
Pointer hwndParent, // HWND optional
int nID // INT
);
}@[Link("avicap32")]
lib LibAVICAP32
fun capCreateCaptureWindowA = capCreateCaptureWindowA(
lpszWindowName : UInt8*, # LPCSTR
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 capCreateCaptureWindowANative = Pointer<Void> Function(Pointer<Utf8>, Uint32, Int32, Int32, Int32, Int32, Pointer<Void>, Int32);
typedef capCreateCaptureWindowADart = Pointer<Void> Function(Pointer<Utf8>, int, int, int, int, int, Pointer<Void>, int);
final capCreateCaptureWindowA = DynamicLibrary.open('AVICAP32.dll')
.lookupFunction<capCreateCaptureWindowANative, capCreateCaptureWindowADart>('capCreateCaptureWindowA');
// lpszWindowName : LPCSTR -> Pointer<Utf8>
// 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 capCreateCaptureWindowA(
lpszWindowName: PAnsiChar; // LPCSTR
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 'capCreateCaptureWindowA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "capCreateCaptureWindowA"
c_capCreateCaptureWindowA :: CString -> Word32 -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> Int32 -> IO (Ptr ())
-- lpszWindowName : LPCSTR -> CString
-- 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 capcreatecapturewindowa =
foreign "capCreateCaptureWindowA"
(string @-> uint32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> returning (ptr void))
(* lpszWindowName : LPCSTR -> string *)
(* 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 ("capCreateCaptureWindowA" cap-create-capture-window-a :convention :stdcall) :pointer
(lpsz-window-name :string) ; LPCSTR
(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 $capCreateCaptureWindowA = Win32::API::More->new('AVICAP32',
'HANDLE capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HANDLE hwndParent, int nID)');
# my $ret = $capCreateCaptureWindowA->Call($lpszWindowName, $dwStyle, $x, $y, $nWidth, $nHeight, $hwndParent, $nID);
# lpszWindowName : LPCSTR -> LPCSTR
# 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 を使用。関連項目
文字セット違い
- f capCreateCaptureWindowW (Unicode版) — ビデオキャプチャ用ウィンドウを作成する(Unicode版)。