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

capGetDriverDescriptionW

関数
指定インデックスのキャプチャドライバの説明とバージョンを取得する(Unicode版)。
DLLAVICAP32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL capGetDriverDescriptionW(
    DWORD wDriverIndex,
    LPWSTR lpszName,
    INT cbName,
    LPWSTR lpszVer,
    INT cbVer
);

パラメーター

名前方向説明
wDriverIndexDWORDin

キャプチャドライバーのインデックス。インデックスは 0 から 9 までの範囲で指定できます。

プラグアンドプレイのキャプチャドライバーが最初に列挙され、続いてレジストリに登録されたキャプチャドライバー、最後に SYSTEM.INI に記載されたキャプチャドライバーが列挙されます。

lpszNameLPWSTRoutキャプチャドライバー名に対応する null 終端文字列を格納するバッファーへのポインター。
cbNameINTinlpszName が指すバッファーの長さ(バイト単位)。
lpszVerLPWSTRoutキャプチャドライバーの説明に対応する null 終端文字列を格納するバッファーへのポインター。
cbVerINTinlpszVer が指すバッファーの長さ(バイト単位)。

戻り値の型: BOOL

公式ドキュメント

capGetDriverDescription 関数は、キャプチャドライバーのバージョン情報を取得します。(Unicode)

戻り値

成功した場合は TRUE を、それ以外の場合は FALSE を返します。

解説(Remarks)

情報の説明がバッファーよりも長い場合、説明は切り詰められます。返される文字列は常に null 終端されています。バッファーサイズが 0 の場合、対応する説明はコピーされません。

メモ

