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

MprConfigServerConnect

関数
ルーター構成サーバーへ接続しハンドルを取得する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprConfigServerConnect(
    LPWSTR lpwsServerName,   // optional
    HANDLE* phMprConfig
);

パラメーター

名前方向説明
lpwsServerNameLPWSTRinoptional構成を操作する対象サーバー名を指すUnicode文字列。ローカルはNULL可。
phMprConfigHANDLE*out確立された構成ハンドルを受け取るポインタ。MprConfigServerDisconnectで解放する。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MprConfigServerConnect = ctypes.windll.mprapi.MprConfigServerConnect
MprConfigServerConnect.restype = wintypes.DWORD
MprConfigServerConnect.argtypes = [
    wintypes.LPCWSTR,  # lpwsServerName : LPWSTR optional
    ctypes.c_void_p,  # phMprConfig : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprConfigServerConnect = mprapi.NewProc("MprConfigServerConnect")
)

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

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

typedef MprConfigServerConnectNative = Uint32 Function(Pointer<Utf16>, Pointer<Void>);
typedef MprConfigServerConnectDart = int Function(Pointer<Utf16>, Pointer<Void>);
final MprConfigServerConnect = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprConfigServerConnectNative, MprConfigServerConnectDart>('MprConfigServerConnect');
// lpwsServerName : LPWSTR optional -> Pointer<Utf16>
// phMprConfig : HANDLE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprConfigServerConnect(
  lpwsServerName: PWideChar;   // LPWSTR optional
  phMprConfig: Pointer   // HANDLE* out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprConfigServerConnect';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MprConfigServerConnect"
  c_MprConfigServerConnect :: CWString -> Ptr () -> IO Word32
-- lpwsServerName : LPWSTR optional -> CWString
-- phMprConfig : HANDLE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mprconfigserverconnect =
  foreign "MprConfigServerConnect"
    ((ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* lpwsServerName : LPWSTR optional -> (ptr uint16_t) *)
(* phMprConfig : HANDLE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)

(cffi:defcfun ("MprConfigServerConnect" mpr-config-server-connect :convention :stdcall) :uint32
  (lpws-server-name (:string :encoding :utf-16le))   ; LPWSTR optional
  (ph-mpr-config :pointer))   ; HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprConfigServerConnect = Win32::API::More->new('MPRAPI',
    'DWORD MprConfigServerConnect(LPCWSTR lpwsServerName, HANDLE phMprConfig)');
# my $ret = $MprConfigServerConnect->Call($lpwsServerName, $phMprConfig);
# lpwsServerName : LPWSTR optional -> LPCWSTR
# phMprConfig : HANDLE* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。