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問い合わせ先のリモートサーバー名を指定する定数文字列へのポインターです。このパラメーターが NULL の場合、ローカルコンピューターが使用されます。
OptionsWantedNET_REMOTE_COMPUTER_SUPPORTS_OPTIONSin

対象とする機能を示すビットフラグのセットを格納する値を指定します。このパラメーターには、次のいずれかの値を少なくとも 1 つ指定する必要があります。

意味
SUPPORTS_REMOTE_ADMIN_PROTOCOL
Remote Administration Protocol のサポートを要求します。
SUPPORTS_RPC
RPC のサポートを要求します。
SUPPORTS_SAM_PROTOCOL
Security Account Manager (SAM) のサポートを要求します。
SUPPORTS_UNICODE
Unicode 標準のサポートを要求します。
SUPPORTS_LOCAL
この表に挙げた最初の 3 つの値のサポートを要求します。呼び出し側アプリケーションで UNICODE が定義されている場合は、前述の 4 つの機能を要求します。
OptionsSupportedDWORD*inout

ビットフラグのセットを受け取る値へのポインターです。これらのフラグは、OptionsWanted パラメーターで指定された機能のうち、UncServerName パラメーターで指定されたコンピューター上で実装されているものを示します (それ以外のビットはすべてゼロに設定されます)。

このパラメーターの値は、 NetRemoteComputerSupports 関数が NERR_Success を返した場合にのみ有効です。

戻り値の型: DWORD

公式ドキュメント

NetRemoteComputerSupports 関数は、リダイレクターに問い合わせて、リモートシステムがサポートするオプション機能を取得します。

戻り値

関数が成功した場合、戻り値は NERR_Success です。

関数が失敗した場合、戻り値は次のいずれかのエラーコードになります。

戻り値 説明
ERROR_INVALID_PARAMETER
OptionsWanted パラメーターまたは OptionsSupported パラメーターが NULL です。これらのパラメーターは両方とも必須です。
ERROR_NOT_ENOUGH_MEMORY
使用可能なメモリが不足しています。

解説(Remarks)

NetRemoteComputerSupports 関数を正常に実行するために、特別なグループメンバーシップは必要ありません。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// 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)。
const std = @import("std");

extern "netapi32" fn NetRemoteComputerSupports(
    UncServerName: [*c]const u16, // LPCWSTR
    OptionsWanted: u32, // NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
    OptionsSupported: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;
proc NetRemoteComputerSupports(
    UncServerName: WideCString,  # LPCWSTR
    OptionsWanted: uint32,  # NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
    OptionsSupported: ptr uint32  # DWORD* in/out
): uint32 {.importc: "NetRemoteComputerSupports", stdcall, dynlib: "NETAPI32.dll".}
pragma(lib, "netapi32");
extern(Windows)
uint NetRemoteComputerSupports(
    const(wchar)* UncServerName,   // LPCWSTR
    uint OptionsWanted,   // NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
    uint* OptionsSupported   // DWORD* in/out
);
ccall((:NetRemoteComputerSupports, "NETAPI32.dll"), stdcall, UInt32,
      (Cwstring, UInt32, Ptr{UInt32}),
      UncServerName, OptionsWanted, OptionsSupported)
# UncServerName : LPCWSTR -> Cwstring
# OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> UInt32
# OptionsSupported : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t NetRemoteComputerSupports(
    const uint16_t* UncServerName,
    uint32_t OptionsWanted,
    uint32_t* OptionsSupported);
]]
local netapi32 = ffi.load("netapi32")
-- netapi32.NetRemoteComputerSupports(UncServerName, OptionsWanted, OptionsSupported)
-- UncServerName : LPCWSTR
-- OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
-- OptionsSupported : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('NETAPI32.dll');
const NetRemoteComputerSupports = lib.func('__stdcall', 'NetRemoteComputerSupports', 'uint32_t', ['str16', 'uint32_t', 'uint32_t *']);
// NetRemoteComputerSupports(UncServerName, OptionsWanted, OptionsSupported)
// UncServerName : LPCWSTR -> 'str16'
// OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> 'uint32_t'
// OptionsSupported : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("NETAPI32.dll", {
  NetRemoteComputerSupports: { parameters: ["buffer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.NetRemoteComputerSupports(UncServerName, OptionsWanted, OptionsSupported)
// UncServerName : LPCWSTR -> "buffer"
// OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> "u32"
// OptionsSupported : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t NetRemoteComputerSupports(
    const uint16_t* UncServerName,
    uint32_t OptionsWanted,
    uint32_t* OptionsSupported);
C, "NETAPI32.dll");
// $ffi->NetRemoteComputerSupports(UncServerName, OptionsWanted, OptionsSupported);
// UncServerName : LPCWSTR
// OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
// OptionsSupported : DWORD* in/out
// 構造体/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 NetRemoteComputerSupports(
        WString UncServerName,   // LPCWSTR
        int OptionsWanted,   // NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
        IntByReference OptionsSupported   // DWORD* in/out
    );
}
@[Link("netapi32")]
lib LibNETAPI32
  fun NetRemoteComputerSupports = NetRemoteComputerSupports(
    UncServerName : UInt16*,   # LPCWSTR
    OptionsWanted : UInt32,   # NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
    OptionsSupported : UInt32*   # DWORD* in/out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef NetRemoteComputerSupportsNative = Uint32 Function(Pointer<Utf16>, Uint32, Pointer<Uint32>);
typedef NetRemoteComputerSupportsDart = int Function(Pointer<Utf16>, int, Pointer<Uint32>);
final NetRemoteComputerSupports = DynamicLibrary.open('NETAPI32.dll')
    .lookupFunction<NetRemoteComputerSupportsNative, NetRemoteComputerSupportsDart>('NetRemoteComputerSupports');
// UncServerName : LPCWSTR -> Pointer<Utf16>
// OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> Uint32
// OptionsSupported : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function NetRemoteComputerSupports(
  UncServerName: PWideChar;   // LPCWSTR
  OptionsWanted: DWORD;   // NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
  OptionsSupported: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'NETAPI32.dll' name 'NetRemoteComputerSupports';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "NetRemoteComputerSupports"
  c_NetRemoteComputerSupports :: CWString -> Word32 -> Ptr Word32 -> IO Word32
-- UncServerName : LPCWSTR -> CWString
-- OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> Word32
-- OptionsSupported : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let netremotecomputersupports =
  foreign "NetRemoteComputerSupports"
    ((ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> returning uint32_t)
(* UncServerName : LPCWSTR -> (ptr uint16_t) *)
(* OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> uint32_t *)
(* OptionsSupported : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library netapi32 (t "NETAPI32.dll"))
(cffi:use-foreign-library netapi32)

(cffi:defcfun ("NetRemoteComputerSupports" net-remote-computer-supports :convention :stdcall) :uint32
  (unc-server-name (:string :encoding :utf-16le))   ; LPCWSTR
  (options-wanted :uint32)   ; NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS
  (options-supported :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $NetRemoteComputerSupports = Win32::API::More->new('NETAPI32',
    'DWORD NetRemoteComputerSupports(LPCWSTR UncServerName, DWORD OptionsWanted, LPVOID OptionsSupported)');
# my $ret = $NetRemoteComputerSupports->Call($UncServerName, $OptionsWanted, $OptionsSupported);
# UncServerName : LPCWSTR -> LPCWSTR
# OptionsWanted : NET_REMOTE_COMPUTER_SUPPORTS_OPTIONS -> DWORD
# OptionsSupported : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型