Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › RouterGetErrorStringA

RouterGetErrorStringA

関数
ルーターのエラーコードに対応するエラー文字列を取得する(ANSI版)。
DLLrtutils.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// rtutils.dll  (ANSI / -A)
#include <windows.h>

DWORD RouterGetErrorStringA(
    DWORD dwErrorCode,
    LPSTR* lplpszErrorString
);

パラメーター

名前方向
dwErrorCodeDWORDin
lplpszErrorStringLPSTR*out

戻り値の型: DWORD

各言語での呼び出し定義

// rtutils.dll  (ANSI / -A)
#include <windows.h>

DWORD RouterGetErrorStringA(
    DWORD dwErrorCode,
    LPSTR* lplpszErrorString
);
[DllImport("rtutils.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RouterGetErrorStringA(
    uint dwErrorCode,   // DWORD
    IntPtr lplpszErrorString   // LPSTR* out
);
<DllImport("rtutils.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RouterGetErrorStringA(
    dwErrorCode As UInteger,   ' DWORD
    lplpszErrorString As IntPtr   ' LPSTR* out
) As UInteger
End Function
' dwErrorCode : DWORD
' lplpszErrorString : LPSTR* out
Declare PtrSafe Function RouterGetErrorStringA Lib "rtutils" ( _
    ByVal dwErrorCode As Long, _
    ByVal lplpszErrorString As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RouterGetErrorStringA = ctypes.windll.rtutils.RouterGetErrorStringA
RouterGetErrorStringA.restype = wintypes.DWORD
RouterGetErrorStringA.argtypes = [
    wintypes.DWORD,  # dwErrorCode : DWORD
    ctypes.c_void_p,  # lplpszErrorString : LPSTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rtutils.dll')
RouterGetErrorStringA = Fiddle::Function.new(
  lib['RouterGetErrorStringA'],
  [
    -Fiddle::TYPE_INT,  # dwErrorCode : DWORD
    Fiddle::TYPE_VOIDP,  # lplpszErrorString : LPSTR* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "rtutils")]
extern "system" {
    fn RouterGetErrorStringA(
        dwErrorCode: u32,  // DWORD
        lplpszErrorString: *mut *mut u8  // LPSTR* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rtutils.dll", CharSet = CharSet.Ansi)]
public static extern uint RouterGetErrorStringA(uint dwErrorCode, IntPtr lplpszErrorString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rtutils_RouterGetErrorStringA' -Namespace Win32 -PassThru
# $api::RouterGetErrorStringA(dwErrorCode, lplpszErrorString)
#uselib "rtutils.dll"
#func global RouterGetErrorStringA "RouterGetErrorStringA" sptr, sptr
; RouterGetErrorStringA dwErrorCode, varptr(lplpszErrorString)   ; 戻り値は stat
; dwErrorCode : DWORD -> "sptr"
; lplpszErrorString : LPSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "rtutils.dll"
#cfunc global RouterGetErrorStringA "RouterGetErrorStringA" int, var
; res = RouterGetErrorStringA(dwErrorCode, lplpszErrorString)
; dwErrorCode : DWORD -> "int"
; lplpszErrorString : LPSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD RouterGetErrorStringA(DWORD dwErrorCode, LPSTR* lplpszErrorString)
#uselib "rtutils.dll"
#cfunc global RouterGetErrorStringA "RouterGetErrorStringA" int, var
; res = RouterGetErrorStringA(dwErrorCode, lplpszErrorString)
; dwErrorCode : DWORD -> "int"
; lplpszErrorString : LPSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rtutils = windows.NewLazySystemDLL("rtutils.dll")
	procRouterGetErrorStringA = rtutils.NewProc("RouterGetErrorStringA")
)

// dwErrorCode (DWORD), lplpszErrorString (LPSTR* out)
r1, _, err := procRouterGetErrorStringA.Call(
	uintptr(dwErrorCode),
	uintptr(lplpszErrorString),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RouterGetErrorStringA(
  dwErrorCode: DWORD;   // DWORD
  lplpszErrorString: PPAnsiChar   // LPSTR* out
): DWORD; stdcall;
  external 'rtutils.dll' name 'RouterGetErrorStringA';
result := DllCall("rtutils\RouterGetErrorStringA"
    , "UInt", dwErrorCode   ; DWORD
    , "Ptr", lplpszErrorString   ; LPSTR* out
    , "UInt")   ; return: DWORD
●RouterGetErrorStringA(dwErrorCode, lplpszErrorString) = DLL("rtutils.dll", "dword RouterGetErrorStringA(dword, void*)")
# 呼び出し: RouterGetErrorStringA(dwErrorCode, lplpszErrorString)
# dwErrorCode : DWORD -> "dword"
# lplpszErrorString : LPSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。