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