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