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

AVIStreamReadFormat

関数
AVIストリームのフォーマット情報を読み込む。
DLLAVIFIL32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// AVIFIL32.dll
#include <windows.h>

HRESULT AVIStreamReadFormat(
    IAVIStream* pavi,
    INT lPos,
    void* lpFormat,   // optional
    INT* lpcbFormat
);

パラメーター

名前方向説明
paviIAVIStream*inオープン済みストリームへのハンドル。
lPosINTinフォーマットデータを取得するために使用する、ストリーム内の位置。
lpFormatvoid*outoptionalフォーマットデータを格納するバッファーへのポインター。
lpcbFormatINT*inoutlpFormat が参照するメモリブロックのサイズを示す場所へのポインター。関数から戻る際、この値は読み取られたデータ量を示すように変更されます。lpFormatNULL の場合、このパラメーターを使用して、フォーマットを返すために必要なメモリ量を取得できます。

戻り値の型: HRESULT

公式ドキュメント

AVIStreamReadFormat 関数は、ストリームのフォーマットデータを読み取ります。

戻り値

成功した場合は 0 を返し、それ以外の場合はエラーを返します。

引数 pavi は、IAVIStream インターフェイスへのポインターです。

解説(Remarks)

標準的なビデオストリームハンドラーは、BITMAPINFOHEADER 構造体でフォーマット情報を提供します。標準的なオーディオストリームハンドラーは、PCMWAVEFORMAT 構造体でフォーマット情報を提供します。その他のデータストリームは、ストリームデータを記述する別の構造体を使用できます。

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

各言語での呼び出し定義

// AVIFIL32.dll
#include <windows.h>

