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

MprAdminInterfaceGetCredentials

関数
ルーターインターフェイスの接続用資格情報を取得する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprAdminInterfaceGetCredentials(
    LPWSTR lpwsServer,   // optional
    LPWSTR lpwsInterfaceName,
    LPWSTR lpwsUserName,   // optional
    LPWSTR lpwsPassword,   // optional
    LPWSTR lpwsDomainName   // optional
);

パラメーター

名前方向説明
lpwsServerLPWSTRinoptional資格情報を取得する対象のRRASサーバー名を指すUnicode文字列。ローカルサーバーはNULLを指定する。
lpwsInterfaceNameLPWSTRin資格情報を取得する要求ダイヤルインターフェイスの名前を指すUnicode文字列。
lpwsUserNameLPWSTRoutoptionalユーザー名を受け取るバッファ。不要ならNULL可。UNLEN+1文字以上を確保する。
lpwsPasswordLPWSTRoutoptionalパスワードを受け取るバッファ。不要ならNULL可。PWLEN+1文字以上を確保する。
lpwsDomainNameLPWSTRoutoptionalドメイン名を受け取るバッファ。不要ならNULL可。DNLEN+1文字以上を確保する。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MprAdminInterfaceGetCredentials = ctypes.windll.mprapi.MprAdminInterfaceGetCredentials
MprAdminInterfaceGetCredentials.restype = wintypes.DWORD
MprAdminInterfaceGetCredentials.argtypes = [
    wintypes.LPCWSTR,  # lpwsServer : LPWSTR optional
    wintypes.LPCWSTR,  # lpwsInterfaceName : LPWSTR
    wintypes.LPWSTR,  # lpwsUserName : LPWSTR optional, out
    wintypes.LPWSTR,  # lpwsPassword : LPWSTR optional, out
    wintypes.LPWSTR,  # lpwsDomainName : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprAdminInterfaceGetCredentials = mprapi.NewProc("MprAdminInterfaceGetCredentials")
)

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

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

typedef MprAdminInterfaceGetCredentialsNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef MprAdminInterfaceGetCredentialsDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final MprAdminInterfaceGetCredentials = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprAdminInterfaceGetCredentialsNative, MprAdminInterfaceGetCredentialsDart>('MprAdminInterfaceGetCredentials');
// lpwsServer : LPWSTR optional -> Pointer<Utf16>
// lpwsInterfaceName : LPWSTR -> Pointer<Utf16>
// lpwsUserName : LPWSTR optional, out -> Pointer<Utf16>
// lpwsPassword : LPWSTR optional, out -> Pointer<Utf16>
// lpwsDomainName : LPWSTR optional, out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprAdminInterfaceGetCredentials(
  lpwsServer: PWideChar;   // LPWSTR optional
  lpwsInterfaceName: PWideChar;   // LPWSTR
  lpwsUserName: PWideChar;   // LPWSTR optional, out
  lpwsPassword: PWideChar;   // LPWSTR optional, out
  lpwsDomainName: PWideChar   // LPWSTR optional, out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprAdminInterfaceGetCredentials';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MprAdminInterfaceGetCredentials"
  c_MprAdminInterfaceGetCredentials :: CWString -> CWString -> CWString -> CWString -> CWString -> IO Word32
-- lpwsServer : LPWSTR optional -> CWString
-- lpwsInterfaceName : LPWSTR -> CWString
-- lpwsUserName : LPWSTR optional, out -> CWString
-- lpwsPassword : LPWSTR optional, out -> CWString
-- lpwsDomainName : LPWSTR optional, out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mpradmininterfacegetcredentials =
  foreign "MprAdminInterfaceGetCredentials"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* lpwsServer : LPWSTR optional -> (ptr uint16_t) *)
(* lpwsInterfaceName : LPWSTR -> (ptr uint16_t) *)
(* lpwsUserName : LPWSTR optional, out -> (ptr uint16_t) *)
(* lpwsPassword : LPWSTR optional, out -> (ptr uint16_t) *)
(* lpwsDomainName : LPWSTR optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)

(cffi:defcfun ("MprAdminInterfaceGetCredentials" mpr-admin-interface-get-credentials :convention :stdcall) :uint32
  (lpws-server (:string :encoding :utf-16le))   ; LPWSTR optional
  (lpws-interface-name (:string :encoding :utf-16le))   ; LPWSTR
  (lpws-user-name :pointer)   ; LPWSTR optional, out
  (lpws-password :pointer)   ; LPWSTR optional, out
  (lpws-domain-name :pointer))   ; LPWSTR optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprAdminInterfaceGetCredentials = Win32::API::More->new('MPRAPI',
    'DWORD MprAdminInterfaceGetCredentials(LPCWSTR lpwsServer, LPCWSTR lpwsInterfaceName, LPWSTR lpwsUserName, LPWSTR lpwsPassword, LPWSTR lpwsDomainName)');
# my $ret = $MprAdminInterfaceGetCredentials->Call($lpwsServer, $lpwsInterfaceName, $lpwsUserName, $lpwsPassword, $lpwsDomainName);
# lpwsServer : LPWSTR optional -> LPCWSTR
# lpwsInterfaceName : LPWSTR -> LPCWSTR
# lpwsUserName : LPWSTR optional, out -> LPWSTR
# lpwsPassword : LPWSTR optional, out -> LPWSTR
# lpwsDomainName : LPWSTR optional, out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API