Win32 API 日本語リファレンス
ホームStorage.Compression › SetCompressorInformation

SetCompressorInformation

関数
圧縮器の指定種別のパラメータを設定する。
DLLCabinet.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

BOOL SetCompressorInformation(
    COMPRESSOR_HANDLE CompressorHandle,
    COMPRESS_INFORMATION_CLASS CompressInformationClass,
    const void* CompressInformation,
    UINT_PTR CompressInformationSize
);

パラメーター

名前方向説明
CompressorHandleCOMPRESSOR_HANDLEin設定対象の圧縮ハンドル。CreateCompressorで取得した値。
CompressInformationClassCOMPRESS_INFORMATION_CLASSin設定する情報の種別を示すCOMPRESS_INFORMATION_CLASS列挙値。ブロックサイズ等を指定する。
CompressInformationvoid*in設定する値を保持するバッファへのポインタ。
CompressInformationSizeUINT_PTRinCompressInformationのバイト単位のサイズ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetCompressorInformation(
    COMPRESSOR_HANDLE CompressorHandle,
    COMPRESS_INFORMATION_CLASS CompressInformationClass,
    const void* CompressInformation,
    UINT_PTR CompressInformationSize
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Cabinet.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetCompressorInformation(
    IntPtr CompressorHandle,   // COMPRESSOR_HANDLE
    int CompressInformationClass,   // COMPRESS_INFORMATION_CLASS
    IntPtr CompressInformation,   // void*
    UIntPtr CompressInformationSize   // UINT_PTR
);
<DllImport("Cabinet.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetCompressorInformation(
    CompressorHandle As IntPtr,   ' COMPRESSOR_HANDLE
    CompressInformationClass As Integer,   ' COMPRESS_INFORMATION_CLASS
    CompressInformation As IntPtr,   ' void*
    CompressInformationSize As UIntPtr   ' UINT_PTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' CompressorHandle : COMPRESSOR_HANDLE
' CompressInformationClass : COMPRESS_INFORMATION_CLASS
' CompressInformation : void*
' CompressInformationSize : UINT_PTR
Declare PtrSafe Function SetCompressorInformation Lib "cabinet" ( _
    ByVal CompressorHandle As LongPtr, _
    ByVal CompressInformationClass As Long, _
    ByVal CompressInformation As LongPtr, _
    ByVal CompressInformationSize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetCompressorInformation = ctypes.windll.cabinet.SetCompressorInformation
SetCompressorInformation.restype = wintypes.BOOL
SetCompressorInformation.argtypes = [
    wintypes.HANDLE,  # CompressorHandle : COMPRESSOR_HANDLE
    ctypes.c_int,  # CompressInformationClass : COMPRESS_INFORMATION_CLASS
    ctypes.POINTER(None),  # CompressInformation : void*
    ctypes.c_size_t,  # CompressInformationSize : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('Cabinet.dll')
SetCompressorInformation = Fiddle::Function.new(
  lib['SetCompressorInformation'],
  [
    Fiddle::TYPE_VOIDP,  # CompressorHandle : COMPRESSOR_HANDLE
    Fiddle::TYPE_INT,  # CompressInformationClass : COMPRESS_INFORMATION_CLASS
    Fiddle::TYPE_VOIDP,  # CompressInformation : void*
    Fiddle::TYPE_UINTPTR_T,  # CompressInformationSize : UINT_PTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "cabinet")]
extern "system" {
    fn SetCompressorInformation(
        CompressorHandle: *mut core::ffi::c_void,  // COMPRESSOR_HANDLE
        CompressInformationClass: i32,  // COMPRESS_INFORMATION_CLASS
        CompressInformation: *const (),  // void*
        CompressInformationSize: usize  // UINT_PTR
    ) -> 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 SetCompressorInformation(IntPtr CompressorHandle, int CompressInformationClass, IntPtr CompressInformation, UIntPtr CompressInformationSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Cabinet_SetCompressorInformation' -Namespace Win32 -PassThru
# $api::SetCompressorInformation(CompressorHandle, CompressInformationClass, CompressInformation, CompressInformationSize)
#uselib "Cabinet.dll"
#func global SetCompressorInformation "SetCompressorInformation" sptr, sptr, sptr, sptr
; SetCompressorInformation CompressorHandle, CompressInformationClass, CompressInformation, CompressInformationSize   ; 戻り値は stat
; CompressorHandle : COMPRESSOR_HANDLE -> "sptr"
; CompressInformationClass : COMPRESS_INFORMATION_CLASS -> "sptr"
; CompressInformation : void* -> "sptr"
; CompressInformationSize : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "Cabinet.dll"
#cfunc global SetCompressorInformation "SetCompressorInformation" sptr, int, sptr, sptr
; res = SetCompressorInformation(CompressorHandle, CompressInformationClass, CompressInformation, CompressInformationSize)
; CompressorHandle : COMPRESSOR_HANDLE -> "sptr"
; CompressInformationClass : COMPRESS_INFORMATION_CLASS -> "int"
; CompressInformation : void* -> "sptr"
; CompressInformationSize : UINT_PTR -> "sptr"
; BOOL SetCompressorInformation(COMPRESSOR_HANDLE CompressorHandle, COMPRESS_INFORMATION_CLASS CompressInformationClass, void* CompressInformation, UINT_PTR CompressInformationSize)
#uselib "Cabinet.dll"
#cfunc global SetCompressorInformation "SetCompressorInformation" intptr, int, intptr, intptr
; res = SetCompressorInformation(CompressorHandle, CompressInformationClass, CompressInformation, CompressInformationSize)
; CompressorHandle : COMPRESSOR_HANDLE -> "intptr"
; CompressInformationClass : COMPRESS_INFORMATION_CLASS -> "int"
; CompressInformation : void* -> "intptr"
; CompressInformationSize : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cabinet = windows.NewLazySystemDLL("Cabinet.dll")
	procSetCompressorInformation = cabinet.NewProc("SetCompressorInformation")
)

// CompressorHandle (COMPRESSOR_HANDLE), CompressInformationClass (COMPRESS_INFORMATION_CLASS), CompressInformation (void*), CompressInformationSize (UINT_PTR)
r1, _, err := procSetCompressorInformation.Call(
	uintptr(CompressorHandle),
	uintptr(CompressInformationClass),
	uintptr(CompressInformation),
	uintptr(CompressInformationSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetCompressorInformation(
  CompressorHandle: THandle;   // COMPRESSOR_HANDLE
  CompressInformationClass: Integer;   // COMPRESS_INFORMATION_CLASS
  CompressInformation: Pointer;   // void*
  CompressInformationSize: NativeUInt   // UINT_PTR
): BOOL; stdcall;
  external 'Cabinet.dll' name 'SetCompressorInformation';
result := DllCall("Cabinet\SetCompressorInformation"
    , "Ptr", CompressorHandle   ; COMPRESSOR_HANDLE
    , "Int", CompressInformationClass   ; COMPRESS_INFORMATION_CLASS
    , "Ptr", CompressInformation   ; void*
    , "UPtr", CompressInformationSize   ; UINT_PTR
    , "Int")   ; return: BOOL
●SetCompressorInformation(CompressorHandle, CompressInformationClass, CompressInformation, CompressInformationSize) = DLL("Cabinet.dll", "bool SetCompressorInformation(void*, int, void*, int)")
# 呼び出し: SetCompressorInformation(CompressorHandle, CompressInformationClass, CompressInformation, CompressInformationSize)
# CompressorHandle : COMPRESSOR_HANDLE -> "void*"
# CompressInformationClass : COMPRESS_INFORMATION_CLASS -> "int"
# CompressInformation : void* -> "void*"
# CompressInformationSize : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef SetCompressorInformationNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, UintPtr);
typedef SetCompressorInformationDart = int Function(Pointer<Void>, int, Pointer<Void>, int);
final SetCompressorInformation = DynamicLibrary.open('Cabinet.dll')
    .lookupFunction<SetCompressorInformationNative, SetCompressorInformationDart>('SetCompressorInformation');
// CompressorHandle : COMPRESSOR_HANDLE -> Pointer<Void>
// CompressInformationClass : COMPRESS_INFORMATION_CLASS -> Int32
// CompressInformation : void* -> Pointer<Void>
// CompressInformationSize : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetCompressorInformation(
  CompressorHandle: THandle;   // COMPRESSOR_HANDLE
  CompressInformationClass: Integer;   // COMPRESS_INFORMATION_CLASS
  CompressInformation: Pointer;   // void*
  CompressInformationSize: NativeUInt   // UINT_PTR
): BOOL; stdcall;
  external 'Cabinet.dll' name 'SetCompressorInformation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetCompressorInformation"
  c_SetCompressorInformation :: Ptr () -> Int32 -> Ptr () -> CUIntPtr -> IO CInt
-- CompressorHandle : COMPRESSOR_HANDLE -> Ptr ()
-- CompressInformationClass : COMPRESS_INFORMATION_CLASS -> Int32
-- CompressInformation : void* -> Ptr ()
-- CompressInformationSize : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setcompressorinformation =
  foreign "SetCompressorInformation"
    ((ptr void) @-> int32_t @-> (ptr void) @-> size_t @-> returning int32_t)
(* CompressorHandle : COMPRESSOR_HANDLE -> (ptr void) *)
(* CompressInformationClass : COMPRESS_INFORMATION_CLASS -> int32_t *)
(* CompressInformation : void* -> (ptr void) *)
(* CompressInformationSize : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library cabinet (t "Cabinet.dll"))
(cffi:use-foreign-library cabinet)

(cffi:defcfun ("SetCompressorInformation" set-compressor-information :convention :stdcall) :int32
  (compressor-handle :pointer)   ; COMPRESSOR_HANDLE
  (compress-information-class :int32)   ; COMPRESS_INFORMATION_CLASS
  (compress-information :pointer)   ; void*
  (compress-information-size :uint64))   ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetCompressorInformation = Win32::API::More->new('Cabinet',
    'BOOL SetCompressorInformation(HANDLE CompressorHandle, int CompressInformationClass, LPVOID CompressInformation, WPARAM CompressInformationSize)');
# my $ret = $SetCompressorInformation->Call($CompressorHandle, $CompressInformationClass, $CompressInformation, $CompressInformationSize);
# CompressorHandle : COMPRESSOR_HANDLE -> HANDLE
# CompressInformationClass : COMPRESS_INFORMATION_CLASS -> int
# CompressInformation : void* -> LPVOID
# CompressInformationSize : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型