HRESULT AVIStreamReadFormat(
    IAVIStream* pavi,
    INT lPos,
    void* lpFormat,   // optional
    INT* lpcbFormat
);
[DllImport("AVIFIL32.dll", ExactSpelling = true)]
static extern int AVIStreamReadFormat(
    IntPtr pavi,   // IAVIStream*
    int lPos,   // INT
    IntPtr lpFormat,   // void* optional, out
    ref int lpcbFormat   // INT* in/out
);
<DllImport("AVIFIL32.dll", ExactSpelling:=True)>
Public Shared Function AVIStreamReadFormat(
    pavi As IntPtr,   ' IAVIStream*
    lPos As Integer,   ' INT
    lpFormat As IntPtr,   ' void* optional, out
    ByRef lpcbFormat As Integer   ' INT* in/out
) As Integer
End Function
' pavi : IAVIStream*
' lPos : INT
' lpFormat : void* optional, out
' lpcbFormat : INT* in/out
Declare PtrSafe Function AVIStreamReadFormat Lib "avifil32" ( _
    ByVal pavi As LongPtr, _
    ByVal lPos As Long, _
    ByVal lpFormat As LongPtr, _
    ByRef lpcbFormat As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AVIStreamReadFormat = ctypes.windll.avifil32.AVIStreamReadFormat
AVIStreamReadFormat.restype = ctypes.c_int
AVIStreamReadFormat.argtypes = [
    ctypes.c_void_p,  # pavi : IAVIStream*
    ctypes.c_int,  # lPos : INT
    ctypes.POINTER(None),  # lpFormat : void* optional, out
    ctypes.POINTER(ctypes.c_int),  # lpcbFormat : INT* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('AVIFIL32.dll')
AVIStreamReadFormat = Fiddle::Function.new(
  lib['AVIStreamReadFormat'],
  [
    Fiddle::TYPE_VOIDP,  # pavi : IAVIStream*
    Fiddle::TYPE_INT,  # lPos : INT
    Fiddle::TYPE_VOIDP,  # lpFormat : void* optional, out
    Fiddle::TYPE_VOIDP,  # lpcbFormat : INT* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "avifil32")]
extern "system" {
    fn AVIStreamReadFormat(
        pavi: *mut core::ffi::c_void,  // IAVIStream*
        lPos: i32,  // INT
        lpFormat: *mut (),  // void* optional, out
        lpcbFormat: *mut i32  // INT* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("AVIFIL32.dll")]
public static extern int AVIStreamReadFormat(IntPtr pavi, int lPos, IntPtr lpFormat, ref int lpcbFormat);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVIFIL32_AVIStreamReadFormat' -Namespace Win32 -PassThru
# $api::AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
#uselib "AVIFIL32.dll"
#func global AVIStreamReadFormat "AVIStreamReadFormat" sptr, sptr, sptr, sptr
; AVIStreamReadFormat pavi, lPos, lpFormat, varptr(lpcbFormat)   ; 戻り値は stat
; pavi : IAVIStream* -> "sptr"
; lPos : INT -> "sptr"
; lpFormat : void* optional, out -> "sptr"
; lpcbFormat : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "AVIFIL32.dll"
#cfunc global AVIStreamReadFormat "AVIStreamReadFormat" sptr, int, sptr, var
; res = AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
; pavi : IAVIStream* -> "sptr"
; lPos : INT -> "int"
; lpFormat : void* optional, out -> "sptr"
; lpcbFormat : INT* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT AVIStreamReadFormat(IAVIStream* pavi, INT lPos, void* lpFormat, INT* lpcbFormat)
#uselib "AVIFIL32.dll"
#cfunc global AVIStreamReadFormat "AVIStreamReadFormat" intptr, int, intptr, var
; res = AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
; pavi : IAVIStream* -> "intptr"
; lPos : INT -> "int"
; lpFormat : void* optional, out -> "intptr"
; lpcbFormat : INT* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	avifil32 = windows.NewLazySystemDLL("AVIFIL32.dll")
	procAVIStreamReadFormat = avifil32.NewProc("AVIStreamReadFormat")
)

// pavi (IAVIStream*), lPos (INT), lpFormat (void* optional, out), lpcbFormat (INT* in/out)
r1, _, err := procAVIStreamReadFormat.Call(
	uintptr(pavi),
	uintptr(lPos),
	uintptr(lpFormat),
	uintptr(lpcbFormat),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function AVIStreamReadFormat(
  pavi: Pointer;   // IAVIStream*
  lPos: Integer;   // INT
  lpFormat: Pointer;   // void* optional, out
  lpcbFormat: Pointer   // INT* in/out
): Integer; stdcall;
  external 'AVIFIL32.dll' name 'AVIStreamReadFormat';
result := DllCall("AVIFIL32\AVIStreamReadFormat"
    , "Ptr", pavi   ; IAVIStream*
    , "Int", lPos   ; INT
    , "Ptr", lpFormat   ; void* optional, out
    , "Ptr", lpcbFormat   ; INT* in/out
    , "Int")   ; return: HRESULT
●AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat) = DLL("AVIFIL32.dll", "int AVIStreamReadFormat(void*, int, void*, void*)")
# 呼び出し: AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
# pavi : IAVIStream* -> "void*"
# lPos : INT -> "int"
# lpFormat : void* optional, out -> "void*"
# lpcbFormat : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "avifil32" fn AVIStreamReadFormat(
    pavi: ?*anyopaque, // IAVIStream*
    lPos: i32, // INT
    lpFormat: ?*anyopaque, // void* optional, out
    lpcbFormat: [*c]i32 // INT* in/out
) callconv(std.os.windows.WINAPI) i32;
proc AVIStreamReadFormat(
    pavi: pointer,  # IAVIStream*
    lPos: int32,  # INT
    lpFormat: pointer,  # void* optional, out
    lpcbFormat: ptr int32  # INT* in/out
): int32 {.importc: "AVIStreamReadFormat", stdcall, dynlib: "AVIFIL32.dll".}
pragma(lib, "avifil32");
extern(Windows)
int AVIStreamReadFormat(
    void* pavi,   // IAVIStream*
    int lPos,   // INT
    void* lpFormat,   // void* optional, out
    int* lpcbFormat   // INT* in/out
);
ccall((:AVIStreamReadFormat, "AVIFIL32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32, Ptr{Cvoid}, Ptr{Int32}),
      pavi, lPos, lpFormat, lpcbFormat)
# pavi : IAVIStream* -> Ptr{Cvoid}
# lPos : INT -> Int32
# lpFormat : void* optional, out -> Ptr{Cvoid}
# lpcbFormat : INT* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t AVIStreamReadFormat(
    void* pavi,
    int32_t lPos,
    void* lpFormat,
    int32_t* lpcbFormat);
]]
local avifil32 = ffi.load("avifil32")
-- avifil32.AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
-- pavi : IAVIStream*
-- lPos : INT
-- lpFormat : void* optional, out
-- lpcbFormat : INT* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('AVIFIL32.dll');
const AVIStreamReadFormat = lib.func('__stdcall', 'AVIStreamReadFormat', 'int32_t', ['void *', 'int32_t', 'void *', 'int32_t *']);
// AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
// pavi : IAVIStream* -> 'void *'
// lPos : INT -> 'int32_t'
// lpFormat : void* optional, out -> 'void *'
// lpcbFormat : INT* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("AVIFIL32.dll", {
  AVIStreamReadFormat: { parameters: ["pointer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat)
// pavi : IAVIStream* -> "pointer"
// lPos : INT -> "i32"
// lpFormat : void* optional, out -> "pointer"
// lpcbFormat : INT* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t AVIStreamReadFormat(
    void* pavi,
    int32_t lPos,
    void* lpFormat,
    int32_t* lpcbFormat);
C, "AVIFIL32.dll");
// $ffi->AVIStreamReadFormat(pavi, lPos, lpFormat, lpcbFormat);
// pavi : IAVIStream*
// lPos : INT
// lpFormat : void* optional, out
// lpcbFormat : INT* in/out
// 構造体/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 Avifil32 extends StdCallLibrary {
    Avifil32 INSTANCE = Native.load("avifil32", Avifil32.class);
    int AVIStreamReadFormat(
        Pointer pavi,   // IAVIStream*
        int lPos,   // INT
        Pointer lpFormat,   // void* optional, out
        IntByReference lpcbFormat   // INT* in/out
    );
}
@[Link("avifil32")]
lib LibAVIFIL32
  fun AVIStreamReadFormat = AVIStreamReadFormat(
    pavi : Void*,   # IAVIStream*
    lPos : Int32,   # INT
    lpFormat : Void*,   # void* optional, out
    lpcbFormat : Int32*   # INT* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef AVIStreamReadFormatNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, Pointer<Int32>);
typedef AVIStreamReadFormatDart = int Function(Pointer<Void>, int, Pointer<Void>, Pointer<Int32>);
final AVIStreamReadFormat = DynamicLibrary.open('AVIFIL32.dll')
    .lookupFunction<AVIStreamReadFormatNative, AVIStreamReadFormatDart>('AVIStreamReadFormat');
// pavi : IAVIStream* -> Pointer<Void>
// lPos : INT -> Int32
// lpFormat : void* optional, out -> Pointer<Void>
// lpcbFormat : INT* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function AVIStreamReadFormat(
  pavi: Pointer;   // IAVIStream*
  lPos: Integer;   // INT
  lpFormat: Pointer;   // void* optional, out
  lpcbFormat: Pointer   // INT* in/out
): Integer; stdcall;
  external 'AVIFIL32.dll' name 'AVIStreamReadFormat';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "AVIStreamReadFormat"
  c_AVIStreamReadFormat :: Ptr () -> Int32 -> Ptr () -> Ptr Int32 -> IO Int32
-- pavi : IAVIStream* -> Ptr ()
-- lPos : INT -> Int32
-- lpFormat : void* optional, out -> Ptr ()
-- lpcbFormat : INT* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let avistreamreadformat =
  foreign "AVIStreamReadFormat"
    ((ptr void) @-> int32_t @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* pavi : IAVIStream* -> (ptr void) *)
(* lPos : INT -> int32_t *)
(* lpFormat : void* optional, out -> (ptr void) *)
(* lpcbFormat : INT* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library avifil32 (t "AVIFIL32.dll"))
(cffi:use-foreign-library avifil32)

(cffi:defcfun ("AVIStreamReadFormat" avistream-read-format :convention :stdcall) :int32
  (pavi :pointer)   ; IAVIStream*
  (l-pos :int32)   ; INT
  (lp-format :pointer)   ; void* optional, out
  (lpcb-format :pointer))   ; INT* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $AVIStreamReadFormat = Win32::API::More->new('AVIFIL32',
    'int AVIStreamReadFormat(LPVOID pavi, int lPos, LPVOID lpFormat, LPVOID lpcbFormat)');
# my $ret = $AVIStreamReadFormat->Call($pavi, $lPos, $lpFormat, $lpcbFormat);
# pavi : IAVIStream* -> LPVOID
# lPos : INT -> int
# lpFormat : void* optional, out -> LPVOID
# lpcbFormat : INT* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型