ホーム › Storage.Cabinets › FDITruncateCabinet
FDITruncateCabinet
関数FDIで指定フォルダ以降のキャビネットを切り詰める。
シグネチャ
// Cabinet.dll
#include <windows.h>
BOOL FDITruncateCabinet(
void* hfdi,
LPSTR pszCabinetName,
WORD iFolderToDelete
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hfdi | void* | in | FDICreateで取得したFDIコンテキストハンドル。 |
| pszCabinetName | LPSTR | in | 切り詰める対象キャビネットのファイル名を示すASCII文字列。 |
| iFolderToDelete | WORD | in | 削除を開始するフォルダーの0始まりのインデックス。以降のフォルダーが除去される。 |
戻り値の型: BOOL
各言語での呼び出し定義
// Cabinet.dll
#include <windows.h>
BOOL FDITruncateCabinet(
void* hfdi,
LPSTR pszCabinetName,
WORD iFolderToDelete
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Cabinet.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern bool FDITruncateCabinet(
IntPtr hfdi, // void*
[MarshalAs(UnmanagedType.LPStr)] string pszCabinetName, // LPSTR
ushort iFolderToDelete // WORD
);<DllImport("Cabinet.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function FDITruncateCabinet(
hfdi As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> pszCabinetName As String, ' LPSTR
iFolderToDelete As UShort ' WORD
) As Boolean
End Function' hfdi : void*
' pszCabinetName : LPSTR
' iFolderToDelete : WORD
Declare PtrSafe Function FDITruncateCabinet Lib "cabinet" ( _
ByVal hfdi As LongPtr, _
ByVal pszCabinetName As String, _
ByVal iFolderToDelete As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FDITruncateCabinet = ctypes.cdll.cabinet.FDITruncateCabinet
FDITruncateCabinet.restype = wintypes.BOOL
FDITruncateCabinet.argtypes = [
ctypes.POINTER(None), # hfdi : void*
wintypes.LPCSTR, # pszCabinetName : LPSTR
ctypes.c_ushort, # iFolderToDelete : WORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Cabinet.dll')
FDITruncateCabinet = Fiddle::Function.new(
lib['FDITruncateCabinet'],
[
Fiddle::TYPE_VOIDP, # hfdi : void*
Fiddle::TYPE_VOIDP, # pszCabinetName : LPSTR
-Fiddle::TYPE_SHORT, # iFolderToDelete : WORD
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "cabinet")]
extern "C" {
fn FDITruncateCabinet(
hfdi: *mut (), // void*
pszCabinetName: *mut u8, // LPSTR
iFolderToDelete: u16 // WORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Cabinet.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool FDITruncateCabinet(IntPtr hfdi, [MarshalAs(UnmanagedType.LPStr)] string pszCabinetName, ushort iFolderToDelete);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Cabinet_FDITruncateCabinet' -Namespace Win32 -PassThru
# $api::FDITruncateCabinet(hfdi, pszCabinetName, iFolderToDelete)#uselib "Cabinet.dll"
#func global FDITruncateCabinet "FDITruncateCabinet" sptr, sptr, sptr
; FDITruncateCabinet hfdi, pszCabinetName, iFolderToDelete ; 戻り値は stat
; hfdi : void* -> "sptr"
; pszCabinetName : LPSTR -> "sptr"
; iFolderToDelete : WORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "Cabinet.dll"
#cfunc global FDITruncateCabinet "FDITruncateCabinet" sptr, str, int
; res = FDITruncateCabinet(hfdi, pszCabinetName, iFolderToDelete)
; hfdi : void* -> "sptr"
; pszCabinetName : LPSTR -> "str"
; iFolderToDelete : WORD -> "int"; BOOL FDITruncateCabinet(void* hfdi, LPSTR pszCabinetName, WORD iFolderToDelete)
#uselib "Cabinet.dll"
#cfunc global FDITruncateCabinet "FDITruncateCabinet" intptr, str, int
; res = FDITruncateCabinet(hfdi, pszCabinetName, iFolderToDelete)
; hfdi : void* -> "intptr"
; pszCabinetName : LPSTR -> "str"
; iFolderToDelete : WORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cabinet = windows.NewLazySystemDLL("Cabinet.dll")
procFDITruncateCabinet = cabinet.NewProc("FDITruncateCabinet")
)
// hfdi (void*), pszCabinetName (LPSTR), iFolderToDelete (WORD)
r1, _, err := procFDITruncateCabinet.Call(
uintptr(hfdi),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszCabinetName))),
uintptr(iFolderToDelete),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction FDITruncateCabinet(
hfdi: Pointer; // void*
pszCabinetName: PAnsiChar; // LPSTR
iFolderToDelete: Word // WORD
): BOOL; cdecl;
external 'Cabinet.dll' name 'FDITruncateCabinet';result := DllCall("Cabinet\FDITruncateCabinet"
, "Ptr", hfdi ; void*
, "AStr", pszCabinetName ; LPSTR
, "UShort", iFolderToDelete ; WORD
, "Cdecl Int") ; return: BOOL●FDITruncateCabinet(hfdi, pszCabinetName, iFolderToDelete) = DLL("Cabinet.dll", "bool FDITruncateCabinet(void*, char*, int)")
# 呼び出し: FDITruncateCabinet(hfdi, pszCabinetName, iFolderToDelete)
# hfdi : void* -> "void*"
# pszCabinetName : LPSTR -> "char*"
# iFolderToDelete : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。