ホーム › NetworkManagement.Rras › RasGetEapUserIdentityA
RasGetEapUserIdentityA
関数EAP認証で使用するユーザーIDを取得する(ANSI版)。
シグネチャ
// RASAPI32.dll (ANSI / -A)
#include <windows.h>
DWORD RasGetEapUserIdentityA(
LPCSTR pszPhonebook, // optional
LPCSTR pszEntry,
DWORD dwFlags,
HWND hwnd,
RASEAPUSERIDENTITYA** ppRasEapUserIdentity
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszPhonebook | LPCSTR | inoptional | 電話帳ファイルのフルパス文字列。NULL指定で既定の電話帳を使用する。 |
| pszEntry | LPCSTR | in | 対象エントリ名の文字列。 |
| dwFlags | DWORD | in | EAP識別取得の動作を制御するRASEAPF_フラグ(対話禁止やログオン時等)。 |
| hwnd | HWND | in | 必要時に表示するEAP UIの親ウィンドウハンドル。 |
| ppRasEapUserIdentity | RASEAPUSERIDENTITYA** | out | 確保されたRASEAPUSERIDENTITYA構造体へのポインタを受け取る変数。使用後はRasFreeEapUserIdentityAで解放する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RASAPI32.dll (ANSI / -A)
#include <windows.h>
DWORD RasGetEapUserIdentityA(
LPCSTR pszPhonebook, // optional
LPCSTR pszEntry,
DWORD dwFlags,
HWND hwnd,
RASEAPUSERIDENTITYA** ppRasEapUserIdentity
);[DllImport("RASAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RasGetEapUserIdentityA(
[MarshalAs(UnmanagedType.LPStr)] string pszPhonebook, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string pszEntry, // LPCSTR
uint dwFlags, // DWORD
IntPtr hwnd, // HWND
IntPtr ppRasEapUserIdentity // RASEAPUSERIDENTITYA** out
);<DllImport("RASAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RasGetEapUserIdentityA(
<MarshalAs(UnmanagedType.LPStr)> pszPhonebook As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> pszEntry As String, ' LPCSTR
dwFlags As UInteger, ' DWORD
hwnd As IntPtr, ' HWND
ppRasEapUserIdentity As IntPtr ' RASEAPUSERIDENTITYA** out
) As UInteger
End Function' pszPhonebook : LPCSTR optional
' pszEntry : LPCSTR
' dwFlags : DWORD
' hwnd : HWND
' ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out
Declare PtrSafe Function RasGetEapUserIdentityA Lib "rasapi32" ( _
ByVal pszPhonebook As String, _
ByVal pszEntry As String, _
ByVal dwFlags As Long, _
ByVal hwnd As LongPtr, _
ByVal ppRasEapUserIdentity As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RasGetEapUserIdentityA = ctypes.windll.rasapi32.RasGetEapUserIdentityA
RasGetEapUserIdentityA.restype = wintypes.DWORD
RasGetEapUserIdentityA.argtypes = [
wintypes.LPCSTR, # pszPhonebook : LPCSTR optional
wintypes.LPCSTR, # pszEntry : LPCSTR
wintypes.DWORD, # dwFlags : DWORD
wintypes.HANDLE, # hwnd : HWND
ctypes.c_void_p, # ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RASAPI32.dll')
RasGetEapUserIdentityA = Fiddle::Function.new(
lib['RasGetEapUserIdentityA'],
[
Fiddle::TYPE_VOIDP, # pszPhonebook : LPCSTR optional
Fiddle::TYPE_VOIDP, # pszEntry : LPCSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out
],
-Fiddle::TYPE_INT)#[link(name = "rasapi32")]
extern "system" {
fn RasGetEapUserIdentityA(
pszPhonebook: *const u8, // LPCSTR optional
pszEntry: *const u8, // LPCSTR
dwFlags: u32, // DWORD
hwnd: *mut core::ffi::c_void, // HWND
ppRasEapUserIdentity: *mut *mut RASEAPUSERIDENTITYA // RASEAPUSERIDENTITYA** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RASAPI32.dll", CharSet = CharSet.Ansi)]
public static extern uint RasGetEapUserIdentityA([MarshalAs(UnmanagedType.LPStr)] string pszPhonebook, [MarshalAs(UnmanagedType.LPStr)] string pszEntry, uint dwFlags, IntPtr hwnd, IntPtr ppRasEapUserIdentity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RASAPI32_RasGetEapUserIdentityA' -Namespace Win32 -PassThru
# $api::RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity)#uselib "RASAPI32.dll"
#func global RasGetEapUserIdentityA "RasGetEapUserIdentityA" sptr, sptr, sptr, sptr, sptr
; RasGetEapUserIdentityA pszPhonebook, pszEntry, dwFlags, hwnd, varptr(ppRasEapUserIdentity) ; 戻り値は stat
; pszPhonebook : LPCSTR optional -> "sptr"
; pszEntry : LPCSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; hwnd : HWND -> "sptr"
; ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RASAPI32.dll" #cfunc global RasGetEapUserIdentityA "RasGetEapUserIdentityA" str, str, int, sptr, var ; res = RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity) ; pszPhonebook : LPCSTR optional -> "str" ; pszEntry : LPCSTR -> "str" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "sptr" ; ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RASAPI32.dll" #cfunc global RasGetEapUserIdentityA "RasGetEapUserIdentityA" str, str, int, sptr, sptr ; res = RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, varptr(ppRasEapUserIdentity)) ; pszPhonebook : LPCSTR optional -> "str" ; pszEntry : LPCSTR -> "str" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "sptr" ; ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD RasGetEapUserIdentityA(LPCSTR pszPhonebook, LPCSTR pszEntry, DWORD dwFlags, HWND hwnd, RASEAPUSERIDENTITYA** ppRasEapUserIdentity) #uselib "RASAPI32.dll" #cfunc global RasGetEapUserIdentityA "RasGetEapUserIdentityA" str, str, int, intptr, var ; res = RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity) ; pszPhonebook : LPCSTR optional -> "str" ; pszEntry : LPCSTR -> "str" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "intptr" ; ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RasGetEapUserIdentityA(LPCSTR pszPhonebook, LPCSTR pszEntry, DWORD dwFlags, HWND hwnd, RASEAPUSERIDENTITYA** ppRasEapUserIdentity) #uselib "RASAPI32.dll" #cfunc global RasGetEapUserIdentityA "RasGetEapUserIdentityA" str, str, int, intptr, intptr ; res = RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, varptr(ppRasEapUserIdentity)) ; pszPhonebook : LPCSTR optional -> "str" ; pszEntry : LPCSTR -> "str" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "intptr" ; ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rasapi32 = windows.NewLazySystemDLL("RASAPI32.dll")
procRasGetEapUserIdentityA = rasapi32.NewProc("RasGetEapUserIdentityA")
)
// pszPhonebook (LPCSTR optional), pszEntry (LPCSTR), dwFlags (DWORD), hwnd (HWND), ppRasEapUserIdentity (RASEAPUSERIDENTITYA** out)
r1, _, err := procRasGetEapUserIdentityA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszPhonebook))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszEntry))),
uintptr(dwFlags),
uintptr(hwnd),
uintptr(ppRasEapUserIdentity),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RasGetEapUserIdentityA(
pszPhonebook: PAnsiChar; // LPCSTR optional
pszEntry: PAnsiChar; // LPCSTR
dwFlags: DWORD; // DWORD
hwnd: THandle; // HWND
ppRasEapUserIdentity: Pointer // RASEAPUSERIDENTITYA** out
): DWORD; stdcall;
external 'RASAPI32.dll' name 'RasGetEapUserIdentityA';result := DllCall("RASAPI32\RasGetEapUserIdentityA"
, "AStr", pszPhonebook ; LPCSTR optional
, "AStr", pszEntry ; LPCSTR
, "UInt", dwFlags ; DWORD
, "Ptr", hwnd ; HWND
, "Ptr", ppRasEapUserIdentity ; RASEAPUSERIDENTITYA** out
, "UInt") ; return: DWORD●RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity) = DLL("RASAPI32.dll", "dword RasGetEapUserIdentityA(char*, char*, dword, void*, void*)")
# 呼び出し: RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity)
# pszPhonebook : LPCSTR optional -> "char*"
# pszEntry : LPCSTR -> "char*"
# dwFlags : DWORD -> "dword"
# hwnd : HWND -> "void*"
# ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rasapi32" fn RasGetEapUserIdentityA(
pszPhonebook: [*c]const u8, // LPCSTR optional
pszEntry: [*c]const u8, // LPCSTR
dwFlags: u32, // DWORD
hwnd: ?*anyopaque, // HWND
ppRasEapUserIdentity: [*c][*c]RASEAPUSERIDENTITYA // RASEAPUSERIDENTITYA** out
) callconv(std.os.windows.WINAPI) u32;proc RasGetEapUserIdentityA(
pszPhonebook: cstring, # LPCSTR optional
pszEntry: cstring, # LPCSTR
dwFlags: uint32, # DWORD
hwnd: pointer, # HWND
ppRasEapUserIdentity: ptr RASEAPUSERIDENTITYA # RASEAPUSERIDENTITYA** out
): uint32 {.importc: "RasGetEapUserIdentityA", stdcall, dynlib: "RASAPI32.dll".}pragma(lib, "rasapi32");
extern(Windows)
uint RasGetEapUserIdentityA(
const(char)* pszPhonebook, // LPCSTR optional
const(char)* pszEntry, // LPCSTR
uint dwFlags, // DWORD
void* hwnd, // HWND
RASEAPUSERIDENTITYA** ppRasEapUserIdentity // RASEAPUSERIDENTITYA** out
);ccall((:RasGetEapUserIdentityA, "RASAPI32.dll"), stdcall, UInt32,
(Cstring, Cstring, UInt32, Ptr{Cvoid}, Ptr{RASEAPUSERIDENTITYA}),
pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity)
# pszPhonebook : LPCSTR optional -> Cstring
# pszEntry : LPCSTR -> Cstring
# dwFlags : DWORD -> UInt32
# hwnd : HWND -> Ptr{Cvoid}
# ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> Ptr{RASEAPUSERIDENTITYA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RasGetEapUserIdentityA(
const char* pszPhonebook,
const char* pszEntry,
uint32_t dwFlags,
void* hwnd,
void* ppRasEapUserIdentity);
]]
local rasapi32 = ffi.load("rasapi32")
-- rasapi32.RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity)
-- pszPhonebook : LPCSTR optional
-- pszEntry : LPCSTR
-- dwFlags : DWORD
-- hwnd : HWND
-- ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RASAPI32.dll');
const RasGetEapUserIdentityA = lib.func('__stdcall', 'RasGetEapUserIdentityA', 'uint32_t', ['str', 'str', 'uint32_t', 'void *', 'void *']);
// RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity)
// pszPhonebook : LPCSTR optional -> 'str'
// pszEntry : LPCSTR -> 'str'
// dwFlags : DWORD -> 'uint32_t'
// hwnd : HWND -> 'void *'
// ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RASAPI32.dll", {
RasGetEapUserIdentityA: { parameters: ["buffer", "buffer", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity)
// pszPhonebook : LPCSTR optional -> "buffer"
// pszEntry : LPCSTR -> "buffer"
// dwFlags : DWORD -> "u32"
// hwnd : HWND -> "pointer"
// ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RasGetEapUserIdentityA(
const char* pszPhonebook,
const char* pszEntry,
uint32_t dwFlags,
void* hwnd,
void* ppRasEapUserIdentity);
C, "RASAPI32.dll");
// $ffi->RasGetEapUserIdentityA(pszPhonebook, pszEntry, dwFlags, hwnd, ppRasEapUserIdentity);
// pszPhonebook : LPCSTR optional
// pszEntry : LPCSTR
// dwFlags : DWORD
// hwnd : HWND
// ppRasEapUserIdentity : RASEAPUSERIDENTITYA** 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 Rasapi32 extends StdCallLibrary {
Rasapi32 INSTANCE = Native.load("rasapi32", Rasapi32.class, W32APIOptions.ASCII_OPTIONS);
int RasGetEapUserIdentityA(
String pszPhonebook, // LPCSTR optional
String pszEntry, // LPCSTR
int dwFlags, // DWORD
Pointer hwnd, // HWND
Pointer ppRasEapUserIdentity // RASEAPUSERIDENTITYA** out
);
}@[Link("rasapi32")]
lib LibRASAPI32
fun RasGetEapUserIdentityA = RasGetEapUserIdentityA(
pszPhonebook : UInt8*, # LPCSTR optional
pszEntry : UInt8*, # LPCSTR
dwFlags : UInt32, # DWORD
hwnd : Void*, # HWND
ppRasEapUserIdentity : RASEAPUSERIDENTITYA** # RASEAPUSERIDENTITYA** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RasGetEapUserIdentityANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Uint32, Pointer<Void>, Pointer<Void>);
typedef RasGetEapUserIdentityADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Void>, Pointer<Void>);
final RasGetEapUserIdentityA = DynamicLibrary.open('RASAPI32.dll')
.lookupFunction<RasGetEapUserIdentityANative, RasGetEapUserIdentityADart>('RasGetEapUserIdentityA');
// pszPhonebook : LPCSTR optional -> Pointer<Utf8>
// pszEntry : LPCSTR -> Pointer<Utf8>
// dwFlags : DWORD -> Uint32
// hwnd : HWND -> Pointer<Void>
// ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RasGetEapUserIdentityA(
pszPhonebook: PAnsiChar; // LPCSTR optional
pszEntry: PAnsiChar; // LPCSTR
dwFlags: DWORD; // DWORD
hwnd: THandle; // HWND
ppRasEapUserIdentity: Pointer // RASEAPUSERIDENTITYA** out
): DWORD; stdcall;
external 'RASAPI32.dll' name 'RasGetEapUserIdentityA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RasGetEapUserIdentityA"
c_RasGetEapUserIdentityA :: CString -> CString -> Word32 -> Ptr () -> Ptr () -> IO Word32
-- pszPhonebook : LPCSTR optional -> CString
-- pszEntry : LPCSTR -> CString
-- dwFlags : DWORD -> Word32
-- hwnd : HWND -> Ptr ()
-- ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rasgeteapuseridentitya =
foreign "RasGetEapUserIdentityA"
(string @-> string @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* pszPhonebook : LPCSTR optional -> string *)
(* pszEntry : LPCSTR -> string *)
(* dwFlags : DWORD -> uint32_t *)
(* hwnd : HWND -> (ptr void) *)
(* ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rasapi32 (t "RASAPI32.dll"))
(cffi:use-foreign-library rasapi32)
(cffi:defcfun ("RasGetEapUserIdentityA" ras-get-eap-user-identity-a :convention :stdcall) :uint32
(psz-phonebook :string) ; LPCSTR optional
(psz-entry :string) ; LPCSTR
(dw-flags :uint32) ; DWORD
(hwnd :pointer) ; HWND
(pp-ras-eap-user-identity :pointer)) ; RASEAPUSERIDENTITYA** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RasGetEapUserIdentityA = Win32::API::More->new('RASAPI32',
'DWORD RasGetEapUserIdentityA(LPCSTR pszPhonebook, LPCSTR pszEntry, DWORD dwFlags, HANDLE hwnd, LPVOID ppRasEapUserIdentity)');
# my $ret = $RasGetEapUserIdentityA->Call($pszPhonebook, $pszEntry, $dwFlags, $hwnd, $ppRasEapUserIdentity);
# pszPhonebook : LPCSTR optional -> LPCSTR
# pszEntry : LPCSTR -> LPCSTR
# dwFlags : DWORD -> DWORD
# hwnd : HWND -> HANDLE
# ppRasEapUserIdentity : RASEAPUSERIDENTITYA** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f RasGetEapUserIdentityW (Unicode版) — EAP認証で使用するユーザーIDを取得する(Unicode版)。