ホーム › NetworkManagement.NetManagement › NetRemoveServiceAccount
NetRemoveServiceAccount
関数管理されたサービスアカウントを削除する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
NTSTATUS NetRemoveServiceAccount(
LPWSTR ServerName, // optional
LPWSTR AccountName,
DWORD Flags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerName | LPWSTR | inoptional |
| AccountName | LPWSTR | in |
| Flags | DWORD | in |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
NTSTATUS NetRemoveServiceAccount(
LPWSTR ServerName, // optional
LPWSTR AccountName,
DWORD Flags
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern int NetRemoveServiceAccount(
[MarshalAs(UnmanagedType.LPWStr)] string ServerName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string AccountName, // LPWSTR
uint Flags // DWORD
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetRemoveServiceAccount(
<MarshalAs(UnmanagedType.LPWStr)> ServerName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> AccountName As String, ' LPWSTR
Flags As UInteger ' DWORD
) As Integer
End Function' ServerName : LPWSTR optional
' AccountName : LPWSTR
' Flags : DWORD
Declare PtrSafe Function NetRemoveServiceAccount Lib "netapi32" ( _
ByVal ServerName As LongPtr, _
ByVal AccountName As LongPtr, _
ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetRemoveServiceAccount = ctypes.windll.netapi32.NetRemoveServiceAccount
NetRemoveServiceAccount.restype = ctypes.c_int
NetRemoveServiceAccount.argtypes = [
wintypes.LPCWSTR, # ServerName : LPWSTR optional
wintypes.LPCWSTR, # AccountName : LPWSTR
wintypes.DWORD, # Flags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetRemoveServiceAccount = Fiddle::Function.new(
lib['NetRemoveServiceAccount'],
[
Fiddle::TYPE_VOIDP, # ServerName : LPWSTR optional
Fiddle::TYPE_VOIDP, # AccountName : LPWSTR
-Fiddle::TYPE_INT, # Flags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetRemoveServiceAccount(
ServerName: *mut u16, // LPWSTR optional
AccountName: *mut u16, // LPWSTR
Flags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern int NetRemoveServiceAccount([MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string AccountName, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetRemoveServiceAccount' -Namespace Win32 -PassThru
# $api::NetRemoveServiceAccount(ServerName, AccountName, Flags)#uselib "NETAPI32.dll"
#func global NetRemoveServiceAccount "NetRemoveServiceAccount" sptr, sptr, sptr
; NetRemoveServiceAccount ServerName, AccountName, Flags ; 戻り値は stat
; ServerName : LPWSTR optional -> "sptr"
; AccountName : LPWSTR -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NETAPI32.dll"
#cfunc global NetRemoveServiceAccount "NetRemoveServiceAccount" wstr, wstr, int
; res = NetRemoveServiceAccount(ServerName, AccountName, Flags)
; ServerName : LPWSTR optional -> "wstr"
; AccountName : LPWSTR -> "wstr"
; Flags : DWORD -> "int"; NTSTATUS NetRemoveServiceAccount(LPWSTR ServerName, LPWSTR AccountName, DWORD Flags)
#uselib "NETAPI32.dll"
#cfunc global NetRemoveServiceAccount "NetRemoveServiceAccount" wstr, wstr, int
; res = NetRemoveServiceAccount(ServerName, AccountName, Flags)
; ServerName : LPWSTR optional -> "wstr"
; AccountName : LPWSTR -> "wstr"
; Flags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetRemoveServiceAccount = netapi32.NewProc("NetRemoveServiceAccount")
)
// ServerName (LPWSTR optional), AccountName (LPWSTR), Flags (DWORD)
r1, _, err := procNetRemoveServiceAccount.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(AccountName))),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction NetRemoveServiceAccount(
ServerName: PWideChar; // LPWSTR optional
AccountName: PWideChar; // LPWSTR
Flags: DWORD // DWORD
): Integer; stdcall;
external 'NETAPI32.dll' name 'NetRemoveServiceAccount';result := DllCall("NETAPI32\NetRemoveServiceAccount"
, "WStr", ServerName ; LPWSTR optional
, "WStr", AccountName ; LPWSTR
, "UInt", Flags ; DWORD
, "Int") ; return: NTSTATUS●NetRemoveServiceAccount(ServerName, AccountName, Flags) = DLL("NETAPI32.dll", "int NetRemoveServiceAccount(char*, char*, dword)")
# 呼び出し: NetRemoveServiceAccount(ServerName, AccountName, Flags)
# ServerName : LPWSTR optional -> "char*"
# AccountName : LPWSTR -> "char*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。