ホーム › Storage.FileSystem › GetFileVersionInfoSizeA
GetFileVersionInfoSizeA
関数ファイルのバージョン情報の必要バッファサイズを取得する(ANSI版)。
シグネチャ
// VERSION.dll (ANSI / -A)
#include <windows.h>
DWORD GetFileVersionInfoSizeA(
LPCSTR lptstrFilename,
DWORD* lpdwHandle // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lptstrFilename | LPCSTR | in |
| lpdwHandle | DWORD* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// VERSION.dll (ANSI / -A)
#include <windows.h>
DWORD GetFileVersionInfoSizeA(
LPCSTR lptstrFilename,
DWORD* lpdwHandle // optional
);[DllImport("VERSION.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint GetFileVersionInfoSizeA(
[MarshalAs(UnmanagedType.LPStr)] string lptstrFilename, // LPCSTR
IntPtr lpdwHandle // DWORD* optional, out
);<DllImport("VERSION.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetFileVersionInfoSizeA(
<MarshalAs(UnmanagedType.LPStr)> lptstrFilename As String, ' LPCSTR
lpdwHandle As IntPtr ' DWORD* optional, out
) As UInteger
End Function' lptstrFilename : LPCSTR
' lpdwHandle : DWORD* optional, out
Declare PtrSafe Function GetFileVersionInfoSizeA Lib "version" ( _
ByVal lptstrFilename As String, _
ByVal lpdwHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetFileVersionInfoSizeA = ctypes.windll.version.GetFileVersionInfoSizeA
GetFileVersionInfoSizeA.restype = wintypes.DWORD
GetFileVersionInfoSizeA.argtypes = [
wintypes.LPCSTR, # lptstrFilename : LPCSTR
ctypes.POINTER(wintypes.DWORD), # lpdwHandle : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('VERSION.dll')
GetFileVersionInfoSizeA = Fiddle::Function.new(
lib['GetFileVersionInfoSizeA'],
[
Fiddle::TYPE_VOIDP, # lptstrFilename : LPCSTR
Fiddle::TYPE_VOIDP, # lpdwHandle : DWORD* optional, out
],
-Fiddle::TYPE_INT)#[link(name = "version")]
extern "system" {
fn GetFileVersionInfoSizeA(
lptstrFilename: *const u8, // LPCSTR
lpdwHandle: *mut u32 // DWORD* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("VERSION.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern uint GetFileVersionInfoSizeA([MarshalAs(UnmanagedType.LPStr)] string lptstrFilename, IntPtr lpdwHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'VERSION_GetFileVersionInfoSizeA' -Namespace Win32 -PassThru
# $api::GetFileVersionInfoSizeA(lptstrFilename, lpdwHandle)#uselib "VERSION.dll"
#func global GetFileVersionInfoSizeA "GetFileVersionInfoSizeA" sptr, sptr
; GetFileVersionInfoSizeA lptstrFilename, varptr(lpdwHandle) ; 戻り値は stat
; lptstrFilename : LPCSTR -> "sptr"
; lpdwHandle : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "VERSION.dll" #cfunc global GetFileVersionInfoSizeA "GetFileVersionInfoSizeA" str, var ; res = GetFileVersionInfoSizeA(lptstrFilename, lpdwHandle) ; lptstrFilename : LPCSTR -> "str" ; lpdwHandle : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "VERSION.dll" #cfunc global GetFileVersionInfoSizeA "GetFileVersionInfoSizeA" str, sptr ; res = GetFileVersionInfoSizeA(lptstrFilename, varptr(lpdwHandle)) ; lptstrFilename : LPCSTR -> "str" ; lpdwHandle : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, DWORD* lpdwHandle) #uselib "VERSION.dll" #cfunc global GetFileVersionInfoSizeA "GetFileVersionInfoSizeA" str, var ; res = GetFileVersionInfoSizeA(lptstrFilename, lpdwHandle) ; lptstrFilename : LPCSTR -> "str" ; lpdwHandle : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetFileVersionInfoSizeA(LPCSTR lptstrFilename, DWORD* lpdwHandle) #uselib "VERSION.dll" #cfunc global GetFileVersionInfoSizeA "GetFileVersionInfoSizeA" str, intptr ; res = GetFileVersionInfoSizeA(lptstrFilename, varptr(lpdwHandle)) ; lptstrFilename : LPCSTR -> "str" ; lpdwHandle : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
version = windows.NewLazySystemDLL("VERSION.dll")
procGetFileVersionInfoSizeA = version.NewProc("GetFileVersionInfoSizeA")
)
// lptstrFilename (LPCSTR), lpdwHandle (DWORD* optional, out)
r1, _, err := procGetFileVersionInfoSizeA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lptstrFilename))),
uintptr(lpdwHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetFileVersionInfoSizeA(
lptstrFilename: PAnsiChar; // LPCSTR
lpdwHandle: Pointer // DWORD* optional, out
): DWORD; stdcall;
external 'VERSION.dll' name 'GetFileVersionInfoSizeA';result := DllCall("VERSION\GetFileVersionInfoSizeA"
, "AStr", lptstrFilename ; LPCSTR
, "Ptr", lpdwHandle ; DWORD* optional, out
, "UInt") ; return: DWORD●GetFileVersionInfoSizeA(lptstrFilename, lpdwHandle) = DLL("VERSION.dll", "dword GetFileVersionInfoSizeA(char*, void*)")
# 呼び出し: GetFileVersionInfoSizeA(lptstrFilename, lpdwHandle)
# lptstrFilename : LPCSTR -> "char*"
# lpdwHandle : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。