ホーム › NetworkManagement.Rras › MprAdminMIBServerConnect
MprAdminMIBServerConnect
関数MIB管理用にルーターサーバーへ接続しハンドルを取得する。
シグネチャ
// MPRAPI.dll
#include <windows.h>
DWORD MprAdminMIBServerConnect(
LPWSTR lpwsServerName, // optional
INT_PTR* phMibServer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpwsServerName | LPWSTR | inoptional | 接続先のMIB提供サーバー名を指すUnicode文字列。ローカルはNULL可。 |
| phMibServer | INT_PTR* | out | 確立されたMIBサーバー接続ハンドルを受け取るポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// MPRAPI.dll
#include <windows.h>
DWORD MprAdminMIBServerConnect(
LPWSTR lpwsServerName, // optional
INT_PTR* phMibServer
);[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprAdminMIBServerConnect(
[MarshalAs(UnmanagedType.LPWStr)] string lpwsServerName, // LPWSTR optional
out IntPtr phMibServer // INT_PTR* out
);<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprAdminMIBServerConnect(
<MarshalAs(UnmanagedType.LPWStr)> lpwsServerName As String, ' LPWSTR optional
<Out> ByRef phMibServer As IntPtr ' INT_PTR* out
) As UInteger
End Function' lpwsServerName : LPWSTR optional
' phMibServer : INT_PTR* out
Declare PtrSafe Function MprAdminMIBServerConnect Lib "mprapi" ( _
ByVal lpwsServerName As LongPtr, _
ByRef phMibServer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MprAdminMIBServerConnect = ctypes.windll.mprapi.MprAdminMIBServerConnect
MprAdminMIBServerConnect.restype = wintypes.DWORD
MprAdminMIBServerConnect.argtypes = [
wintypes.LPCWSTR, # lpwsServerName : LPWSTR optional
ctypes.POINTER(ctypes.c_ssize_t), # phMibServer : INT_PTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MPRAPI.dll')
MprAdminMIBServerConnect = Fiddle::Function.new(
lib['MprAdminMIBServerConnect'],
[
Fiddle::TYPE_VOIDP, # lpwsServerName : LPWSTR optional
Fiddle::TYPE_VOIDP, # phMibServer : INT_PTR* out
],
-Fiddle::TYPE_INT)#[link(name = "mprapi")]
extern "system" {
fn MprAdminMIBServerConnect(
lpwsServerName: *mut u16, // LPWSTR optional
phMibServer: *mut isize // INT_PTR* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MPRAPI.dll")]
public static extern uint MprAdminMIBServerConnect([MarshalAs(UnmanagedType.LPWStr)] string lpwsServerName, out IntPtr phMibServer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPRAPI_MprAdminMIBServerConnect' -Namespace Win32 -PassThru
# $api::MprAdminMIBServerConnect(lpwsServerName, phMibServer)#uselib "MPRAPI.dll"
#func global MprAdminMIBServerConnect "MprAdminMIBServerConnect" sptr, sptr
; MprAdminMIBServerConnect lpwsServerName, varptr(phMibServer) ; 戻り値は stat
; lpwsServerName : LPWSTR optional -> "sptr"
; phMibServer : INT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MPRAPI.dll" #cfunc global MprAdminMIBServerConnect "MprAdminMIBServerConnect" wstr, var ; res = MprAdminMIBServerConnect(lpwsServerName, phMibServer) ; lpwsServerName : LPWSTR optional -> "wstr" ; phMibServer : INT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MPRAPI.dll" #cfunc global MprAdminMIBServerConnect "MprAdminMIBServerConnect" wstr, sptr ; res = MprAdminMIBServerConnect(lpwsServerName, varptr(phMibServer)) ; lpwsServerName : LPWSTR optional -> "wstr" ; phMibServer : INT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MprAdminMIBServerConnect(LPWSTR lpwsServerName, INT_PTR* phMibServer) #uselib "MPRAPI.dll" #cfunc global MprAdminMIBServerConnect "MprAdminMIBServerConnect" wstr, var ; res = MprAdminMIBServerConnect(lpwsServerName, phMibServer) ; lpwsServerName : LPWSTR optional -> "wstr" ; phMibServer : INT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MprAdminMIBServerConnect(LPWSTR lpwsServerName, INT_PTR* phMibServer) #uselib "MPRAPI.dll" #cfunc global MprAdminMIBServerConnect "MprAdminMIBServerConnect" wstr, intptr ; res = MprAdminMIBServerConnect(lpwsServerName, varptr(phMibServer)) ; lpwsServerName : LPWSTR optional -> "wstr" ; phMibServer : INT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
procMprAdminMIBServerConnect = mprapi.NewProc("MprAdminMIBServerConnect")
)
// lpwsServerName (LPWSTR optional), phMibServer (INT_PTR* out)
r1, _, err := procMprAdminMIBServerConnect.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwsServerName))),
uintptr(phMibServer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MprAdminMIBServerConnect(
lpwsServerName: PWideChar; // LPWSTR optional
phMibServer: Pointer // INT_PTR* out
): DWORD; stdcall;
external 'MPRAPI.dll' name 'MprAdminMIBServerConnect';result := DllCall("MPRAPI\MprAdminMIBServerConnect"
, "WStr", lpwsServerName ; LPWSTR optional
, "Ptr", phMibServer ; INT_PTR* out
, "UInt") ; return: DWORD●MprAdminMIBServerConnect(lpwsServerName, phMibServer) = DLL("MPRAPI.dll", "dword MprAdminMIBServerConnect(char*, void*)")
# 呼び出し: MprAdminMIBServerConnect(lpwsServerName, phMibServer)
# lpwsServerName : LPWSTR optional -> "char*"
# phMibServer : INT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mprapi" fn MprAdminMIBServerConnect(
lpwsServerName: [*c]const u16, // LPWSTR optional
phMibServer: [*c]isize // INT_PTR* out
) callconv(std.os.windows.WINAPI) u32;proc MprAdminMIBServerConnect(
lpwsServerName: WideCString, # LPWSTR optional
phMibServer: ptr int # INT_PTR* out
): uint32 {.importc: "MprAdminMIBServerConnect", stdcall, dynlib: "MPRAPI.dll".}pragma(lib, "mprapi");
extern(Windows)
uint MprAdminMIBServerConnect(
const(wchar)* lpwsServerName, // LPWSTR optional
ptrdiff_t* phMibServer // INT_PTR* out
);ccall((:MprAdminMIBServerConnect, "MPRAPI.dll"), stdcall, UInt32,
(Cwstring, Ptr{Int}),
lpwsServerName, phMibServer)
# lpwsServerName : LPWSTR optional -> Cwstring
# phMibServer : INT_PTR* out -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MprAdminMIBServerConnect(
const uint16_t* lpwsServerName,
intptr_t* phMibServer);
]]
local mprapi = ffi.load("mprapi")
-- mprapi.MprAdminMIBServerConnect(lpwsServerName, phMibServer)
-- lpwsServerName : LPWSTR optional
-- phMibServer : INT_PTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MPRAPI.dll');
const MprAdminMIBServerConnect = lib.func('__stdcall', 'MprAdminMIBServerConnect', 'uint32_t', ['str16', 'intptr_t *']);
// MprAdminMIBServerConnect(lpwsServerName, phMibServer)
// lpwsServerName : LPWSTR optional -> 'str16'
// phMibServer : INT_PTR* out -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MPRAPI.dll", {
MprAdminMIBServerConnect: { parameters: ["buffer", "pointer"], result: "u32" },
});
// lib.symbols.MprAdminMIBServerConnect(lpwsServerName, phMibServer)
// lpwsServerName : LPWSTR optional -> "buffer"
// phMibServer : INT_PTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MprAdminMIBServerConnect(
const uint16_t* lpwsServerName,
intptr_t* phMibServer);
C, "MPRAPI.dll");
// $ffi->MprAdminMIBServerConnect(lpwsServerName, phMibServer);
// lpwsServerName : LPWSTR optional
// phMibServer : INT_PTR* 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 MprAdminMIBServerConnect(
WString lpwsServerName, // LPWSTR optional
LongByReference phMibServer // INT_PTR* out
);
}@[Link("mprapi")]
lib LibMPRAPI
fun MprAdminMIBServerConnect = MprAdminMIBServerConnect(
lpwsServerName : UInt16*, # LPWSTR optional
phMibServer : LibC::SSizeT* # INT_PTR* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MprAdminMIBServerConnectNative = Uint32 Function(Pointer<Utf16>, Pointer<IntPtr>);
typedef MprAdminMIBServerConnectDart = int Function(Pointer<Utf16>, Pointer<IntPtr>);
final MprAdminMIBServerConnect = DynamicLibrary.open('MPRAPI.dll')
.lookupFunction<MprAdminMIBServerConnectNative, MprAdminMIBServerConnectDart>('MprAdminMIBServerConnect');
// lpwsServerName : LPWSTR optional -> Pointer<Utf16>
// phMibServer : INT_PTR* out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MprAdminMIBServerConnect(
lpwsServerName: PWideChar; // LPWSTR optional
phMibServer: Pointer // INT_PTR* out
): DWORD; stdcall;
external 'MPRAPI.dll' name 'MprAdminMIBServerConnect';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MprAdminMIBServerConnect"
c_MprAdminMIBServerConnect :: CWString -> Ptr CIntPtr -> IO Word32
-- lpwsServerName : LPWSTR optional -> CWString
-- phMibServer : INT_PTR* out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mpradminmibserverconnect =
foreign "MprAdminMIBServerConnect"
((ptr uint16_t) @-> (ptr intptr_t) @-> returning uint32_t)
(* lpwsServerName : LPWSTR optional -> (ptr uint16_t) *)
(* phMibServer : INT_PTR* out -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)
(cffi:defcfun ("MprAdminMIBServerConnect" mpr-admin-mibserver-connect :convention :stdcall) :uint32
(lpws-server-name (:string :encoding :utf-16le)) ; LPWSTR optional
(ph-mib-server :pointer)) ; INT_PTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MprAdminMIBServerConnect = Win32::API::More->new('MPRAPI',
'DWORD MprAdminMIBServerConnect(LPCWSTR lpwsServerName, LPVOID phMibServer)');
# my $ret = $MprAdminMIBServerConnect->Call($lpwsServerName, $phMibServer);
# lpwsServerName : LPWSTR optional -> LPCWSTR
# phMibServer : INT_PTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。