ホーム › Media.Multimedia › capGetDriverDescriptionA
capGetDriverDescriptionA
関数指定インデックスのキャプチャドライバの説明とバージョンを取得する(ANSI版)。
シグネチャ
// AVICAP32.dll (ANSI / -A)
#include <windows.h>
BOOL capGetDriverDescriptionA(
DWORD wDriverIndex,
LPSTR lpszName,
INT cbName,
LPSTR lpszVer,
INT cbVer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| wDriverIndex | DWORD | in | キャプチャドライバーのインデックス。インデックスは 0 から 9 の範囲で指定できます。 プラグアンドプレイのキャプチャドライバーが最初に列挙され、続いてレジストリに登録されているキャプチャドライバー、その後に SYSTEM.INI に記載されているキャプチャドライバーが列挙されます。 |
| lpszName | LPSTR | out | キャプチャドライバー名に対応する、null で終わる文字列を格納するバッファーへのポインター。 |
| cbName | INT | in | lpszName が指すバッファーの長さ(バイト単位)。 |
| lpszVer | LPSTR | out | キャプチャドライバーの説明に対応する、null で終わる文字列を格納するバッファーへのポインター。 |
| cbVer | INT | in | lpszVer が指すバッファーの長さ(バイト単位)。 |
戻り値の型: BOOL
公式ドキュメント
capGetDriverDescription 関数は、キャプチャドライバーのバージョン情報を取得します。(ANSI)
戻り値
成功した場合は 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)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// AVICAP32.dll (ANSI / -A)
#include <windows.h>
BOOL capGetDriverDescriptionA(
DWORD wDriverIndex,
LPSTR lpszName,
INT cbName,
LPSTR lpszVer,
INT cbVer
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("AVICAP32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool capGetDriverDescriptionA(
uint wDriverIndex, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszName, // LPSTR out
int cbName, // INT
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszVer, // LPSTR out
int cbVer // INT
);<DllImport("AVICAP32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function capGetDriverDescriptionA(
wDriverIndex As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> lpszName As System.Text.StringBuilder, ' LPSTR out
cbName As Integer, ' INT
<MarshalAs(UnmanagedType.LPStr)> lpszVer As System.Text.StringBuilder, ' LPSTR out
cbVer As Integer ' INT
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' wDriverIndex : DWORD
' lpszName : LPSTR out
' cbName : INT
' lpszVer : LPSTR out
' cbVer : INT
Declare PtrSafe Function capGetDriverDescriptionA Lib "avicap32" ( _
ByVal wDriverIndex As Long, _
ByVal lpszName As String, _
ByVal cbName As Long, _
ByVal lpszVer As String, _
ByVal cbVer As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
capGetDriverDescriptionA = ctypes.windll.avicap32.capGetDriverDescriptionA
capGetDriverDescriptionA.restype = wintypes.BOOL
capGetDriverDescriptionA.argtypes = [
wintypes.DWORD, # wDriverIndex : DWORD
wintypes.LPSTR, # lpszName : LPSTR out
ctypes.c_int, # cbName : INT
wintypes.LPSTR, # lpszVer : LPSTR out
ctypes.c_int, # cbVer : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('AVICAP32.dll')
capGetDriverDescriptionA = Fiddle::Function.new(
lib['capGetDriverDescriptionA'],
[
-Fiddle::TYPE_INT, # wDriverIndex : DWORD
Fiddle::TYPE_VOIDP, # lpszName : LPSTR out
Fiddle::TYPE_INT, # cbName : INT
Fiddle::TYPE_VOIDP, # lpszVer : LPSTR out
Fiddle::TYPE_INT, # cbVer : INT
],
Fiddle::TYPE_INT)#[link(name = "avicap32")]
extern "system" {
fn capGetDriverDescriptionA(
wDriverIndex: u32, // DWORD
lpszName: *mut u8, // LPSTR out
cbName: i32, // INT
lpszVer: *mut u8, // LPSTR 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.Ansi)]
public static extern bool capGetDriverDescriptionA(uint wDriverIndex, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszName, int cbName, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszVer, int cbVer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVICAP32_capGetDriverDescriptionA' -Namespace Win32 -PassThru
# $api::capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer)#uselib "AVICAP32.dll"
#func global capGetDriverDescriptionA "capGetDriverDescriptionA" sptr, sptr, sptr, sptr, sptr
; capGetDriverDescriptionA wDriverIndex, varptr(lpszName), cbName, varptr(lpszVer), cbVer ; 戻り値は stat
; wDriverIndex : DWORD -> "sptr"
; lpszName : LPSTR out -> "sptr"
; cbName : INT -> "sptr"
; lpszVer : LPSTR out -> "sptr"
; cbVer : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "AVICAP32.dll" #cfunc global capGetDriverDescriptionA "capGetDriverDescriptionA" int, var, int, var, int ; res = capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer) ; wDriverIndex : DWORD -> "int" ; lpszName : LPSTR out -> "var" ; cbName : INT -> "int" ; lpszVer : LPSTR out -> "var" ; cbVer : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "AVICAP32.dll" #cfunc global capGetDriverDescriptionA "capGetDriverDescriptionA" int, sptr, int, sptr, int ; res = capGetDriverDescriptionA(wDriverIndex, varptr(lpszName), cbName, varptr(lpszVer), cbVer) ; wDriverIndex : DWORD -> "int" ; lpszName : LPSTR out -> "sptr" ; cbName : INT -> "int" ; lpszVer : LPSTR out -> "sptr" ; cbVer : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL capGetDriverDescriptionA(DWORD wDriverIndex, LPSTR lpszName, INT cbName, LPSTR lpszVer, INT cbVer) #uselib "AVICAP32.dll" #cfunc global capGetDriverDescriptionA "capGetDriverDescriptionA" int, var, int, var, int ; res = capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer) ; wDriverIndex : DWORD -> "int" ; lpszName : LPSTR out -> "var" ; cbName : INT -> "int" ; lpszVer : LPSTR out -> "var" ; cbVer : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL capGetDriverDescriptionA(DWORD wDriverIndex, LPSTR lpszName, INT cbName, LPSTR lpszVer, INT cbVer) #uselib "AVICAP32.dll" #cfunc global capGetDriverDescriptionA "capGetDriverDescriptionA" int, intptr, int, intptr, int ; res = capGetDriverDescriptionA(wDriverIndex, varptr(lpszName), cbName, varptr(lpszVer), cbVer) ; wDriverIndex : DWORD -> "int" ; lpszName : LPSTR out -> "intptr" ; cbName : INT -> "int" ; lpszVer : LPSTR out -> "intptr" ; cbVer : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
avicap32 = windows.NewLazySystemDLL("AVICAP32.dll")
proccapGetDriverDescriptionA = avicap32.NewProc("capGetDriverDescriptionA")
)
// wDriverIndex (DWORD), lpszName (LPSTR out), cbName (INT), lpszVer (LPSTR out), cbVer (INT)
r1, _, err := proccapGetDriverDescriptionA.Call(
uintptr(wDriverIndex),
uintptr(lpszName),
uintptr(cbName),
uintptr(lpszVer),
uintptr(cbVer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction capGetDriverDescriptionA(
wDriverIndex: DWORD; // DWORD
lpszName: PAnsiChar; // LPSTR out
cbName: Integer; // INT
lpszVer: PAnsiChar; // LPSTR out
cbVer: Integer // INT
): BOOL; stdcall;
external 'AVICAP32.dll' name 'capGetDriverDescriptionA';result := DllCall("AVICAP32\capGetDriverDescriptionA"
, "UInt", wDriverIndex ; DWORD
, "Ptr", lpszName ; LPSTR out
, "Int", cbName ; INT
, "Ptr", lpszVer ; LPSTR out
, "Int", cbVer ; INT
, "Int") ; return: BOOL●capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer) = DLL("AVICAP32.dll", "bool capGetDriverDescriptionA(dword, char*, int, char*, int)")
# 呼び出し: capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
# wDriverIndex : DWORD -> "dword"
# lpszName : LPSTR out -> "char*"
# cbName : INT -> "int"
# lpszVer : LPSTR out -> "char*"
# cbVer : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "avicap32" fn capGetDriverDescriptionA(
wDriverIndex: u32, // DWORD
lpszName: [*c]u8, // LPSTR out
cbName: i32, // INT
lpszVer: [*c]u8, // LPSTR out
cbVer: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc capGetDriverDescriptionA(
wDriverIndex: uint32, # DWORD
lpszName: ptr char, # LPSTR out
cbName: int32, # INT
lpszVer: ptr char, # LPSTR out
cbVer: int32 # INT
): int32 {.importc: "capGetDriverDescriptionA", stdcall, dynlib: "AVICAP32.dll".}pragma(lib, "avicap32");
extern(Windows)
int capGetDriverDescriptionA(
uint wDriverIndex, // DWORD
char* lpszName, // LPSTR out
int cbName, // INT
char* lpszVer, // LPSTR out
int cbVer // INT
);ccall((:capGetDriverDescriptionA, "AVICAP32.dll"), stdcall, Int32,
(UInt32, Ptr{UInt8}, Int32, Ptr{UInt8}, Int32),
wDriverIndex, lpszName, cbName, lpszVer, cbVer)
# wDriverIndex : DWORD -> UInt32
# lpszName : LPSTR out -> Ptr{UInt8}
# cbName : INT -> Int32
# lpszVer : LPSTR out -> Ptr{UInt8}
# cbVer : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t capGetDriverDescriptionA(
uint32_t wDriverIndex,
char* lpszName,
int32_t cbName,
char* lpszVer,
int32_t cbVer);
]]
local avicap32 = ffi.load("avicap32")
-- avicap32.capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
-- wDriverIndex : DWORD
-- lpszName : LPSTR out
-- cbName : INT
-- lpszVer : LPSTR out
-- cbVer : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('AVICAP32.dll');
const capGetDriverDescriptionA = lib.func('__stdcall', 'capGetDriverDescriptionA', 'int32_t', ['uint32_t', 'char *', 'int32_t', 'char *', 'int32_t']);
// capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
// wDriverIndex : DWORD -> 'uint32_t'
// lpszName : LPSTR out -> 'char *'
// cbName : INT -> 'int32_t'
// lpszVer : LPSTR out -> 'char *'
// cbVer : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("AVICAP32.dll", {
capGetDriverDescriptionA: { parameters: ["u32", "buffer", "i32", "buffer", "i32"], result: "i32" },
});
// lib.symbols.capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer)
// wDriverIndex : DWORD -> "u32"
// lpszName : LPSTR out -> "buffer"
// cbName : INT -> "i32"
// lpszVer : LPSTR out -> "buffer"
// cbVer : INT -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t capGetDriverDescriptionA(
uint32_t wDriverIndex,
char* lpszName,
int32_t cbName,
char* lpszVer,
int32_t cbVer);
C, "AVICAP32.dll");
// $ffi->capGetDriverDescriptionA(wDriverIndex, lpszName, cbName, lpszVer, cbVer);
// wDriverIndex : DWORD
// lpszName : LPSTR out
// cbName : INT
// lpszVer : LPSTR 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.ASCII_OPTIONS);
boolean capGetDriverDescriptionA(
int wDriverIndex, // DWORD
byte[] lpszName, // LPSTR out
int cbName, // INT
byte[] lpszVer, // LPSTR out
int cbVer // INT
);
}@[Link("avicap32")]
lib LibAVICAP32
fun capGetDriverDescriptionA = capGetDriverDescriptionA(
wDriverIndex : UInt32, # DWORD
lpszName : UInt8*, # LPSTR out
cbName : Int32, # INT
lpszVer : UInt8*, # LPSTR 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 capGetDriverDescriptionANative = Int32 Function(Uint32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
typedef capGetDriverDescriptionADart = int Function(int, Pointer<Utf8>, int, Pointer<Utf8>, int);
final capGetDriverDescriptionA = DynamicLibrary.open('AVICAP32.dll')
.lookupFunction<capGetDriverDescriptionANative, capGetDriverDescriptionADart>('capGetDriverDescriptionA');
// wDriverIndex : DWORD -> Uint32
// lpszName : LPSTR out -> Pointer<Utf8>
// cbName : INT -> Int32
// lpszVer : LPSTR out -> Pointer<Utf8>
// cbVer : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function capGetDriverDescriptionA(
wDriverIndex: DWORD; // DWORD
lpszName: PAnsiChar; // LPSTR out
cbName: Integer; // INT
lpszVer: PAnsiChar; // LPSTR out
cbVer: Integer // INT
): BOOL; stdcall;
external 'AVICAP32.dll' name 'capGetDriverDescriptionA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "capGetDriverDescriptionA"
c_capGetDriverDescriptionA :: Word32 -> CString -> Int32 -> CString -> Int32 -> IO CInt
-- wDriverIndex : DWORD -> Word32
-- lpszName : LPSTR out -> CString
-- cbName : INT -> Int32
-- lpszVer : LPSTR out -> CString
-- cbVer : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let capgetdriverdescriptiona =
foreign "capGetDriverDescriptionA"
(uint32_t @-> string @-> int32_t @-> string @-> int32_t @-> returning int32_t)
(* wDriverIndex : DWORD -> uint32_t *)
(* lpszName : LPSTR out -> string *)
(* cbName : INT -> int32_t *)
(* lpszVer : LPSTR out -> string *)
(* 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 ("capGetDriverDescriptionA" cap-get-driver-description-a :convention :stdcall) :int32
(w-driver-index :uint32) ; DWORD
(lpsz-name :pointer) ; LPSTR out
(cb-name :int32) ; INT
(lpsz-ver :pointer) ; LPSTR out
(cb-ver :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $capGetDriverDescriptionA = Win32::API::More->new('AVICAP32',
'BOOL capGetDriverDescriptionA(DWORD wDriverIndex, LPSTR lpszName, int cbName, LPSTR lpszVer, int cbVer)');
# my $ret = $capGetDriverDescriptionA->Call($wDriverIndex, $lpszName, $cbName, $lpszVer, $cbVer);
# wDriverIndex : DWORD -> DWORD
# lpszName : LPSTR out -> LPSTR
# cbName : INT -> int
# lpszVer : LPSTR out -> LPSTR
# cbVer : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f capGetDriverDescriptionW (Unicode版) — 指定インデックスのキャプチャドライバの説明とバージョンを取得する(Unicode版)。