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

MprAdminEstablishDomainRasServer

関数
ドメイン内のRASサーバー登録を有効または無効にする。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

DWORD MprAdminEstablishDomainRasServer(
    LPWSTR pszDomain,
    LPWSTR pszMachine,
    BOOL bEnable
);

パラメーター

名前方向
pszDomainLPWSTRin
pszMachineLPWSTRin
bEnableBOOLin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MprAdminEstablishDomainRasServer = ctypes.windll.mprapi.MprAdminEstablishDomainRasServer
MprAdminEstablishDomainRasServer.restype = wintypes.DWORD
MprAdminEstablishDomainRasServer.argtypes = [
    wintypes.LPCWSTR,  # pszDomain : LPWSTR
    wintypes.LPCWSTR,  # pszMachine : LPWSTR
    wintypes.BOOL,  # bEnable : BOOL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprAdminEstablishDomainRasServer = mprapi.NewProc("MprAdminEstablishDomainRasServer")
)

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