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
lpwsInterfaceNameLPWSTRin
lpwsUserNameLPWSTRoutoptional
lpwsPasswordLPWSTRoutoptional
lpwsDomainNameLPWSTRoutoptional

戻り値の型: 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)。