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変換前の元エラーを示すHRESULTコード。
newErrorHRESULTin変換後の新しいエラーを示すHRESULTコード。
messageHSTRINGinoptional新エラーに付随する説明メッセージを保持するHSTRING。NULL可。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "api-ms-win-core-winrt-error-l1-1-0" fn RoTransformError(
    oldError: i32, // HRESULT
    newError: i32, // HRESULT
    message: ?*anyopaque // HSTRING optional
) callconv(std.os.windows.WINAPI) i32;
proc RoTransformError(
    oldError: int32,  # HRESULT
    newError: int32,  # HRESULT
    message: pointer  # HSTRING optional
): int32 {.importc: "RoTransformError", stdcall, dynlib: "api-ms-win-core-winrt-error-l1-1-0.dll".}
pragma(lib, "api-ms-win-core-winrt-error-l1-1-0");
extern(Windows)
int RoTransformError(
    int oldError,   // HRESULT
    int newError,   // HRESULT
    void* message   // HSTRING optional
);
ccall((:RoTransformError, "api-ms-win-core-winrt-error-l1-1-0.dll"), stdcall, Int32,
      (Int32, Int32, Ptr{Cvoid}),
      oldError, newError, message)
# oldError : HRESULT -> Int32
# newError : HRESULT -> Int32
# message : HSTRING optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RoTransformError(
    int32_t oldError,
    int32_t newError,
    void* message);
]]
local api-ms-win-core-winrt-error-l1-1-0 = ffi.load("api-ms-win-core-winrt-error-l1-1-0")
-- api-ms-win-core-winrt-error-l1-1-0.RoTransformError(oldError, newError, message)
-- oldError : HRESULT
-- newError : HRESULT
-- message : HSTRING optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-winrt-error-l1-1-0.dll');
const RoTransformError = lib.func('__stdcall', 'RoTransformError', 'int32_t', ['int32_t', 'int32_t', 'void *']);
// RoTransformError(oldError, newError, message)
// oldError : HRESULT -> 'int32_t'
// newError : HRESULT -> 'int32_t'
// message : HSTRING optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("api-ms-win-core-winrt-error-l1-1-0.dll", {
  RoTransformError: { parameters: ["i32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.RoTransformError(oldError, newError, message)
// oldError : HRESULT -> "i32"
// newError : HRESULT -> "i32"
// message : HSTRING optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RoTransformError(
    int32_t oldError,
    int32_t newError,
    void* message);
C, "api-ms-win-core-winrt-error-l1-1-0.dll");
// $ffi->RoTransformError(oldError, newError, message);
// oldError : HRESULT
// newError : HRESULT
// message : HSTRING optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Api-ms-win-core-winrt-error-l1-1-0 extends StdCallLibrary {
    Api-ms-win-core-winrt-error-l1-1-0 INSTANCE = Native.load("api-ms-win-core-winrt-error-l1-1-0", Api-ms-win-core-winrt-error-l1-1-0.class, W32APIOptions.ASCII_OPTIONS);
    boolean RoTransformError(
        int oldError,   // HRESULT
        int newError,   // HRESULT
        Pointer message   // HSTRING optional
    );
}
@[Link("api-ms-win-core-winrt-error-l1-1-0")]
lib Libapi-ms-win-core-winrt-error-l1-1-0
  fun RoTransformError = RoTransformError(
    oldError : Int32,   # HRESULT
    newError : Int32,   # HRESULT
    message : Void*   # HSTRING optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RoTransformErrorNative = Int32 Function(Int32, Int32, Pointer<Void>);
typedef RoTransformErrorDart = int Function(int, int, Pointer<Void>);
final RoTransformError = DynamicLibrary.open('api-ms-win-core-winrt-error-l1-1-0.dll')
    .lookupFunction<RoTransformErrorNative, RoTransformErrorDart>('RoTransformError');
// oldError : HRESULT -> Int32
// newError : HRESULT -> Int32
// message : HSTRING optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RoTransformError"
  c_RoTransformError :: Int32 -> Int32 -> Ptr () -> IO CInt
-- oldError : HRESULT -> Int32
-- newError : HRESULT -> Int32
-- message : HSTRING optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rotransformerror =
  foreign "RoTransformError"
    (int32_t @-> int32_t @-> (ptr void) @-> returning int32_t)
(* oldError : HRESULT -> int32_t *)
(* newError : HRESULT -> int32_t *)
(* message : HSTRING optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library api-ms-win-core-winrt-error-l1-1-0 (t "api-ms-win-core-winrt-error-l1-1-0.dll"))
(cffi:use-foreign-library api-ms-win-core-winrt-error-l1-1-0)

(cffi:defcfun ("RoTransformError" ro-transform-error :convention :stdcall) :int32
  (old-error :int32)   ; HRESULT
  (new-error :int32)   ; HRESULT
  (message :pointer))   ; HSTRING optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RoTransformError = Win32::API::More->new('api-ms-win-core-winrt-error-l1-1-0',
    'BOOL RoTransformError(int oldError, int newError, HANDLE message)');
# my $ret = $RoTransformError->Call($oldError, $newError, $message);
# oldError : HRESULT -> int
# newError : HRESULT -> int
# message : HSTRING optional -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い