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