ホーム › NetworkManagement.Rras › RasGetErrorStringA
RasGetErrorStringA
関数RASエラーコードに対応するエラーメッセージ文字列を取得する(ANSI版)。
シグネチャ
// RASAPI32.dll (ANSI / -A)
#include <windows.h>
DWORD RasGetErrorStringA(
DWORD ResourceId,
LPSTR lpszString,
DWORD InBufSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ResourceId | DWORD | in |
| lpszString | LPSTR | out |
| InBufSize | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// RASAPI32.dll (ANSI / -A)
#include <windows.h>
DWORD RasGetErrorStringA(
DWORD ResourceId,
LPSTR lpszString,
DWORD InBufSize
);[DllImport("RASAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RasGetErrorStringA(
uint ResourceId, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszString, // LPSTR out
uint InBufSize // DWORD
);<DllImport("RASAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RasGetErrorStringA(
ResourceId As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> lpszString As System.Text.StringBuilder, ' LPSTR out
InBufSize As UInteger ' DWORD
) As UInteger
End Function' ResourceId : DWORD
' lpszString : LPSTR out
' InBufSize : DWORD
Declare PtrSafe Function RasGetErrorStringA Lib "rasapi32" ( _
ByVal ResourceId As Long, _
ByVal lpszString As String, _
ByVal InBufSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RasGetErrorStringA = ctypes.windll.rasapi32.RasGetErrorStringA
RasGetErrorStringA.restype = wintypes.DWORD
RasGetErrorStringA.argtypes = [
wintypes.DWORD, # ResourceId : DWORD
wintypes.LPSTR, # lpszString : LPSTR out
wintypes.DWORD, # InBufSize : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RASAPI32.dll')
RasGetErrorStringA = Fiddle::Function.new(
lib['RasGetErrorStringA'],
[
-Fiddle::TYPE_INT, # ResourceId : DWORD
Fiddle::TYPE_VOIDP, # lpszString : LPSTR out
-Fiddle::TYPE_INT, # InBufSize : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "rasapi32")]
extern "system" {
fn RasGetErrorStringA(
ResourceId: u32, // DWORD
lpszString: *mut u8, // LPSTR out
InBufSize: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RASAPI32.dll", CharSet = CharSet.Ansi)]
public static extern uint RasGetErrorStringA(uint ResourceId, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszString, uint InBufSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RASAPI32_RasGetErrorStringA' -Namespace Win32 -PassThru
# $api::RasGetErrorStringA(ResourceId, lpszString, InBufSize)#uselib "RASAPI32.dll"
#func global RasGetErrorStringA "RasGetErrorStringA" sptr, sptr, sptr
; RasGetErrorStringA ResourceId, varptr(lpszString), InBufSize ; 戻り値は stat
; ResourceId : DWORD -> "sptr"
; lpszString : LPSTR out -> "sptr"
; InBufSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RASAPI32.dll" #cfunc global RasGetErrorStringA "RasGetErrorStringA" int, var, int ; res = RasGetErrorStringA(ResourceId, lpszString, InBufSize) ; ResourceId : DWORD -> "int" ; lpszString : LPSTR out -> "var" ; InBufSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RASAPI32.dll" #cfunc global RasGetErrorStringA "RasGetErrorStringA" int, sptr, int ; res = RasGetErrorStringA(ResourceId, varptr(lpszString), InBufSize) ; ResourceId : DWORD -> "int" ; lpszString : LPSTR out -> "sptr" ; InBufSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD RasGetErrorStringA(DWORD ResourceId, LPSTR lpszString, DWORD InBufSize) #uselib "RASAPI32.dll" #cfunc global RasGetErrorStringA "RasGetErrorStringA" int, var, int ; res = RasGetErrorStringA(ResourceId, lpszString, InBufSize) ; ResourceId : DWORD -> "int" ; lpszString : LPSTR out -> "var" ; InBufSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RasGetErrorStringA(DWORD ResourceId, LPSTR lpszString, DWORD InBufSize) #uselib "RASAPI32.dll" #cfunc global RasGetErrorStringA "RasGetErrorStringA" int, intptr, int ; res = RasGetErrorStringA(ResourceId, varptr(lpszString), InBufSize) ; ResourceId : DWORD -> "int" ; lpszString : LPSTR out -> "intptr" ; InBufSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rasapi32 = windows.NewLazySystemDLL("RASAPI32.dll")
procRasGetErrorStringA = rasapi32.NewProc("RasGetErrorStringA")
)
// ResourceId (DWORD), lpszString (LPSTR out), InBufSize (DWORD)
r1, _, err := procRasGetErrorStringA.Call(
uintptr(ResourceId),
uintptr(lpszString),
uintptr(InBufSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RasGetErrorStringA(
ResourceId: DWORD; // DWORD
lpszString: PAnsiChar; // LPSTR out
InBufSize: DWORD // DWORD
): DWORD; stdcall;
external 'RASAPI32.dll' name 'RasGetErrorStringA';result := DllCall("RASAPI32\RasGetErrorStringA"
, "UInt", ResourceId ; DWORD
, "Ptr", lpszString ; LPSTR out
, "UInt", InBufSize ; DWORD
, "UInt") ; return: DWORD●RasGetErrorStringA(ResourceId, lpszString, InBufSize) = DLL("RASAPI32.dll", "dword RasGetErrorStringA(dword, char*, dword)")
# 呼び出し: RasGetErrorStringA(ResourceId, lpszString, InBufSize)
# ResourceId : DWORD -> "dword"
# lpszString : LPSTR out -> "char*"
# InBufSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。