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