Win32 API 日本語リファレンス
ホームSecurity.Authentication.WebAuthn › WebAuthNGetErrorName

WebAuthNGetErrorName

関数
WebAuthnのHRESULTエラーに対応するエラー名文字列を取得する。
DLLwebauthn.dll呼出規約winapi

シグネチャ

// webauthn.dll
#include <windows.h>

LPWSTR WebAuthNGetErrorName(
    HRESULT hr
);

パラメーター

名前方向説明
hrHRESULTinエラー名を取得する元となるHRESULTエラーコード。

戻り値の型: LPWSTR

各言語での呼び出し定義

// webauthn.dll
#include <windows.h>

LPWSTR WebAuthNGetErrorName(
    HRESULT hr
);
[DllImport("webauthn.dll", ExactSpelling = true)]
static extern IntPtr WebAuthNGetErrorName(
    int hr   // HRESULT
);
<DllImport("webauthn.dll", ExactSpelling:=True)>
Public Shared Function WebAuthNGetErrorName(
    hr As Integer   ' HRESULT
) As IntPtr
End Function
' hr : HRESULT
Declare PtrSafe Function WebAuthNGetErrorName Lib "webauthn" ( _
    ByVal hr As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WebAuthNGetErrorName = ctypes.windll.webauthn.WebAuthNGetErrorName
WebAuthNGetErrorName.restype = wintypes.LPWSTR
WebAuthNGetErrorName.argtypes = [
    ctypes.c_int,  # hr : HRESULT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webauthn.dll')
WebAuthNGetErrorName = Fiddle::Function.new(
  lib['WebAuthNGetErrorName'],
  [
    Fiddle::TYPE_INT,  # hr : HRESULT
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "webauthn")]
extern "system" {
    fn WebAuthNGetErrorName(
        hr: i32  // HRESULT
    ) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webauthn.dll")]
public static extern IntPtr WebAuthNGetErrorName(int hr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webauthn_WebAuthNGetErrorName' -Namespace Win32 -PassThru
# $api::WebAuthNGetErrorName(hr)
#uselib "webauthn.dll"
#func global WebAuthNGetErrorName "WebAuthNGetErrorName" sptr
; WebAuthNGetErrorName hr   ; 戻り値は stat
; hr : HRESULT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "webauthn.dll"
#cfunc global WebAuthNGetErrorName "WebAuthNGetErrorName" int
; res = WebAuthNGetErrorName(hr)
; hr : HRESULT -> "int"
; LPWSTR WebAuthNGetErrorName(HRESULT hr)
#uselib "webauthn.dll"
#cfunc global WebAuthNGetErrorName "WebAuthNGetErrorName" int
; res = WebAuthNGetErrorName(hr)
; hr : HRESULT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webauthn = windows.NewLazySystemDLL("webauthn.dll")
	procWebAuthNGetErrorName = webauthn.NewProc("WebAuthNGetErrorName")
)

// hr (HRESULT)
r1, _, err := procWebAuthNGetErrorName.Call(
	uintptr(hr),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPWSTR
function WebAuthNGetErrorName(
  hr: Integer   // HRESULT
): PWideChar; stdcall;
  external 'webauthn.dll' name 'WebAuthNGetErrorName';
result := DllCall("webauthn\WebAuthNGetErrorName"
    , "Int", hr   ; HRESULT
    , "Ptr")   ; return: LPWSTR
●WebAuthNGetErrorName(hr) = DLL("webauthn.dll", "char* WebAuthNGetErrorName(int)")
# 呼び出し: WebAuthNGetErrorName(hr)
# hr : HRESULT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。