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

RemoveLogContainer

関数
CLFSログからコンテナを削除する。
DLLclfsw32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL RemoveLogContainer(
    HANDLE hLog,
    LPWSTR pwszContainerPath,
    BOOL fForce,
    void* pReserved   // optional
);

パラメーター

名前方向説明
hLogHANDLEinCreateLogFile から取得したログへのハンドルです。
pwszContainerPathLPWSTRinAddLogContainer または AddLogContainerSet のいずれかによって作成されたログコンテナーのパスを格納するワイド文字列へのポインターです。
fForceBOOLin

コンテナーをいつ、どのように削除するかを決定する削除フラグです。

fForceTRUE で、コンテナーがアクティブなログ領域の一部である場合、コンテナーは削除されず、エラー ERROR_LOG_CANT_DELETE が返されます。

FALSE の場合、コンテナーがアクティブなログ領域の一部でなくなった時点で削除されます。

pReservedvoid*inoutoptionalこのパラメーターは予約されており、NULL に設定する必要があります。

戻り値の型: BOOL

公式ドキュメント

専用ログハンドルまたは多重化ログハンドルに関連付けられたログから、コンテナーを1つ削除します。

戻り値

関数が成功すると、戻り値は0以外になります。

関数が失敗すると、戻り値は0になります。拡張エラー情報を取得するには、 GetLastError を呼び出します。

以下のリストは、発生し得るエラーコードを示します。

解説(Remarks)

既定では、コンテナーの削除は遅延型であり、コンテナーがアクティブなログの一部でない場合にのみ削除されます。コンテナーがアクティブなログの一部である場合は、削除対象としてマークされます。ただし、ログの末尾がコンテナーの最終セクターを超えるか、コンテナーがアクティブなログの先頭の論理識別子よりも大きい論理識別子を持つようになるまで、削除は行われません。ログのサイズにコンテナーの削除が反映されるのは、コンテナーが物理的に削除された時点のみです。

