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

NetAuditClear

関数
サーバーの監査ログをクリアし任意でバックアップ保存する。
DLLNETAPI32.dll呼出規約winapi

シグネチャ

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

DWORD NetAuditClear(
    LPCWSTR server,
    LPCWSTR backupfile,
    LPCWSTR service
);

パラメーター

名前方向
serverLPCWSTRin
backupfileLPCWSTRin
serviceLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD NetAuditClear(
    LPCWSTR server,
    LPCWSTR backupfile,
    LPCWSTR service
);
[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetAuditClear(
    [MarshalAs(UnmanagedType.LPWStr)] string server,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string backupfile,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string service   // LPCWSTR
);
<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetAuditClear(
    <MarshalAs(UnmanagedType.LPWStr)> server As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> backupfile As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> service As String   ' LPCWSTR
) As UInteger
End Function
' server : LPCWSTR
' backupfile : LPCWSTR
' service : LPCWSTR
Declare PtrSafe Function NetAuditClear Lib "netapi32" ( _
    ByVal server As LongPtr, _
    ByVal backupfile As LongPtr, _
    ByVal service As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NetAuditClear = ctypes.windll.netapi32.NetAuditClear
NetAuditClear.restype = wintypes.DWORD
NetAuditClear.argtypes = [
    wintypes.LPCWSTR,  # server : LPCWSTR
    wintypes.LPCWSTR,  # backupfile : LPCWSTR
    wintypes.LPCWSTR,  # service : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('NETAPI32.dll')
NetAuditClear = Fiddle::Function.new(
  lib['NetAuditClear'],
  [
    Fiddle::TYPE_VOIDP,  # server : LPCWSTR
    Fiddle::TYPE_VOIDP,  # backupfile : LPCWSTR
    Fiddle::TYPE_VOIDP,  # service : LPCWSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "netapi32")]
extern "system" {
    fn NetAuditClear(
        server: *const u16,  // LPCWSTR
        backupfile: *const u16,  // LPCWSTR
        service: *const u16  // LPCWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetAuditClear([MarshalAs(UnmanagedType.LPWStr)] string server, [MarshalAs(UnmanagedType.LPWStr)] string backupfile, [MarshalAs(UnmanagedType.LPWStr)] string service);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetAuditClear' -Namespace Win32 -PassThru
# $api::NetAuditClear(server, backupfile, service)
#uselib "NETAPI32.dll"
#func global NetAuditClear "NetAuditClear" sptr, sptr, sptr
; NetAuditClear server, backupfile, service   ; 戻り値は stat
; server : LPCWSTR -> "sptr"
; backupfile : LPCWSTR -> "sptr"
; service : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "NETAPI32.dll"
#cfunc global NetAuditClear "NetAuditClear" wstr, wstr, wstr
; res = NetAuditClear(server, backupfile, service)
; server : LPCWSTR -> "wstr"
; backupfile : LPCWSTR -> "wstr"
; service : LPCWSTR -> "wstr"
; DWORD NetAuditClear(LPCWSTR server, LPCWSTR backupfile, LPCWSTR service)
#uselib "NETAPI32.dll"
#cfunc global NetAuditClear "NetAuditClear" wstr, wstr, wstr
; res = NetAuditClear(server, backupfile, service)
; server : LPCWSTR -> "wstr"
; backupfile : LPCWSTR -> "wstr"
; service : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetAuditClear = netapi32.NewProc("NetAuditClear")
)

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