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

MprAdminIsDomainRasServer

関数
指定マシンがドメインのRASサーバーかどうかを判定する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

DWORD MprAdminIsDomainRasServer(
    LPWSTR pszDomain,
    LPWSTR pszMachine,
    BOOL* pbIsRasServer
);

パラメーター

名前方向説明
pszDomainLPWSTRin確認対象のドメイン名の文字列。
pszMachineLPWSTRin確認対象のマシン名の文字列。
pbIsRasServerBOOL*out当該マシンがドメインのRASサーバーとして登録済みかを受け取るBOOL変数へのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprAdminIsDomainRasServer(
    LPWSTR pszDomain,
    LPWSTR pszMachine,
    BOOL* pbIsRasServer
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprAdminIsDomainRasServer(
    [MarshalAs(UnmanagedType.LPWStr)] string pszDomain,   // LPWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszMachine,   // LPWSTR
    out bool pbIsRasServer   // BOOL* out
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprAdminIsDomainRasServer(
    <MarshalAs(UnmanagedType.LPWStr)> pszDomain As String,   ' LPWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszMachine As String,   ' LPWSTR
    <Out> ByRef pbIsRasServer As Boolean   ' BOOL* out
) As UInteger
End Function
' pszDomain : LPWSTR
' pszMachine : LPWSTR
' pbIsRasServer : BOOL* out
Declare PtrSafe Function MprAdminIsDomainRasServer Lib "mprapi" ( _
    ByVal pszDomain As LongPtr, _
    ByVal pszMachine As LongPtr, _
    ByRef pbIsRasServer As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprAdminIsDomainRasServer = ctypes.windll.mprapi.MprAdminIsDomainRasServer
MprAdminIsDomainRasServer.restype = wintypes.DWORD
MprAdminIsDomainRasServer.argtypes = [
    wintypes.LPCWSTR,  # pszDomain : LPWSTR
    wintypes.LPCWSTR,  # pszMachine : LPWSTR
    ctypes.c_void_p,  # pbIsRasServer : BOOL* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprAdminIsDomainRasServer = mprapi.NewProc("MprAdminIsDomainRasServer")
)

// pszDomain (LPWSTR), pszMachine (LPWSTR), pbIsRasServer (BOOL* out)
r1, _, err := procMprAdminIsDomainRasServer.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDomain))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMachine))),
	uintptr(pbIsRasServer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MprAdminIsDomainRasServer(
  pszDomain: PWideChar;   // LPWSTR
  pszMachine: PWideChar;   // LPWSTR
  pbIsRasServer: Pointer   // BOOL* out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprAdminIsDomainRasServer';
result := DllCall("MPRAPI\MprAdminIsDomainRasServer"
    , "WStr", pszDomain   ; LPWSTR
    , "WStr", pszMachine   ; LPWSTR
    , "Ptr", pbIsRasServer   ; BOOL* out
    , "UInt")   ; return: DWORD
●MprAdminIsDomainRasServer(pszDomain, pszMachine, pbIsRasServer) = DLL("MPRAPI.dll", "dword MprAdminIsDomainRasServer(char*, char*, void*)")
# 呼び出し: MprAdminIsDomainRasServer(pszDomain, pszMachine, pbIsRasServer)
# pszDomain : LPWSTR -> "char*"
# pszMachine : LPWSTR -> "char*"
# pbIsRasServer : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef MprAdminIsDomainRasServerNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Int32>);
typedef MprAdminIsDomainRasServerDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Int32>);
final MprAdminIsDomainRasServer = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprAdminIsDomainRasServerNative, MprAdminIsDomainRasServerDart>('MprAdminIsDomainRasServer');
// pszDomain : LPWSTR -> Pointer<Utf16>
// pszMachine : LPWSTR -> Pointer<Utf16>
// pbIsRasServer : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprAdminIsDomainRasServer(
  pszDomain: PWideChar;   // LPWSTR
  pszMachine: PWideChar;   // LPWSTR
  pbIsRasServer: Pointer   // BOOL* out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprAdminIsDomainRasServer';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MprAdminIsDomainRasServer"
  c_MprAdminIsDomainRasServer :: CWString -> CWString -> Ptr CInt -> IO Word32
-- pszDomain : LPWSTR -> CWString
-- pszMachine : LPWSTR -> CWString
-- pbIsRasServer : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mpradminisdomainrasserver =
  foreign "MprAdminIsDomainRasServer"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr int32_t) @-> returning uint32_t)
(* pszDomain : LPWSTR -> (ptr uint16_t) *)
(* pszMachine : LPWSTR -> (ptr uint16_t) *)
(* pbIsRasServer : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)

(cffi:defcfun ("MprAdminIsDomainRasServer" mpr-admin-is-domain-ras-server :convention :stdcall) :uint32
  (psz-domain (:string :encoding :utf-16le))   ; LPWSTR
  (psz-machine (:string :encoding :utf-16le))   ; LPWSTR
  (pb-is-ras-server :pointer))   ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprAdminIsDomainRasServer = Win32::API::More->new('MPRAPI',
    'DWORD MprAdminIsDomainRasServer(LPCWSTR pszDomain, LPCWSTR pszMachine, LPVOID pbIsRasServer)');
# my $ret = $MprAdminIsDomainRasServer->Call($pszDomain, $pszMachine, $pbIsRasServer);
# pszDomain : LPWSTR -> LPCWSTR
# pszMachine : LPWSTR -> LPCWSTR
# pbIsRasServer : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。