ログクライアントは、削除フラグを TRUE に設定することで、コンテナーの強制削除を要求できます。これは、アクティブなログの一部でないコンテナーを削除する場合と同じ効果を持ちます。ただし、コンテナーがアクティブなログの一部である場合、呼び出しは失敗し、コンテナーは削除対象としてマークされません。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL RemoveLogContainer(
    HANDLE hLog,
    LPWSTR pwszContainerPath,
    BOOL fForce,
    void* pReserved   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("clfsw32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool RemoveLogContainer(
    IntPtr hLog,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string pwszContainerPath,   // LPWSTR
    bool fForce,   // BOOL
    IntPtr pReserved   // void* optional, in/out
);
<DllImport("clfsw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RemoveLogContainer(
    hLog As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> pwszContainerPath As String,   ' LPWSTR
    fForce As Boolean,   ' BOOL
    pReserved As IntPtr   ' void* optional, in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hLog : HANDLE
' pwszContainerPath : LPWSTR
' fForce : BOOL
' pReserved : void* optional, in/out
Declare PtrSafe Function RemoveLogContainer Lib "clfsw32" ( _
    ByVal hLog As LongPtr, _
    ByVal pwszContainerPath As LongPtr, _
    ByVal fForce As Long, _
    ByVal pReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RemoveLogContainer = ctypes.windll.clfsw32.RemoveLogContainer
RemoveLogContainer.restype = wintypes.BOOL
RemoveLogContainer.argtypes = [
    wintypes.HANDLE,  # hLog : HANDLE
    wintypes.LPCWSTR,  # pwszContainerPath : LPWSTR
    wintypes.BOOL,  # fForce : BOOL
    ctypes.POINTER(None),  # pReserved : void* optional, in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('clfsw32.dll')
RemoveLogContainer = Fiddle::Function.new(
  lib['RemoveLogContainer'],
  [
    Fiddle::TYPE_VOIDP,  # hLog : HANDLE
    Fiddle::TYPE_VOIDP,  # pwszContainerPath : LPWSTR
    Fiddle::TYPE_INT,  # fForce : BOOL
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional, in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "clfsw32")]
extern "system" {
    fn RemoveLogContainer(
        hLog: *mut core::ffi::c_void,  // HANDLE
        pwszContainerPath: *mut u16,  // LPWSTR
        fForce: i32,  // BOOL
        pReserved: *mut ()  // void* optional, in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("clfsw32.dll", SetLastError = true)]
public static extern bool RemoveLogContainer(IntPtr hLog, [MarshalAs(UnmanagedType.LPWStr)] string pwszContainerPath, bool fForce, IntPtr pReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'clfsw32_RemoveLogContainer' -Namespace Win32 -PassThru
# $api::RemoveLogContainer(hLog, pwszContainerPath, fForce, pReserved)
#uselib "clfsw32.dll"
#func global RemoveLogContainer "RemoveLogContainer" sptr, sptr, sptr, sptr
; RemoveLogContainer hLog, pwszContainerPath, fForce, pReserved   ; 戻り値は stat
; hLog : HANDLE -> "sptr"
; pwszContainerPath : LPWSTR -> "sptr"
; fForce : BOOL -> "sptr"
; pReserved : void* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "clfsw32.dll"
#cfunc global RemoveLogContainer "RemoveLogContainer" sptr, wstr, int, sptr
; res = RemoveLogContainer(hLog, pwszContainerPath, fForce, pReserved)
; hLog : HANDLE -> "sptr"
; pwszContainerPath : LPWSTR -> "wstr"
; fForce : BOOL -> "int"
; pReserved : void* optional, in/out -> "sptr"
; BOOL RemoveLogContainer(HANDLE hLog, LPWSTR pwszContainerPath, BOOL fForce, void* pReserved)
#uselib "clfsw32.dll"
#cfunc global RemoveLogContainer "RemoveLogContainer" intptr, wstr, int, intptr
; res = RemoveLogContainer(hLog, pwszContainerPath, fForce, pReserved)
; hLog : HANDLE -> "intptr"
; pwszContainerPath : LPWSTR -> "wstr"
; fForce : BOOL -> "int"
; pReserved : void* optional, in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clfsw32 = windows.NewLazySystemDLL("clfsw32.dll")
	procRemoveLogContainer = clfsw32.NewProc("RemoveLogContainer")
)

// hLog (HANDLE), pwszContainerPath (LPWSTR), fForce (BOOL), pReserved (void* optional, in/out)
r1, _, err := procRemoveLogContainer.Call(
	uintptr(hLog),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszContainerPath))),
	uintptr(fForce),
	uintptr(pReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function RemoveLogContainer(
  hLog: THandle;   // HANDLE
  pwszContainerPath: PWideChar;   // LPWSTR
  fForce: BOOL;   // BOOL
  pReserved: Pointer   // void* optional, in/out
): BOOL; stdcall;
  external 'clfsw32.dll' name 'RemoveLogContainer';
result := DllCall("clfsw32\RemoveLogContainer"
    , "Ptr", hLog   ; HANDLE
    , "WStr", pwszContainerPath   ; LPWSTR
    , "Int", fForce   ; BOOL
    , "Ptr", pReserved   ; void* optional, in/out
    , "Int")   ; return: BOOL
●RemoveLogContainer(hLog, pwszContainerPath, fForce, pReserved) = DLL("clfsw32.dll", "bool RemoveLogContainer(void*, char*, bool, void*)")
# 呼び出し: RemoveLogContainer(hLog, pwszContainerPath, fForce, pReserved)
# hLog : HANDLE -> "void*"
# pwszContainerPath : LPWSTR -> "char*"
# fForce : BOOL -> "bool"
# pReserved : void* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef RemoveLogContainerNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Int32, Pointer<Void>);
typedef RemoveLogContainerDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Void>);
final RemoveLogContainer = DynamicLibrary.open('clfsw32.dll')
    .lookupFunction<RemoveLogContainerNative, RemoveLogContainerDart>('RemoveLogContainer');
// hLog : HANDLE -> Pointer<Void>
// pwszContainerPath : LPWSTR -> Pointer<Utf16>
// fForce : BOOL -> Int32
// pReserved : void* optional, in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RemoveLogContainer(
  hLog: THandle;   // HANDLE
  pwszContainerPath: PWideChar;   // LPWSTR
  fForce: BOOL;   // BOOL
  pReserved: Pointer   // void* optional, in/out
): BOOL; stdcall;
  external 'clfsw32.dll' name 'RemoveLogContainer';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RemoveLogContainer"
  c_RemoveLogContainer :: Ptr () -> CWString -> CInt -> Ptr () -> IO CInt
-- hLog : HANDLE -> Ptr ()
-- pwszContainerPath : LPWSTR -> CWString
-- fForce : BOOL -> CInt
-- pReserved : void* optional, in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let removelogcontainer =
  foreign "RemoveLogContainer"
    ((ptr void) @-> (ptr uint16_t) @-> int32_t @-> (ptr void) @-> returning int32_t)
(* hLog : HANDLE -> (ptr void) *)
(* pwszContainerPath : LPWSTR -> (ptr uint16_t) *)
(* fForce : BOOL -> int32_t *)
(* pReserved : void* optional, in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clfsw32 (t "clfsw32.dll"))
(cffi:use-foreign-library clfsw32)

(cffi:defcfun ("RemoveLogContainer" remove-log-container :convention :stdcall) :int32
  (h-log :pointer)   ; HANDLE
  (pwsz-container-path (:string :encoding :utf-16le))   ; LPWSTR
  (f-force :int32)   ; BOOL
  (p-reserved :pointer))   ; void* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RemoveLogContainer = Win32::API::More->new('clfsw32',
    'BOOL RemoveLogContainer(HANDLE hLog, LPCWSTR pwszContainerPath, BOOL fForce, LPVOID pReserved)');
# my $ret = $RemoveLogContainer->Call($hLog, $pwszContainerPath, $fForce, $pReserved);
# hLog : HANDLE -> HANDLE
# pwszContainerPath : LPWSTR -> LPCWSTR
# fForce : BOOL -> BOOL
# pReserved : void* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目