Win32 API 日本語リファレンス
ホームSystem.WinRT › RoTransformError

RoTransformError

関数
既存のWinRTエラーを別のHRESULTとHSTRINGへ変換する。
DLLapi-ms-win-core-winrt-error-l1-1-0.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

// api-ms-win-core-winrt-error-l1-1-0.dll  (ANSI / -A)
#include <windows.h>

BOOL RoTransformError(
    HRESULT oldError,
    HRESULT newError,
    HSTRING message   // optional
);

パラメーター

名前方向
oldErrorHRESULTin
newErrorHRESULTin
messageHSTRINGinoptional

戻り値の型: BOOL

各言語での呼び出し定義

// api-ms-win-core-winrt-error-l1-1-0.dll  (ANSI / -A)
#include <windows.h>

BOOL RoTransformError(
    HRESULT oldError,
    HRESULT newError,
    HSTRING message   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-winrt-error-l1-1-0.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool RoTransformError(
    int oldError,   // HRESULT
    int newError,   // HRESULT
    IntPtr message   // HSTRING optional
);
<DllImport("api-ms-win-core-winrt-error-l1-1-0.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RoTransformError(
    oldError As Integer,   ' HRESULT
    newError As Integer,   ' HRESULT
    message As IntPtr   ' HSTRING optional
) As Boolean
End Function
' oldError : HRESULT
' newError : HRESULT
' message : HSTRING optional
Declare PtrSafe Function RoTransformError Lib "api-ms-win-core-winrt-error-l1-1-0" ( _
    ByVal oldError As Long, _
    ByVal newError As Long, _
    ByVal message As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RoTransformError = ctypes.windll.LoadLibrary("api-ms-win-core-winrt-error-l1-1-0.dll").RoTransformError
RoTransformError.restype = wintypes.BOOL
RoTransformError.argtypes = [
    ctypes.c_int,  # oldError : HRESULT
    ctypes.c_int,  # newError : HRESULT
    wintypes.HANDLE,  # message : HSTRING optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-winrt-error-l1-1-0.dll')
RoTransformError = Fiddle::Function.new(
  lib['RoTransformError'],
  [
    Fiddle::TYPE_INT,  # oldError : HRESULT
    Fiddle::TYPE_INT,  # newError : HRESULT
    Fiddle::TYPE_VOIDP,  # message : HSTRING optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-winrt-error-l1-1-0")]
extern "system" {
    fn RoTransformError(
        oldError: i32,  // HRESULT
        newError: i32,  // HRESULT
        message: *mut core::ffi::c_void  // HSTRING optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-winrt-error-l1-1-0.dll", CharSet = CharSet.Ansi)]
public static extern bool RoTransformError(int oldError, int newError, IntPtr message);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-winrt-error-l1-1-0_RoTransformError' -Namespace Win32 -PassThru
# $api::RoTransformError(oldError, newError, message)
#uselib "api-ms-win-core-winrt-error-l1-1-0.dll"
#func global RoTransformError "RoTransformError" sptr, sptr, sptr
; RoTransformError oldError, newError, message   ; 戻り値は stat
; oldError : HRESULT -> "sptr"
; newError : HRESULT -> "sptr"
; message : HSTRING optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "api-ms-win-core-winrt-error-l1-1-0.dll"
#cfunc global RoTransformError "RoTransformError" int, int, sptr
; res = RoTransformError(oldError, newError, message)
; oldError : HRESULT -> "int"
; newError : HRESULT -> "int"
; message : HSTRING optional -> "sptr"
; BOOL RoTransformError(HRESULT oldError, HRESULT newError, HSTRING message)
#uselib "api-ms-win-core-winrt-error-l1-1-0.dll"
#cfunc global RoTransformError "RoTransformError" int, int, intptr
; res = RoTransformError(oldError, newError, message)
; oldError : HRESULT -> "int"
; newError : HRESULT -> "int"
; message : HSTRING optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_winrt_error_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-winrt-error-l1-1-0.dll")
	procRoTransformError = api_ms_win_core_winrt_error_l1_1_0.NewProc("RoTransformError")
)

// oldError (HRESULT), newError (HRESULT), message (HSTRING optional)
r1, _, err := procRoTransformError.Call(
	uintptr(oldError),
	uintptr(newError),
	uintptr(message),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function RoTransformError(
  oldError: Integer;   // HRESULT
  newError: Integer;   // HRESULT
  message: THandle   // HSTRING optional
): BOOL; stdcall;
  external 'api-ms-win-core-winrt-error-l1-1-0.dll' name 'RoTransformError';
result := DllCall("api-ms-win-core-winrt-error-l1-1-0\RoTransformError"
    , "Int", oldError   ; HRESULT
    , "Int", newError   ; HRESULT
    , "Ptr", message   ; HSTRING optional
    , "Int")   ; return: BOOL
●RoTransformError(oldError, newError, message) = DLL("api-ms-win-core-winrt-error-l1-1-0.dll", "bool RoTransformError(int, int, void*)")
# 呼び出し: RoTransformError(oldError, newError, message)
# oldError : HRESULT -> "int"
# newError : HRESULT -> "int"
# message : HSTRING optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。