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

RouterGetErrorStringW

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

シグネチャ

// rtutils.dll  (Unicode / -W)
#include <windows.h>

DWORD RouterGetErrorStringW(
    DWORD dwErrorCode,
    LPWSTR* lplpwszErrorString
);

パラメーター

名前方向
dwErrorCodeDWORDin
lplpwszErrorStringLPWSTR*out

戻り値の型: DWORD

各言語での呼び出し定義

// rtutils.dll  (Unicode / -W)
#include <windows.h>

DWORD RouterGetErrorStringW(
    DWORD dwErrorCode,
    LPWSTR* lplpwszErrorString
);
[DllImport("rtutils.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RouterGetErrorStringW(
    uint dwErrorCode,   // DWORD
    IntPtr lplpwszErrorString   // LPWSTR* out
);
<DllImport("rtutils.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RouterGetErrorStringW(
    dwErrorCode As UInteger,   ' DWORD
    lplpwszErrorString As IntPtr   ' LPWSTR* out
) As UInteger
End Function
' dwErrorCode : DWORD
' lplpwszErrorString : LPWSTR* out
Declare PtrSafe Function RouterGetErrorStringW Lib "rtutils" ( _
    ByVal dwErrorCode As Long, _
    ByVal lplpwszErrorString 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

RouterGetErrorStringW = ctypes.windll.rtutils.RouterGetErrorStringW
RouterGetErrorStringW.restype = wintypes.DWORD
RouterGetErrorStringW.argtypes = [
    wintypes.DWORD,  # dwErrorCode : DWORD
    ctypes.c_void_p,  # lplpwszErrorString : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rtutils = windows.NewLazySystemDLL("rtutils.dll")
	procRouterGetErrorStringW = rtutils.NewProc("RouterGetErrorStringW")
)

// dwErrorCode (DWORD), lplpwszErrorString (LPWSTR* out)
r1, _, err := procRouterGetErrorStringW.Call(
	uintptr(dwErrorCode),
	uintptr(lplpwszErrorString),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RouterGetErrorStringW(
  dwErrorCode: DWORD;   // DWORD
  lplpwszErrorString: PPWideChar   // LPWSTR* out
): DWORD; stdcall;
  external 'rtutils.dll' name 'RouterGetErrorStringW';
result := DllCall("rtutils\RouterGetErrorStringW"
    , "UInt", dwErrorCode   ; DWORD
    , "Ptr", lplpwszErrorString   ; LPWSTR* out
    , "UInt")   ; return: DWORD
●RouterGetErrorStringW(dwErrorCode, lplpwszErrorString) = DLL("rtutils.dll", "dword RouterGetErrorStringW(dword, void*)")
# 呼び出し: RouterGetErrorStringW(dwErrorCode, lplpwszErrorString)
# dwErrorCode : DWORD -> "dword"
# lplpwszErrorString : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。