vfw.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして capGetDriverDescription を定義しています。エンコーディング中立のエイリアスを、エンコーディング中立でないコードと混在させて使用すると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL capGetDriverDescriptionW(
    DWORD wDriverIndex,
    LPWSTR lpszName,
    INT cbName,
    LPWSTR lpszVer,
    INT cbVer
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("AVICAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool capGetDriverDescriptionW(
    uint wDriverIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszName,   // LPWSTR out
    int cbName,   // INT
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszVer,   // LPWSTR out
    int cbVer   // INT
);
<DllImport("AVICAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function capGetDriverDescriptionW(
    wDriverIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpszName As System.Text.StringBuilder,   ' LPWSTR out
    cbName As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPWStr)> lpszVer As System.Text.StringBuilder,   ' LPWSTR out
    cbVer As Integer   ' INT
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' wDriverIndex : DWORD
' lpszName : LPWSTR out
' cbName : INT
' lpszVer : LPWSTR out
' cbVer : INT
Declare PtrSafe Function capGetDriverDescriptionW Lib "avicap32" ( _
    ByVal wDriverIndex As Long, _
    ByVal lpszName As LongPtr, _
    ByVal cbName As Long, _
    ByVal lpszVer As LongPtr, _
    ByVal cbVer As Long) 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

capGetDriverDescriptionW = ctypes.windll.avicap32.capGetDriverDescriptionW
capGetDriverDescriptionW.restype = wintypes.BOOL
capGetDriverDescriptionW.argtypes = [
    wintypes.DWORD,  # wDriverIndex : DWORD
    wintypes.LPWSTR,  # lpszName : LPWSTR out
    ctypes.c_int,  # cbName : INT
    wintypes.LPWSTR,  # lpszVer : LPWSTR out
    ctypes.c_int,  # cbVer : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('AVICAP32.dll')
capGetDriverDescriptionW = Fiddle::Function.new(
  lib['capGetDriverDescriptionW'],
  [
    -Fiddle::TYPE_INT,  # wDriverIndex : DWORD
    Fiddle::TYPE_VOIDP,  # lpszName : LPWSTR out
    Fiddle::TYPE_INT,  # cbName : INT
    Fiddle::TYPE_VOIDP,  # lpszVer : LPWSTR out
    Fiddle::TYPE_INT,  # cbVer : INT
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "avicap32")]
extern "system" {
    fn capGetDriverDescriptionW(
        wDriverIndex: u32,  // DWORD
        lpszName: *mut u16,  // LPWSTR out
        cbName: i32,  // INT
        lpszVer: *mut u16,  // LPWSTR out
        cbVer: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("AVICAP32.dll", CharSet = CharSet.Unicode)]
public static extern bool capGetDriverDescriptionW(uint wDriverIndex, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszName, int cbName, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszVer, int cbVer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVICAP32_capGetDriverDescriptionW' -Namespace Win32 -PassThru
# $api::capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
#uselib "AVICAP32.dll"
#func global capGetDriverDescriptionW "capGetDriverDescriptionW" wptr, wptr, wptr, wptr, wptr
; capGetDriverDescriptionW wDriverIndex, varptr(lpszName), cbName, varptr(lpszVer), cbVer   ; 戻り値は stat
; wDriverIndex : DWORD -> "wptr"
; lpszName : LPWSTR out -> "wptr"
; cbName : INT -> "wptr"
; lpszVer : LPWSTR out -> "wptr"
; cbVer : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "AVICAP32.dll"
#cfunc global capGetDriverDescriptionW "capGetDriverDescriptionW" int, var, int, var, int
; res = capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
; wDriverIndex : DWORD -> "int"
; lpszName : LPWSTR out -> "var"
; cbName : INT -> "int"
; lpszVer : LPWSTR out -> "var"
; cbVer : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL capGetDriverDescriptionW(DWORD wDriverIndex, LPWSTR lpszName, INT cbName, LPWSTR lpszVer, INT cbVer)
#uselib "AVICAP32.dll"
#cfunc global capGetDriverDescriptionW "capGetDriverDescriptionW" int, var, int, var, int
; res = capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
; wDriverIndex : DWORD -> "int"
; lpszName : LPWSTR out -> "var"
; cbName : INT -> "int"
; lpszVer : LPWSTR out -> "var"
; cbVer : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	avicap32 = windows.NewLazySystemDLL("AVICAP32.dll")
	proccapGetDriverDescriptionW = avicap32.NewProc("capGetDriverDescriptionW")
)

// wDriverIndex (DWORD), lpszName (LPWSTR out), cbName (INT), lpszVer (LPWSTR out), cbVer (INT)
r1, _, err := proccapGetDriverDescriptionW.Call(
	uintptr(wDriverIndex),
	uintptr(lpszName),
	uintptr(cbName),
	uintptr(lpszVer),
	uintptr(cbVer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function capGetDriverDescriptionW(
  wDriverIndex: DWORD;   // DWORD
  lpszName: PWideChar;   // LPWSTR out
  cbName: Integer;   // INT
  lpszVer: PWideChar;   // LPWSTR out
  cbVer: Integer   // INT
): BOOL; stdcall;
  external 'AVICAP32.dll' name 'capGetDriverDescriptionW';
result := DllCall("AVICAP32\capGetDriverDescriptionW"
    , "UInt", wDriverIndex   ; DWORD
    , "Ptr", lpszName   ; LPWSTR out
    , "Int", cbName   ; INT
    , "Ptr", lpszVer   ; LPWSTR out
    , "Int", cbVer   ; INT
    , "Int")   ; return: BOOL
●capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer) = DLL("AVICAP32.dll", "bool capGetDriverDescriptionW(dword, char*, int, char*, int)")
# 呼び出し: capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
# wDriverIndex : DWORD -> "dword"
# lpszName : LPWSTR out -> "char*"
# cbName : INT -> "int"
# lpszVer : LPWSTR out -> "char*"
# cbVer : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "avicap32" fn capGetDriverDescriptionW(
    wDriverIndex: u32, // DWORD
    lpszName: [*c]u16, // LPWSTR out
    cbName: i32, // INT
    lpszVer: [*c]u16, // LPWSTR out
    cbVer: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc capGetDriverDescriptionW(
    wDriverIndex: uint32,  # DWORD
    lpszName: ptr uint16,  # LPWSTR out
    cbName: int32,  # INT
    lpszVer: ptr uint16,  # LPWSTR out
    cbVer: int32  # INT
): int32 {.importc: "capGetDriverDescriptionW", stdcall, dynlib: "AVICAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "avicap32");
extern(Windows)
int capGetDriverDescriptionW(
    uint wDriverIndex,   // DWORD
    wchar* lpszName,   // LPWSTR out
    int cbName,   // INT
    wchar* lpszVer,   // LPWSTR out
    int cbVer   // INT
);
ccall((:capGetDriverDescriptionW, "AVICAP32.dll"), stdcall, Int32,
      (UInt32, Ptr{UInt16}, Int32, Ptr{UInt16}, Int32),
      wDriverIndex, lpszName, cbName, lpszVer, cbVer)
# wDriverIndex : DWORD -> UInt32
# lpszName : LPWSTR out -> Ptr{UInt16}
# cbName : INT -> Int32
# lpszVer : LPWSTR out -> Ptr{UInt16}
# cbVer : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t capGetDriverDescriptionW(
    uint32_t wDriverIndex,
    uint16_t* lpszName,
    int32_t cbName,
    uint16_t* lpszVer,
    int32_t cbVer);
]]
local avicap32 = ffi.load("avicap32")
-- avicap32.capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
-- wDriverIndex : DWORD
-- lpszName : LPWSTR out
-- cbName : INT
-- lpszVer : LPWSTR out
-- cbVer : 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 capGetDriverDescriptionW = lib.func('__stdcall', 'capGetDriverDescriptionW', 'int32_t', ['uint32_t', 'uint16_t *', 'int32_t', 'uint16_t *', 'int32_t']);
// capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
// wDriverIndex : DWORD -> 'uint32_t'
// lpszName : LPWSTR out -> 'uint16_t *'
// cbName : INT -> 'int32_t'
// lpszVer : LPWSTR out -> 'uint16_t *'
// cbVer : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("AVICAP32.dll", {
  capGetDriverDescriptionW: { parameters: ["u32", "buffer", "i32", "buffer", "i32"], result: "i32" },
});
// lib.symbols.capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
// wDriverIndex : DWORD -> "u32"
// lpszName : LPWSTR out -> "buffer"
// cbName : INT -> "i32"
// lpszVer : LPWSTR out -> "buffer"
// cbVer : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t capGetDriverDescriptionW(
    uint32_t wDriverIndex,
    uint16_t* lpszName,
    int32_t cbName,
    uint16_t* lpszVer,
    int32_t cbVer);
