ホーム › Storage.Compression › CreateDecompressor
CreateDecompressor
関数指定アルゴリズムの展開器ハンドルを作成する。
シグネチャ
// Cabinet.dll
#include <windows.h>
BOOL CreateDecompressor(
COMPRESS_ALGORITHM Algorithm,
COMPRESS_ALLOCATION_ROUTINES* AllocationRoutines, // optional
DECOMPRESSOR_HANDLE* DecompressorHandle
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Algorithm | COMPRESS_ALGORITHM | in |
| AllocationRoutines | COMPRESS_ALLOCATION_ROUTINES* | inoptional |
| DecompressorHandle | DECOMPRESSOR_HANDLE* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// Cabinet.dll
#include <windows.h>
BOOL CreateDecompressor(
COMPRESS_ALGORITHM Algorithm,
COMPRESS_ALLOCATION_ROUTINES* AllocationRoutines, // optional
DECOMPRESSOR_HANDLE* DecompressorHandle
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Cabinet.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CreateDecompressor(
uint Algorithm, // COMPRESS_ALGORITHM
IntPtr AllocationRoutines, // COMPRESS_ALLOCATION_ROUTINES* optional
IntPtr DecompressorHandle // DECOMPRESSOR_HANDLE* out
);<DllImport("Cabinet.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateDecompressor(
Algorithm As UInteger, ' COMPRESS_ALGORITHM
AllocationRoutines As IntPtr, ' COMPRESS_ALLOCATION_ROUTINES* optional
DecompressorHandle As IntPtr ' DECOMPRESSOR_HANDLE* out
) As Boolean
End Function' Algorithm : COMPRESS_ALGORITHM
' AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional
' DecompressorHandle : DECOMPRESSOR_HANDLE* out
Declare PtrSafe Function CreateDecompressor Lib "cabinet" ( _
ByVal Algorithm As Long, _
ByVal AllocationRoutines As LongPtr, _
ByVal DecompressorHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateDecompressor = ctypes.windll.cabinet.CreateDecompressor
CreateDecompressor.restype = wintypes.BOOL
CreateDecompressor.argtypes = [
wintypes.DWORD, # Algorithm : COMPRESS_ALGORITHM
ctypes.c_void_p, # AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional
ctypes.c_void_p, # DecompressorHandle : DECOMPRESSOR_HANDLE* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Cabinet.dll')
CreateDecompressor = Fiddle::Function.new(
lib['CreateDecompressor'],
[
-Fiddle::TYPE_INT, # Algorithm : COMPRESS_ALGORITHM
Fiddle::TYPE_VOIDP, # AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional
Fiddle::TYPE_VOIDP, # DecompressorHandle : DECOMPRESSOR_HANDLE* out
],
Fiddle::TYPE_INT)#[link(name = "cabinet")]
extern "system" {
fn CreateDecompressor(
Algorithm: u32, // COMPRESS_ALGORITHM
AllocationRoutines: *mut COMPRESS_ALLOCATION_ROUTINES, // COMPRESS_ALLOCATION_ROUTINES* optional
DecompressorHandle: *mut *mut core::ffi::c_void // DECOMPRESSOR_HANDLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Cabinet.dll", SetLastError = true)]
public static extern bool CreateDecompressor(uint Algorithm, IntPtr AllocationRoutines, IntPtr DecompressorHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Cabinet_CreateDecompressor' -Namespace Win32 -PassThru
# $api::CreateDecompressor(Algorithm, AllocationRoutines, DecompressorHandle)#uselib "Cabinet.dll"
#func global CreateDecompressor "CreateDecompressor" sptr, sptr, sptr
; CreateDecompressor Algorithm, varptr(AllocationRoutines), DecompressorHandle ; 戻り値は stat
; Algorithm : COMPRESS_ALGORITHM -> "sptr"
; AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional -> "sptr"
; DecompressorHandle : DECOMPRESSOR_HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "Cabinet.dll" #cfunc global CreateDecompressor "CreateDecompressor" int, var, sptr ; res = CreateDecompressor(Algorithm, AllocationRoutines, DecompressorHandle) ; Algorithm : COMPRESS_ALGORITHM -> "int" ; AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional -> "var" ; DecompressorHandle : DECOMPRESSOR_HANDLE* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "Cabinet.dll" #cfunc global CreateDecompressor "CreateDecompressor" int, sptr, sptr ; res = CreateDecompressor(Algorithm, varptr(AllocationRoutines), DecompressorHandle) ; Algorithm : COMPRESS_ALGORITHM -> "int" ; AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional -> "sptr" ; DecompressorHandle : DECOMPRESSOR_HANDLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CreateDecompressor(COMPRESS_ALGORITHM Algorithm, COMPRESS_ALLOCATION_ROUTINES* AllocationRoutines, DECOMPRESSOR_HANDLE* DecompressorHandle) #uselib "Cabinet.dll" #cfunc global CreateDecompressor "CreateDecompressor" int, var, intptr ; res = CreateDecompressor(Algorithm, AllocationRoutines, DecompressorHandle) ; Algorithm : COMPRESS_ALGORITHM -> "int" ; AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional -> "var" ; DecompressorHandle : DECOMPRESSOR_HANDLE* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CreateDecompressor(COMPRESS_ALGORITHM Algorithm, COMPRESS_ALLOCATION_ROUTINES* AllocationRoutines, DECOMPRESSOR_HANDLE* DecompressorHandle) #uselib "Cabinet.dll" #cfunc global CreateDecompressor "CreateDecompressor" int, intptr, intptr ; res = CreateDecompressor(Algorithm, varptr(AllocationRoutines), DecompressorHandle) ; Algorithm : COMPRESS_ALGORITHM -> "int" ; AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional -> "intptr" ; DecompressorHandle : DECOMPRESSOR_HANDLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cabinet = windows.NewLazySystemDLL("Cabinet.dll")
procCreateDecompressor = cabinet.NewProc("CreateDecompressor")
)
// Algorithm (COMPRESS_ALGORITHM), AllocationRoutines (COMPRESS_ALLOCATION_ROUTINES* optional), DecompressorHandle (DECOMPRESSOR_HANDLE* out)
r1, _, err := procCreateDecompressor.Call(
uintptr(Algorithm),
uintptr(AllocationRoutines),
uintptr(DecompressorHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CreateDecompressor(
Algorithm: DWORD; // COMPRESS_ALGORITHM
AllocationRoutines: Pointer; // COMPRESS_ALLOCATION_ROUTINES* optional
DecompressorHandle: Pointer // DECOMPRESSOR_HANDLE* out
): BOOL; stdcall;
external 'Cabinet.dll' name 'CreateDecompressor';result := DllCall("Cabinet\CreateDecompressor"
, "UInt", Algorithm ; COMPRESS_ALGORITHM
, "Ptr", AllocationRoutines ; COMPRESS_ALLOCATION_ROUTINES* optional
, "Ptr", DecompressorHandle ; DECOMPRESSOR_HANDLE* out
, "Int") ; return: BOOL●CreateDecompressor(Algorithm, AllocationRoutines, DecompressorHandle) = DLL("Cabinet.dll", "bool CreateDecompressor(dword, void*, void*)")
# 呼び出し: CreateDecompressor(Algorithm, AllocationRoutines, DecompressorHandle)
# Algorithm : COMPRESS_ALGORITHM -> "dword"
# AllocationRoutines : COMPRESS_ALLOCATION_ROUTINES* optional -> "void*"
# DecompressorHandle : DECOMPRESSOR_HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。