ホーム › NetworkManagement.NetManagement › NetServerComputerNameDel
NetServerComputerNameDel
関数サーバーからエミュレートするコンピューター名を削除する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetServerComputerNameDel(
LPWSTR ServerName, // optional
LPWSTR EmulatedServerName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerName | LPWSTR | inoptional | 関数を実行するリモートサーバーの DNS 名または NetBIOS 名を指定する文字列へのポインター。このパラメーターが NULL の場合、ローカルコンピューターが使用されます。 |
| EmulatedServerName | LPWSTR | in | サーバーがサポートを停止すべきエミュレート名を含む、null で終わる文字列へのポインター。サーバーは、サポートしていた他のすべてのサーバー名のサポートを継続します。 |
戻り値の型: DWORD
公式ドキュメント
NetServerComputerNameDel 関数は、以前の NetServerComputerNameAdd 関数の呼び出しによって設定されたエミュレートされたサーバー名のサポートを、指定したサーバーに停止させます。この関数は、エミュレートされた名前からネットワークトランスポートのバインドを解除することでこれを行います。
戻り値
関数が成功した場合、戻り値は NERR_Success です。
関数が失敗した場合、戻り値は次のいずれかのエラーコードになります。
| 戻り値 | 説明 |
|---|---|
| ユーザーに、要求された情報へのアクセス権がありません。 | |
| 指定したパラメーターが無効です。 | |
| 使用可能なメモリが不足しています。 | |
|
共有名が存在しません。 |
解説(Remarks)
Administrators または Server Operators ローカルグループのメンバーのみが、 NetServerComputerNameDel 関数を正常に実行できます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetServerComputerNameDel(
LPWSTR ServerName, // optional
LPWSTR EmulatedServerName
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetServerComputerNameDel(
[MarshalAs(UnmanagedType.LPWStr)] string ServerName, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string EmulatedServerName // LPWSTR
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetServerComputerNameDel(
<MarshalAs(UnmanagedType.LPWStr)> ServerName As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> EmulatedServerName As String ' LPWSTR
) As UInteger
End Function' ServerName : LPWSTR optional
' EmulatedServerName : LPWSTR
Declare PtrSafe Function NetServerComputerNameDel Lib "netapi32" ( _
ByVal ServerName As LongPtr, _
ByVal EmulatedServerName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetServerComputerNameDel = ctypes.windll.netapi32.NetServerComputerNameDel
NetServerComputerNameDel.restype = wintypes.DWORD
NetServerComputerNameDel.argtypes = [
wintypes.LPCWSTR, # ServerName : LPWSTR optional
wintypes.LPCWSTR, # EmulatedServerName : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetServerComputerNameDel = Fiddle::Function.new(
lib['NetServerComputerNameDel'],
[
Fiddle::TYPE_VOIDP, # ServerName : LPWSTR optional
Fiddle::TYPE_VOIDP, # EmulatedServerName : LPWSTR
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetServerComputerNameDel(
ServerName: *mut u16, // LPWSTR optional
EmulatedServerName: *mut u16 // LPWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetServerComputerNameDel([MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string EmulatedServerName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetServerComputerNameDel' -Namespace Win32 -PassThru
# $api::NetServerComputerNameDel(ServerName, EmulatedServerName)#uselib "NETAPI32.dll"
#func global NetServerComputerNameDel "NetServerComputerNameDel" sptr, sptr
; NetServerComputerNameDel ServerName, EmulatedServerName ; 戻り値は stat
; ServerName : LPWSTR optional -> "sptr"
; EmulatedServerName : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "NETAPI32.dll"
#cfunc global NetServerComputerNameDel "NetServerComputerNameDel" wstr, wstr
; res = NetServerComputerNameDel(ServerName, EmulatedServerName)
; ServerName : LPWSTR optional -> "wstr"
; EmulatedServerName : LPWSTR -> "wstr"; DWORD NetServerComputerNameDel(LPWSTR ServerName, LPWSTR EmulatedServerName)
#uselib "NETAPI32.dll"
#cfunc global NetServerComputerNameDel "NetServerComputerNameDel" wstr, wstr
; res = NetServerComputerNameDel(ServerName, EmulatedServerName)
; ServerName : LPWSTR optional -> "wstr"
; EmulatedServerName : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetServerComputerNameDel = netapi32.NewProc("NetServerComputerNameDel")
)
// ServerName (LPWSTR optional), EmulatedServerName (LPWSTR)
r1, _, err := procNetServerComputerNameDel.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(EmulatedServerName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetServerComputerNameDel(
ServerName: PWideChar; // LPWSTR optional
EmulatedServerName: PWideChar // LPWSTR
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetServerComputerNameDel';result := DllCall("NETAPI32\NetServerComputerNameDel"
, "WStr", ServerName ; LPWSTR optional
, "WStr", EmulatedServerName ; LPWSTR
, "UInt") ; return: DWORD●NetServerComputerNameDel(ServerName, EmulatedServerName) = DLL("NETAPI32.dll", "dword NetServerComputerNameDel(char*, char*)")
# 呼び出し: NetServerComputerNameDel(ServerName, EmulatedServerName)
# ServerName : LPWSTR optional -> "char*"
# EmulatedServerName : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "netapi32" fn NetServerComputerNameDel(
ServerName: [*c]const u16, // LPWSTR optional
EmulatedServerName: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) u32;proc NetServerComputerNameDel(
ServerName: WideCString, # LPWSTR optional
EmulatedServerName: WideCString # LPWSTR
): uint32 {.importc: "NetServerComputerNameDel", stdcall, dynlib: "NETAPI32.dll".}pragma(lib, "netapi32");
extern(Windows)
uint NetServerComputerNameDel(
const(wchar)* ServerName, // LPWSTR optional
const(wchar)* EmulatedServerName // LPWSTR
);ccall((:NetServerComputerNameDel, "NETAPI32.dll"), stdcall, UInt32,
(Cwstring, Cwstring),
ServerName, EmulatedServerName)
# ServerName : LPWSTR optional -> Cwstring
# EmulatedServerName : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t NetServerComputerNameDel(
const uint16_t* ServerName,
const uint16_t* EmulatedServerName);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetServerComputerNameDel(ServerName, EmulatedServerName)
-- ServerName : LPWSTR optional
-- EmulatedServerName : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetServerComputerNameDel = lib.func('__stdcall', 'NetServerComputerNameDel', 'uint32_t', ['str16', 'str16']);
// NetServerComputerNameDel(ServerName, EmulatedServerName)
// ServerName : LPWSTR optional -> 'str16'
// EmulatedServerName : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("NETAPI32.dll", {
NetServerComputerNameDel: { parameters: ["buffer", "buffer"], result: "u32" },
});
// lib.symbols.NetServerComputerNameDel(ServerName, EmulatedServerName)
// ServerName : LPWSTR optional -> "buffer"
// EmulatedServerName : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t NetServerComputerNameDel(
const uint16_t* ServerName,
const uint16_t* EmulatedServerName);
C, "NETAPI32.dll");
// $ffi->NetServerComputerNameDel(ServerName, EmulatedServerName);
// ServerName : LPWSTR optional
// EmulatedServerName : LPWSTR
// 構造体/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 NetServerComputerNameDel(
WString ServerName, // LPWSTR optional
WString EmulatedServerName // LPWSTR
);
}@[Link("netapi32")]
lib LibNETAPI32
fun NetServerComputerNameDel = NetServerComputerNameDel(
ServerName : UInt16*, # LPWSTR optional
EmulatedServerName : UInt16* # LPWSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NetServerComputerNameDelNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>);
typedef NetServerComputerNameDelDart = int Function(Pointer<Utf16>, Pointer<Utf16>);
final NetServerComputerNameDel = DynamicLibrary.open('NETAPI32.dll')
.lookupFunction<NetServerComputerNameDelNative, NetServerComputerNameDelDart>('NetServerComputerNameDel');
// ServerName : LPWSTR optional -> Pointer<Utf16>
// EmulatedServerName : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NetServerComputerNameDel(
ServerName: PWideChar; // LPWSTR optional
EmulatedServerName: PWideChar // LPWSTR
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetServerComputerNameDel';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NetServerComputerNameDel"
c_NetServerComputerNameDel :: CWString -> CWString -> IO Word32
-- ServerName : LPWSTR optional -> CWString
-- EmulatedServerName : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let netservercomputernamedel =
foreign "NetServerComputerNameDel"
((ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* ServerName : LPWSTR optional -> (ptr uint16_t) *)
(* EmulatedServerName : LPWSTR -> (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 ("NetServerComputerNameDel" net-server-computer-name-del :convention :stdcall) :uint32
(server-name (:string :encoding :utf-16le)) ; LPWSTR optional
(emulated-server-name (:string :encoding :utf-16le))) ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NetServerComputerNameDel = Win32::API::More->new('NETAPI32',
'DWORD NetServerComputerNameDel(LPCWSTR ServerName, LPCWSTR EmulatedServerName)');
# my $ret = $NetServerComputerNameDel->Call($ServerName, $EmulatedServerName);
# ServerName : LPWSTR optional -> LPCWSTR
# EmulatedServerName : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f NetServerComputerNameAdd — サーバーにエミュレートするコンピューター名を追加する。
- f NetServerTransportAdd — サーバーをトランスポートプロトコルにバインドする。
- f NetServerTransportAddEx — 拡張情報を指定してサーバーをトランスポートにバインドする。
- f NetServerTransportEnum — サーバーがバインドされているトランスポートを列挙する。