Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › NetAuditRead

NetAuditRead

関数
サーバーの監査ログから記録されたエントリを読み取る。
DLLNETAPI32.dll呼出規約winapi

シグネチャ

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

DWORD NetAuditRead(
    LPCWSTR server,
    LPCWSTR service,
    HLOG* auditloghandle,
    DWORD offset,
    DWORD* reserved1,
    DWORD reserved2,
    DWORD offsetflag,
    BYTE** bufptr,
    DWORD prefmaxlen,
    DWORD* bytesread,
    DWORD* totalavailable
);

パラメーター

名前方向
serverLPCWSTRin
serviceLPCWSTRin
auditloghandleHLOG*inout
offsetDWORDin
reserved1DWORD*inout
reserved2DWORDin
offsetflagDWORDin
bufptrBYTE**inout
prefmaxlenDWORDin
bytesreadDWORD*inout
totalavailableDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD NetAuditRead(
    LPCWSTR server,
    LPCWSTR service,
    HLOG* auditloghandle,
    DWORD offset,
    DWORD* reserved1,
    DWORD reserved2,
    DWORD offsetflag,
    BYTE** bufptr,
    DWORD prefmaxlen,
    DWORD* bytesread,
    DWORD* totalavailable
);
[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetAuditRead(
    [MarshalAs(UnmanagedType.LPWStr)] string server,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string service,   // LPCWSTR
    IntPtr auditloghandle,   // HLOG* in/out
    uint offset,   // DWORD
    ref uint reserved1,   // DWORD* in/out
    uint reserved2,   // DWORD
    uint offsetflag,   // DWORD
    IntPtr bufptr,   // BYTE** in/out
    uint prefmaxlen,   // DWORD
    ref uint bytesread,   // DWORD* in/out
    ref uint totalavailable   // DWORD* in/out
);
<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetAuditRead(
    <MarshalAs(UnmanagedType.LPWStr)> server As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> service As String,   ' LPCWSTR
    auditloghandle As IntPtr,   ' HLOG* in/out
    offset As UInteger,   ' DWORD
    ByRef reserved1 As UInteger,   ' DWORD* in/out
    reserved2 As UInteger,   ' DWORD
    offsetflag As UInteger,   ' DWORD
    bufptr As IntPtr,   ' BYTE** in/out
    prefmaxlen As UInteger,   ' DWORD
    ByRef bytesread As UInteger,   ' DWORD* in/out
    ByRef totalavailable As UInteger   ' DWORD* in/out
) As UInteger
End Function
' server : LPCWSTR
' service : LPCWSTR
' auditloghandle : HLOG* in/out
' offset : DWORD
' reserved1 : DWORD* in/out
' reserved2 : DWORD
' offsetflag : DWORD
' bufptr : BYTE** in/out
' prefmaxlen : DWORD
' bytesread : DWORD* in/out
' totalavailable : DWORD* in/out
Declare PtrSafe Function NetAuditRead Lib "netapi32" ( _
    ByVal server As LongPtr, _
    ByVal service As LongPtr, _
    ByVal auditloghandle As LongPtr, _
    ByVal offset As Long, _
    ByRef reserved1 As Long, _
    ByVal reserved2 As Long, _
    ByVal offsetflag As Long, _
    ByVal bufptr As LongPtr, _
    ByVal prefmaxlen As Long, _
    ByRef bytesread As Long, _
    ByRef totalavailable As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NetAuditRead = ctypes.windll.netapi32.NetAuditRead
NetAuditRead.restype = wintypes.DWORD
NetAuditRead.argtypes = [
    wintypes.LPCWSTR,  # server : LPCWSTR
    wintypes.LPCWSTR,  # service : LPCWSTR
    ctypes.c_void_p,  # auditloghandle : HLOG* in/out
    wintypes.DWORD,  # offset : DWORD
    ctypes.POINTER(wintypes.DWORD),  # reserved1 : DWORD* in/out
    wintypes.DWORD,  # reserved2 : DWORD
    wintypes.DWORD,  # offsetflag : DWORD
    ctypes.c_void_p,  # bufptr : BYTE** in/out
    wintypes.DWORD,  # prefmaxlen : DWORD
    ctypes.POINTER(wintypes.DWORD),  # bytesread : DWORD* in/out
    ctypes.POINTER(wintypes.DWORD),  # totalavailable : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NETAPI32.dll')
NetAuditRead = Fiddle::Function.new(
  lib['NetAuditRead'],
  [
    Fiddle::TYPE_VOIDP,  # server : LPCWSTR
    Fiddle::TYPE_VOIDP,  # service : LPCWSTR
    Fiddle::TYPE_VOIDP,  # auditloghandle : HLOG* in/out
    -Fiddle::TYPE_INT,  # offset : DWORD
    Fiddle::TYPE_VOIDP,  # reserved1 : DWORD* in/out
    -Fiddle::TYPE_INT,  # reserved2 : DWORD
    -Fiddle::TYPE_INT,  # offsetflag : DWORD
    Fiddle::TYPE_VOIDP,  # bufptr : BYTE** in/out
    -Fiddle::TYPE_INT,  # prefmaxlen : DWORD
    Fiddle::TYPE_VOIDP,  # bytesread : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # totalavailable : DWORD* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "netapi32")]
extern "system" {
    fn NetAuditRead(
        server: *const u16,  // LPCWSTR
        service: *const u16,  // LPCWSTR
        auditloghandle: *mut HLOG,  // HLOG* in/out
        offset: u32,  // DWORD
        reserved1: *mut u32,  // DWORD* in/out
        reserved2: u32,  // DWORD
        offsetflag: u32,  // DWORD
        bufptr: *mut *mut u8,  // BYTE** in/out
        prefmaxlen: u32,  // DWORD
        bytesread: *mut u32,  // DWORD* in/out
        totalavailable: *mut u32  // DWORD* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetAuditRead([MarshalAs(UnmanagedType.LPWStr)] string server, [MarshalAs(UnmanagedType.LPWStr)] string service, IntPtr auditloghandle, uint offset, ref uint reserved1, uint reserved2, uint offsetflag, IntPtr bufptr, uint prefmaxlen, ref uint bytesread, ref uint totalavailable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetAuditRead' -Namespace Win32 -PassThru
# $api::NetAuditRead(server, service, auditloghandle, offset, reserved1, reserved2, offsetflag, bufptr, prefmaxlen, bytesread, totalavailable)
#uselib "NETAPI32.dll"
#func global NetAuditRead "NetAuditRead" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; NetAuditRead server, service, varptr(auditloghandle), offset, varptr(reserved1), reserved2, offsetflag, varptr(bufptr), prefmaxlen, varptr(bytesread), varptr(totalavailable)   ; 戻り値は stat
; server : LPCWSTR -> "sptr"
; service : LPCWSTR -> "sptr"
; auditloghandle : HLOG* in/out -> "sptr"
; offset : DWORD -> "sptr"
; reserved1 : DWORD* in/out -> "sptr"
; reserved2 : DWORD -> "sptr"
; offsetflag : DWORD -> "sptr"
; bufptr : BYTE** in/out -> "sptr"
; prefmaxlen : DWORD -> "sptr"
; bytesread : DWORD* in/out -> "sptr"
; totalavailable : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "NETAPI32.dll"
#cfunc global NetAuditRead "NetAuditRead" wstr, wstr, var, int, var, int, int, var, int, var, var
; res = NetAuditRead(server, service, auditloghandle, offset, reserved1, reserved2, offsetflag, bufptr, prefmaxlen, bytesread, totalavailable)
; server : LPCWSTR -> "wstr"
; service : LPCWSTR -> "wstr"
; auditloghandle : HLOG* in/out -> "var"
; offset : DWORD -> "int"
; reserved1 : DWORD* in/out -> "var"
; reserved2 : DWORD -> "int"
; offsetflag : DWORD -> "int"
; bufptr : BYTE** in/out -> "var"
; prefmaxlen : DWORD -> "int"
; bytesread : DWORD* in/out -> "var"
; totalavailable : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD NetAuditRead(LPCWSTR server, LPCWSTR service, HLOG* auditloghandle, DWORD offset, DWORD* reserved1, DWORD reserved2, DWORD offsetflag, BYTE** bufptr, DWORD prefmaxlen, DWORD* bytesread, DWORD* totalavailable)
#uselib "NETAPI32.dll"
#cfunc global NetAuditRead "NetAuditRead" wstr, wstr, var, int, var, int, int, var, int, var, var
; res = NetAuditRead(server, service, auditloghandle, offset, reserved1, reserved2, offsetflag, bufptr, prefmaxlen, bytesread, totalavailable)
; server : LPCWSTR -> "wstr"
; service : LPCWSTR -> "wstr"
; auditloghandle : HLOG* in/out -> "var"
; offset : DWORD -> "int"
; reserved1 : DWORD* in/out -> "var"
; reserved2 : DWORD -> "int"
; offsetflag : DWORD -> "int"
; bufptr : BYTE** in/out -> "var"
; prefmaxlen : DWORD -> "int"
; bytesread : DWORD* in/out -> "var"
; totalavailable : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetAuditRead = netapi32.NewProc("NetAuditRead")
)

// server (LPCWSTR), service (LPCWSTR), auditloghandle (HLOG* in/out), offset (DWORD), reserved1 (DWORD* in/out), reserved2 (DWORD), offsetflag (DWORD), bufptr (BYTE** in/out), prefmaxlen (DWORD), bytesread (DWORD* in/out), totalavailable (DWORD* in/out)
r1, _, err := procNetAuditRead.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(server))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(service))),
	uintptr(auditloghandle),
	uintptr(offset),
	uintptr(reserved1),
	uintptr(reserved2),
	uintptr(offsetflag),
	uintptr(bufptr),
	uintptr(prefmaxlen),
	uintptr(bytesread),
	uintptr(totalavailable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function NetAuditRead(
  server: PWideChar;   // LPCWSTR
  service: PWideChar;   // LPCWSTR
  auditloghandle: Pointer;   // HLOG* in/out
  offset: DWORD;   // DWORD
  reserved1: Pointer;   // DWORD* in/out
  reserved2: DWORD;   // DWORD
  offsetflag: DWORD;   // DWORD
  bufptr: Pointer;   // BYTE** in/out
  prefmaxlen: DWORD;   // DWORD
  bytesread: Pointer;   // DWORD* in/out
  totalavailable: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetAuditRead';
result := DllCall("NETAPI32\NetAuditRead"
    , "WStr", server   ; LPCWSTR
    , "WStr", service   ; LPCWSTR
    , "Ptr", auditloghandle   ; HLOG* in/out
    , "UInt", offset   ; DWORD
    , "Ptr", reserved1   ; DWORD* in/out
    , "UInt", reserved2   ; DWORD
    , "UInt", offsetflag   ; DWORD
    , "Ptr", bufptr   ; BYTE** in/out
    , "UInt", prefmaxlen   ; DWORD
    , "Ptr", bytesread   ; DWORD* in/out
    , "Ptr", totalavailable   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●NetAuditRead(server, service, auditloghandle, offset, reserved1, reserved2, offsetflag, bufptr, prefmaxlen, bytesread, totalavailable) = DLL("NETAPI32.dll", "dword NetAuditRead(char*, char*, void*, dword, void*, dword, dword, void*, dword, void*, void*)")
# 呼び出し: NetAuditRead(server, service, auditloghandle, offset, reserved1, reserved2, offsetflag, bufptr, prefmaxlen, bytesread, totalavailable)
# server : LPCWSTR -> "char*"
# service : LPCWSTR -> "char*"
# auditloghandle : HLOG* in/out -> "void*"
# offset : DWORD -> "dword"
# reserved1 : DWORD* in/out -> "void*"
# reserved2 : DWORD -> "dword"
# offsetflag : DWORD -> "dword"
# bufptr : BYTE** in/out -> "void*"
# prefmaxlen : DWORD -> "dword"
# bytesread : DWORD* in/out -> "void*"
# totalavailable : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。