C, "AVICAP32.dll");
// $ffi->capGetDriverDescriptionW(wDriverIndex, lpszName, cbName, lpszVer, cbVer);
// wDriverIndex : DWORD
// lpszName : LPWSTR out
// cbName : INT
// lpszVer : LPWSTR out
// cbVer : 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);
    boolean capGetDriverDescriptionW(
        int wDriverIndex,   // DWORD
        char[] lpszName,   // LPWSTR out
        int cbName,   // INT
        char[] lpszVer,   // LPWSTR out
        int cbVer   // INT
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("avicap32")]
lib LibAVICAP32
  fun capGetDriverDescriptionW = capGetDriverDescriptionW(
    wDriverIndex : UInt32,   # DWORD
    lpszName : UInt16*,   # LPWSTR out
    cbName : Int32,   # INT
    lpszVer : UInt16*,   # LPWSTR out
    cbVer : Int32   # INT
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef capGetDriverDescriptionWNative = Int32 Function(Uint32, Pointer<Utf16>, Int32, Pointer<Utf16>, Int32);
typedef capGetDriverDescriptionWDart = int Function(int, Pointer<Utf16>, int, Pointer<Utf16>, int);
final capGetDriverDescriptionW = DynamicLibrary.open('AVICAP32.dll')
    .lookupFunction<capGetDriverDescriptionWNative, capGetDriverDescriptionWDart>('capGetDriverDescriptionW');
// wDriverIndex : DWORD -> Uint32
// lpszName : LPWSTR out -> Pointer<Utf16>
// cbName : INT -> Int32
// lpszVer : LPWSTR out -> Pointer<Utf16>
// cbVer : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function capGetDriverDescriptionW(
  wDriverIndex: DWORD;   // DWORD
  lpszName: PWideChar;   // LPWSTR out
  cbName: Integer;   // INT
  lpszVer: PWideChar;   // LPWSTR out
  cbVer: Integer   // INT
): BOOL; stdcall;
  external 'AVICAP32.dll' name 'capGetDriverDescriptionW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "capGetDriverDescriptionW"
  c_capGetDriverDescriptionW :: Word32 -> CWString -> Int32 -> CWString -> Int32 -> IO CInt
-- wDriverIndex : DWORD -> Word32
-- lpszName : LPWSTR out -> CWString
-- cbName : INT -> Int32
-- lpszVer : LPWSTR out -> CWString
-- cbVer : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let capgetdriverdescriptionw =
  foreign "capGetDriverDescriptionW"
    (uint32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* wDriverIndex : DWORD -> uint32_t *)
(* lpszName : LPWSTR out -> (ptr uint16_t) *)
(* cbName : INT -> int32_t *)
(* lpszVer : LPWSTR out -> (ptr uint16_t) *)
(* cbVer : 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 ("capGetDriverDescriptionW" cap-get-driver-description-w :convention :stdcall) :int32
  (w-driver-index :uint32)   ; DWORD
  (lpsz-name :pointer)   ; LPWSTR out
  (cb-name :int32)   ; INT
  (lpsz-ver :pointer)   ; LPWSTR out
  (cb-ver :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $capGetDriverDescriptionW = Win32::API::More->new('AVICAP32',
    'BOOL capGetDriverDescriptionW(DWORD wDriverIndex, LPWSTR lpszName, int cbName, LPWSTR lpszVer, int cbVer)');
# my $ret = $capGetDriverDescriptionW->Call($wDriverIndex, $lpszName, $cbName, $lpszVer, $cbVer);
# wDriverIndex : DWORD -> DWORD
# lpszName : LPWSTR out -> LPWSTR
# cbName : INT -> int
# lpszVer : LPWSTR out -> LPWSTR
# cbVer : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い