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

NetRemoteComputerSupports

関数
リモートコンピューターが対応する機能を問い合わせる。
DLLNETAPI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD NetRemoteComputerSupports(
    LPCWSTR UncServerName,
    NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS OptionsWanted,
    DWORD* OptionsSupported
);

パラメーター

名前方向
UncServerNameLPCWSTRin
OptionsWantedNET_REMOTE_COMPUTER_SUPPORTS_OPTIONSin
OptionsSupportedDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

NetRemoteComputerSupports = ctypes.windll.netapi32.NetRemoteComputerSupports
NetRemoteComputerSupports.restype = wintypes.DWORD
NetRemoteComputerSupports.argtypes = [
    wintypes.LPCWSTR,  # UncServerName : LPCWSTR
    wintypes.DWORD,  # OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
    ctypes.POINTER(wintypes.DWORD),  # OptionsSupported : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
	procNetRemoteComputerSupports = netapi32.NewProc("NetRemoteComputerSupports")
)

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