ホーム › Storage.FileSystem › LZRead
LZRead
関数LZ圧縮ファイルから展開したデータを読み取る。
シグネチャ
// KERNEL32.dll
#include <windows.h>
INT LZRead(
INT hFile,
LPSTR lpBuffer,
INT cbRead
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hFile | INT | in |
| lpBuffer | LPSTR | out |
| cbRead | INT | in |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
INT LZRead(
INT hFile,
LPSTR lpBuffer,
INT cbRead
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern int LZRead(
int hFile, // INT
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpBuffer, // LPSTR out
int cbRead // INT
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function LZRead(
hFile As Integer, ' INT
<MarshalAs(UnmanagedType.LPStr)> lpBuffer As System.Text.StringBuilder, ' LPSTR out
cbRead As Integer ' INT
) As Integer
End Function' hFile : INT
' lpBuffer : LPSTR out
' cbRead : INT
Declare PtrSafe Function LZRead Lib "kernel32" ( _
ByVal hFile As Long, _
ByVal lpBuffer As String, _
ByVal cbRead As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LZRead = ctypes.windll.kernel32.LZRead
LZRead.restype = ctypes.c_int
LZRead.argtypes = [
ctypes.c_int, # hFile : INT
wintypes.LPSTR, # lpBuffer : LPSTR out
ctypes.c_int, # cbRead : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
LZRead = Fiddle::Function.new(
lib['LZRead'],
[
Fiddle::TYPE_INT, # hFile : INT
Fiddle::TYPE_VOIDP, # lpBuffer : LPSTR out
Fiddle::TYPE_INT, # cbRead : INT
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn LZRead(
hFile: i32, // INT
lpBuffer: *mut u8, // LPSTR out
cbRead: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern int LZRead(int hFile, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpBuffer, int cbRead);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_LZRead' -Namespace Win32 -PassThru
# $api::LZRead(hFile, lpBuffer, cbRead)#uselib "KERNEL32.dll"
#func global LZRead "LZRead" sptr, sptr, sptr
; LZRead hFile, varptr(lpBuffer), cbRead ; 戻り値は stat
; hFile : INT -> "sptr"
; lpBuffer : LPSTR out -> "sptr"
; cbRead : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global LZRead "LZRead" int, var, int ; res = LZRead(hFile, lpBuffer, cbRead) ; hFile : INT -> "int" ; lpBuffer : LPSTR out -> "var" ; cbRead : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global LZRead "LZRead" int, sptr, int ; res = LZRead(hFile, varptr(lpBuffer), cbRead) ; hFile : INT -> "int" ; lpBuffer : LPSTR out -> "sptr" ; cbRead : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT LZRead(INT hFile, LPSTR lpBuffer, INT cbRead) #uselib "KERNEL32.dll" #cfunc global LZRead "LZRead" int, var, int ; res = LZRead(hFile, lpBuffer, cbRead) ; hFile : INT -> "int" ; lpBuffer : LPSTR out -> "var" ; cbRead : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT LZRead(INT hFile, LPSTR lpBuffer, INT cbRead) #uselib "KERNEL32.dll" #cfunc global LZRead "LZRead" int, intptr, int ; res = LZRead(hFile, varptr(lpBuffer), cbRead) ; hFile : INT -> "int" ; lpBuffer : LPSTR out -> "intptr" ; cbRead : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procLZRead = kernel32.NewProc("LZRead")
)
// hFile (INT), lpBuffer (LPSTR out), cbRead (INT)
r1, _, err := procLZRead.Call(
uintptr(hFile),
uintptr(lpBuffer),
uintptr(cbRead),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction LZRead(
hFile: Integer; // INT
lpBuffer: PAnsiChar; // LPSTR out
cbRead: Integer // INT
): Integer; stdcall;
external 'KERNEL32.dll' name 'LZRead';result := DllCall("KERNEL32\LZRead"
, "Int", hFile ; INT
, "Ptr", lpBuffer ; LPSTR out
, "Int", cbRead ; INT
, "Int") ; return: INT●LZRead(hFile, lpBuffer, cbRead) = DLL("KERNEL32.dll", "int LZRead(int, char*, int)")
# 呼び出し: LZRead(hFile, lpBuffer, cbRead)
# hFile : INT -> "int"
# lpBuffer : LPSTR out -> "char*"
# cbRead : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。