ホーム › NetworkManagement.NetManagement › NetAuditClear
NetAuditClear
関数サーバーの監査ログをクリアし任意でバックアップ保存する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetAuditClear(
LPCWSTR server,
LPCWSTR backupfile,
LPCWSTR service
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| server | LPCWSTR | in | 対象サーバーのUNC名。NULLでローカルコンピューターを対象とする。 |
| backupfile | LPCWSTR | in | クリア前に監査ログを退避するバックアップファイルのパス。NULL可。 |
| service | LPCWSTR | in | 予約済み。NULLを指定する必要がある。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "netapi32" fn NetAuditClear(
server: [*c]const u16, // LPCWSTR
backupfile: [*c]const u16, // LPCWSTR
service: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;proc NetAuditClear(
server: WideCString, # LPCWSTR
backupfile: WideCString, # LPCWSTR
service: WideCString # LPCWSTR
): uint32 {.importc: "NetAuditClear", stdcall, dynlib: "NETAPI32.dll".}pragma(lib, "netapi32");
extern(Windows)
uint NetAuditClear(
const(wchar)* server, // LPCWSTR
const(wchar)* backupfile, // LPCWSTR
const(wchar)* service // LPCWSTR
);ccall((:NetAuditClear, "NETAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Cwstring),
server, backupfile, service)
# server : LPCWSTR -> Cwstring
# backupfile : LPCWSTR -> Cwstring
# service : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NetAuditClear(
const uint16_t* server,
const uint16_t* backupfile,
const uint16_t* service);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetAuditClear(server, backupfile, service)
-- server : LPCWSTR
-- backupfile : LPCWSTR
-- service : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetAuditClear = lib.func('__stdcall', 'NetAuditClear', 'uint32_t', ['str16', 'str16', 'str16']);
// NetAuditClear(server, backupfile, service)
// server : LPCWSTR -> 'str16'
// backupfile : LPCWSTR -> 'str16'
// service : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NETAPI32.dll", {
NetAuditClear: { parameters: ["buffer", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.NetAuditClear(server, backupfile, service)
// server : LPCWSTR -> "buffer"
// backupfile : LPCWSTR -> "buffer"
// service : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NetAuditClear(
const uint16_t* server,
const uint16_t* backupfile,
const uint16_t* service);
C, "NETAPI32.dll");
// $ffi->NetAuditClear(server, backupfile, service);
// server : LPCWSTR
// backupfile : LPCWSTR
// service : LPCWSTR
// 構造体/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 Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = Native.load("netapi32", Netapi32.class);
int NetAuditClear(
WString server, // LPCWSTR
WString backupfile, // LPCWSTR
WString service // LPCWSTR
);
}@[Link("netapi32")]
lib LibNETAPI32
fun NetAuditClear = NetAuditClear(
server : UInt16*, # LPCWSTR
backupfile : UInt16*, # LPCWSTR
service : UInt16* # LPCWSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NetAuditClearNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef NetAuditClearDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final NetAuditClear = DynamicLibrary.open('NETAPI32.dll')
.lookupFunction<NetAuditClearNative, NetAuditClearDart>('NetAuditClear');
// server : LPCWSTR -> Pointer<Utf16>
// backupfile : LPCWSTR -> Pointer<Utf16>
// service : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NetAuditClear(
server: PWideChar; // LPCWSTR
backupfile: PWideChar; // LPCWSTR
service: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetAuditClear';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NetAuditClear"
c_NetAuditClear :: CWString -> CWString -> CWString -> IO Word32
-- server : LPCWSTR -> CWString
-- backupfile : LPCWSTR -> CWString
-- service : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let netauditclear =
foreign "NetAuditClear"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* server : LPCWSTR -> (ptr uint16_t) *)
(* backupfile : LPCWSTR -> (ptr uint16_t) *)
(* service : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)
(cffi:defcfun ("NetAuditClear" net-audit-clear :convention :stdcall) :uint32
(server (:string :encoding :utf-16le)) ; LPCWSTR
(backupfile (:string :encoding :utf-16le)) ; LPCWSTR
(service (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NetAuditClear = Win32::API::More->new('NETAPI32',
'DWORD NetAuditClear(LPCWSTR server, LPCWSTR backupfile, LPCWSTR service)');
# my $ret = $NetAuditClear->Call($server, $backupfile, $service);
# server : LPCWSTR -> LPCWSTR
# backupfile : LPCWSTR -> LPCWSTR
# service : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。