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

capCreateCaptureWindowW

関数
ビデオキャプチャ用ウィンドウを作成する(Unicode版)。
DLLAVICAP32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// 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
);

パラメーター

名前方向
lpszWindowNameLPCWSTRin
dwStyleDWORDin
xINTin
yINTin
nWidthINTin
nHeightINTin
hwndParentHWNDinoptional
nIDINTin

戻り値の型: HWND

各言語での呼び出し定義

// 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   // HWND
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';
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 版の利用を推奨。