ホーム › Storage.FileSystem › RegisterForLogWriteNotification
RegisterForLogWriteNotification
関数CLFSログ書き込みしきい値通知の登録を設定する。
シグネチャ
// clfsw32.dll
#include <windows.h>
BOOL RegisterForLogWriteNotification(
HANDLE hLog,
DWORD cbThreshold,
BOOL fEnable
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hLog | HANDLE | in | ログフル状態を解決する対象のログへのハンドル。 |
| cbThreshold | DWORD | in | 通知が送信されるまでにログファイルへ書き込まれるバイト数。 |
| fEnable | BOOL | in | TRUE の場合、通知は有効になります。FALSE の場合、通知は無効になります。 |
戻り値の型: BOOL
公式ドキュメント
RegisterForLogWriteNotification 関数は、ログ書き込み通知を有効または無効にするために、マネージドログクライアントから呼び出されます。
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。詳細なエラー情報を取得するには、 GetLastError を呼び出します。有効な値には次のものが含まれます:
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// clfsw32.dll
#include <windows.h>
BOOL RegisterForLogWriteNotification(
HANDLE hLog,
DWORD cbThreshold,
BOOL fEnable
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("clfsw32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool RegisterForLogWriteNotification(
IntPtr hLog, // HANDLE
uint cbThreshold, // DWORD
bool fEnable // BOOL
);<DllImport("clfsw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RegisterForLogWriteNotification(
hLog As IntPtr, ' HANDLE
cbThreshold As UInteger, ' DWORD
fEnable As Boolean ' BOOL
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hLog : HANDLE
' cbThreshold : DWORD
' fEnable : BOOL
Declare PtrSafe Function RegisterForLogWriteNotification Lib "clfsw32" ( _
ByVal hLog As LongPtr, _
ByVal cbThreshold As Long, _
ByVal fEnable As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterForLogWriteNotification = ctypes.windll.clfsw32.RegisterForLogWriteNotification
RegisterForLogWriteNotification.restype = wintypes.BOOL
RegisterForLogWriteNotification.argtypes = [
wintypes.HANDLE, # hLog : HANDLE
wintypes.DWORD, # cbThreshold : DWORD
wintypes.BOOL, # fEnable : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('clfsw32.dll')
RegisterForLogWriteNotification = Fiddle::Function.new(
lib['RegisterForLogWriteNotification'],
[
Fiddle::TYPE_VOIDP, # hLog : HANDLE
-Fiddle::TYPE_INT, # cbThreshold : DWORD
Fiddle::TYPE_INT, # fEnable : BOOL
],
Fiddle::TYPE_INT)#[link(name = "clfsw32")]
extern "system" {
fn RegisterForLogWriteNotification(
hLog: *mut core::ffi::c_void, // HANDLE
cbThreshold: u32, // DWORD
fEnable: i32 // BOOL
) -> 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 RegisterForLogWriteNotification(IntPtr hLog, uint cbThreshold, bool fEnable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'clfsw32_RegisterForLogWriteNotification' -Namespace Win32 -PassThru
# $api::RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)#uselib "clfsw32.dll"
#func global RegisterForLogWriteNotification "RegisterForLogWriteNotification" sptr, sptr, sptr
; RegisterForLogWriteNotification hLog, cbThreshold, fEnable ; 戻り値は stat
; hLog : HANDLE -> "sptr"
; cbThreshold : DWORD -> "sptr"
; fEnable : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "clfsw32.dll"
#cfunc global RegisterForLogWriteNotification "RegisterForLogWriteNotification" sptr, int, int
; res = RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)
; hLog : HANDLE -> "sptr"
; cbThreshold : DWORD -> "int"
; fEnable : BOOL -> "int"; BOOL RegisterForLogWriteNotification(HANDLE hLog, DWORD cbThreshold, BOOL fEnable)
#uselib "clfsw32.dll"
#cfunc global RegisterForLogWriteNotification "RegisterForLogWriteNotification" intptr, int, int
; res = RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)
; hLog : HANDLE -> "intptr"
; cbThreshold : DWORD -> "int"
; fEnable : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clfsw32 = windows.NewLazySystemDLL("clfsw32.dll")
procRegisterForLogWriteNotification = clfsw32.NewProc("RegisterForLogWriteNotification")
)
// hLog (HANDLE), cbThreshold (DWORD), fEnable (BOOL)
r1, _, err := procRegisterForLogWriteNotification.Call(
uintptr(hLog),
uintptr(cbThreshold),
uintptr(fEnable),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction RegisterForLogWriteNotification(
hLog: THandle; // HANDLE
cbThreshold: DWORD; // DWORD
fEnable: BOOL // BOOL
): BOOL; stdcall;
external 'clfsw32.dll' name 'RegisterForLogWriteNotification';result := DllCall("clfsw32\RegisterForLogWriteNotification"
, "Ptr", hLog ; HANDLE
, "UInt", cbThreshold ; DWORD
, "Int", fEnable ; BOOL
, "Int") ; return: BOOL●RegisterForLogWriteNotification(hLog, cbThreshold, fEnable) = DLL("clfsw32.dll", "bool RegisterForLogWriteNotification(void*, dword, bool)")
# 呼び出し: RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)
# hLog : HANDLE -> "void*"
# cbThreshold : DWORD -> "dword"
# fEnable : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "clfsw32" fn RegisterForLogWriteNotification(
hLog: ?*anyopaque, // HANDLE
cbThreshold: u32, // DWORD
fEnable: i32 // BOOL
) callconv(std.os.windows.WINAPI) i32;proc RegisterForLogWriteNotification(
hLog: pointer, # HANDLE
cbThreshold: uint32, # DWORD
fEnable: int32 # BOOL
): int32 {.importc: "RegisterForLogWriteNotification", stdcall, dynlib: "clfsw32.dll".}pragma(lib, "clfsw32");
extern(Windows)
int RegisterForLogWriteNotification(
void* hLog, // HANDLE
uint cbThreshold, // DWORD
int fEnable // BOOL
);ccall((:RegisterForLogWriteNotification, "clfsw32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Int32),
hLog, cbThreshold, fEnable)
# hLog : HANDLE -> Ptr{Cvoid}
# cbThreshold : DWORD -> UInt32
# fEnable : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RegisterForLogWriteNotification(
void* hLog,
uint32_t cbThreshold,
int32_t fEnable);
]]
local clfsw32 = ffi.load("clfsw32")
-- clfsw32.RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)
-- hLog : HANDLE
-- cbThreshold : DWORD
-- fEnable : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('clfsw32.dll');
const RegisterForLogWriteNotification = lib.func('__stdcall', 'RegisterForLogWriteNotification', 'int32_t', ['void *', 'uint32_t', 'int32_t']);
// RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)
// hLog : HANDLE -> 'void *'
// cbThreshold : DWORD -> 'uint32_t'
// fEnable : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("clfsw32.dll", {
RegisterForLogWriteNotification: { parameters: ["pointer", "u32", "i32"], result: "i32" },
});
// lib.symbols.RegisterForLogWriteNotification(hLog, cbThreshold, fEnable)
// hLog : HANDLE -> "pointer"
// cbThreshold : DWORD -> "u32"
// fEnable : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RegisterForLogWriteNotification(
void* hLog,
uint32_t cbThreshold,
int32_t fEnable);
C, "clfsw32.dll");
// $ffi->RegisterForLogWriteNotification(hLog, cbThreshold, fEnable);
// hLog : HANDLE
// cbThreshold : DWORD
// fEnable : BOOL
// 構造体/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 RegisterForLogWriteNotification(
Pointer hLog, // HANDLE
int cbThreshold, // DWORD
boolean fEnable // BOOL
);
}@[Link("clfsw32")]
lib Libclfsw32
fun RegisterForLogWriteNotification = RegisterForLogWriteNotification(
hLog : Void*, # HANDLE
cbThreshold : UInt32, # DWORD
fEnable : Int32 # BOOL
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RegisterForLogWriteNotificationNative = Int32 Function(Pointer<Void>, Uint32, Int32);
typedef RegisterForLogWriteNotificationDart = int Function(Pointer<Void>, int, int);
final RegisterForLogWriteNotification = DynamicLibrary.open('clfsw32.dll')
.lookupFunction<RegisterForLogWriteNotificationNative, RegisterForLogWriteNotificationDart>('RegisterForLogWriteNotification');
// hLog : HANDLE -> Pointer<Void>
// cbThreshold : DWORD -> Uint32
// fEnable : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RegisterForLogWriteNotification(
hLog: THandle; // HANDLE
cbThreshold: DWORD; // DWORD
fEnable: BOOL // BOOL
): BOOL; stdcall;
external 'clfsw32.dll' name 'RegisterForLogWriteNotification';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegisterForLogWriteNotification"
c_RegisterForLogWriteNotification :: Ptr () -> Word32 -> CInt -> IO CInt
-- hLog : HANDLE -> Ptr ()
-- cbThreshold : DWORD -> Word32
-- fEnable : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let registerforlogwritenotification =
foreign "RegisterForLogWriteNotification"
((ptr void) @-> uint32_t @-> int32_t @-> returning int32_t)
(* hLog : HANDLE -> (ptr void) *)
(* cbThreshold : DWORD -> uint32_t *)
(* fEnable : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clfsw32 (t "clfsw32.dll"))
(cffi:use-foreign-library clfsw32)
(cffi:defcfun ("RegisterForLogWriteNotification" register-for-log-write-notification :convention :stdcall) :int32
(h-log :pointer) ; HANDLE
(cb-threshold :uint32) ; DWORD
(f-enable :int32)) ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegisterForLogWriteNotification = Win32::API::More->new('clfsw32',
'BOOL RegisterForLogWriteNotification(HANDLE hLog, DWORD cbThreshold, BOOL fEnable)');
# my $ret = $RegisterForLogWriteNotification->Call($hLog, $cbThreshold, $fEnable);
# hLog : HANDLE -> HANDLE
# cbThreshold : DWORD -> DWORD
# fEnable : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。