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

RpcErrorGetNextRecord

関数
エラー列挙から次の拡張エラー情報レコードを取得する。
DLLRPCRT4.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

RPC_STATUS RpcErrorGetNextRecord(
    RPC_ERROR_ENUM_HANDLE* EnumHandle,
    BOOL CopyStrings,
    RPC_EXTENDED_ERROR_INFO* ErrorInfo
);

パラメーター

名前方向説明
EnumHandleRPC_ERROR_ENUM_HANDLE*in列挙の状態を保持するRPC_ERROR_ENUM_HANDLEへのポインタ。
CopyStringsBOOLinTRUEで文字列を複製して返すかを示すフラグ。FALSEで内部バッファ参照を返す。
ErrorInfoRPC_EXTENDED_ERROR_INFO*out次のエラー記録を受け取るRPC_EXTENDED_ERROR_INFO構造体へのポインタ。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS RpcErrorGetNextRecord(
    RPC_ERROR_ENUM_HANDLE* EnumHandle,
    BOOL CopyStrings,
    RPC_EXTENDED_ERROR_INFO* ErrorInfo
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int RpcErrorGetNextRecord(
    IntPtr EnumHandle,   // RPC_ERROR_ENUM_HANDLE*
    bool CopyStrings,   // BOOL
    IntPtr ErrorInfo   // RPC_EXTENDED_ERROR_INFO* out
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function RpcErrorGetNextRecord(
    EnumHandle As IntPtr,   ' RPC_ERROR_ENUM_HANDLE*
    CopyStrings As Boolean,   ' BOOL
    ErrorInfo As IntPtr   ' RPC_EXTENDED_ERROR_INFO* out
) As Integer
End Function
' EnumHandle : RPC_ERROR_ENUM_HANDLE*
' CopyStrings : BOOL
' ErrorInfo : RPC_EXTENDED_ERROR_INFO* out
Declare PtrSafe Function RpcErrorGetNextRecord Lib "rpcrt4" ( _
    ByVal EnumHandle As LongPtr, _
    ByVal CopyStrings As Long, _
    ByVal ErrorInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcErrorGetNextRecord = ctypes.windll.rpcrt4.RpcErrorGetNextRecord
RpcErrorGetNextRecord.restype = ctypes.c_int
RpcErrorGetNextRecord.argtypes = [
    ctypes.c_void_p,  # EnumHandle : RPC_ERROR_ENUM_HANDLE*
    wintypes.BOOL,  # CopyStrings : BOOL
    ctypes.c_void_p,  # ErrorInfo : RPC_EXTENDED_ERROR_INFO* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcErrorGetNextRecord = rpcrt4.NewProc("RpcErrorGetNextRecord")
)

// EnumHandle (RPC_ERROR_ENUM_HANDLE*), CopyStrings (BOOL), ErrorInfo (RPC_EXTENDED_ERROR_INFO* out)
r1, _, err := procRpcErrorGetNextRecord.Call(
	uintptr(EnumHandle),
	uintptr(CopyStrings),
	uintptr(ErrorInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcErrorGetNextRecord(
  EnumHandle: Pointer;   // RPC_ERROR_ENUM_HANDLE*
  CopyStrings: BOOL;   // BOOL
  ErrorInfo: Pointer   // RPC_EXTENDED_ERROR_INFO* out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcErrorGetNextRecord';
result := DllCall("RPCRT4\RpcErrorGetNextRecord"
    , "Ptr", EnumHandle   ; RPC_ERROR_ENUM_HANDLE*
    , "Int", CopyStrings   ; BOOL
    , "Ptr", ErrorInfo   ; RPC_EXTENDED_ERROR_INFO* out
    , "Int")   ; return: RPC_STATUS
●RpcErrorGetNextRecord(EnumHandle, CopyStrings, ErrorInfo) = DLL("RPCRT4.dll", "int RpcErrorGetNextRecord(void*, bool, void*)")
# 呼び出し: RpcErrorGetNextRecord(EnumHandle, CopyStrings, ErrorInfo)
# EnumHandle : RPC_ERROR_ENUM_HANDLE* -> "void*"
# CopyStrings : BOOL -> "bool"
# ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "rpcrt4" fn RpcErrorGetNextRecord(
    EnumHandle: [*c]RPC_ERROR_ENUM_HANDLE, // RPC_ERROR_ENUM_HANDLE*
    CopyStrings: i32, // BOOL
    ErrorInfo: [*c]RPC_EXTENDED_ERROR_INFO // RPC_EXTENDED_ERROR_INFO* out
) callconv(std.os.windows.WINAPI) i32;
proc RpcErrorGetNextRecord(
    EnumHandle: ptr RPC_ERROR_ENUM_HANDLE,  # RPC_ERROR_ENUM_HANDLE*
    CopyStrings: int32,  # BOOL
    ErrorInfo: ptr RPC_EXTENDED_ERROR_INFO  # RPC_EXTENDED_ERROR_INFO* out
): int32 {.importc: "RpcErrorGetNextRecord", stdcall, dynlib: "RPCRT4.dll".}
pragma(lib, "rpcrt4");
extern(Windows)
int RpcErrorGetNextRecord(
    RPC_ERROR_ENUM_HANDLE* EnumHandle,   // RPC_ERROR_ENUM_HANDLE*
    int CopyStrings,   // BOOL
    RPC_EXTENDED_ERROR_INFO* ErrorInfo   // RPC_EXTENDED_ERROR_INFO* out
);
ccall((:RpcErrorGetNextRecord, "RPCRT4.dll"), stdcall, Int32,
      (Ptr{RPC_ERROR_ENUM_HANDLE}, Int32, Ptr{RPC_EXTENDED_ERROR_INFO}),
      EnumHandle, CopyStrings, ErrorInfo)
# EnumHandle : RPC_ERROR_ENUM_HANDLE* -> Ptr{RPC_ERROR_ENUM_HANDLE}
# CopyStrings : BOOL -> Int32
# ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> Ptr{RPC_EXTENDED_ERROR_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcErrorGetNextRecord(
    void* EnumHandle,
    int32_t CopyStrings,
    void* ErrorInfo);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcErrorGetNextRecord(EnumHandle, CopyStrings, ErrorInfo)
-- EnumHandle : RPC_ERROR_ENUM_HANDLE*
-- CopyStrings : BOOL
-- ErrorInfo : RPC_EXTENDED_ERROR_INFO* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcErrorGetNextRecord = lib.func('__stdcall', 'RpcErrorGetNextRecord', 'int32_t', ['void *', 'int32_t', 'void *']);
// RpcErrorGetNextRecord(EnumHandle, CopyStrings, ErrorInfo)
// EnumHandle : RPC_ERROR_ENUM_HANDLE* -> 'void *'
// CopyStrings : BOOL -> 'int32_t'
// ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RPCRT4.dll", {
  RpcErrorGetNextRecord: { parameters: ["pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.RpcErrorGetNextRecord(EnumHandle, CopyStrings, ErrorInfo)
// EnumHandle : RPC_ERROR_ENUM_HANDLE* -> "pointer"
// CopyStrings : BOOL -> "i32"
// ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcErrorGetNextRecord(
    void* EnumHandle,
    int32_t CopyStrings,
    void* ErrorInfo);
C, "RPCRT4.dll");
// $ffi->RpcErrorGetNextRecord(EnumHandle, CopyStrings, ErrorInfo);
// EnumHandle : RPC_ERROR_ENUM_HANDLE*
// CopyStrings : BOOL
// ErrorInfo : RPC_EXTENDED_ERROR_INFO* out
// 構造体/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 Rpcrt4 extends StdCallLibrary {
    Rpcrt4 INSTANCE = Native.load("rpcrt4", Rpcrt4.class);
    int RpcErrorGetNextRecord(
        Pointer EnumHandle,   // RPC_ERROR_ENUM_HANDLE*
        boolean CopyStrings,   // BOOL
        Pointer ErrorInfo   // RPC_EXTENDED_ERROR_INFO* out
    );
}
@[Link("rpcrt4")]
lib LibRPCRT4
  fun RpcErrorGetNextRecord = RpcErrorGetNextRecord(
    EnumHandle : RPC_ERROR_ENUM_HANDLE*,   # RPC_ERROR_ENUM_HANDLE*
    CopyStrings : Int32,   # BOOL
    ErrorInfo : RPC_EXTENDED_ERROR_INFO*   # RPC_EXTENDED_ERROR_INFO* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RpcErrorGetNextRecordNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>);
typedef RpcErrorGetNextRecordDart = int Function(Pointer<Void>, int, Pointer<Void>);
final RpcErrorGetNextRecord = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<RpcErrorGetNextRecordNative, RpcErrorGetNextRecordDart>('RpcErrorGetNextRecord');
// EnumHandle : RPC_ERROR_ENUM_HANDLE* -> Pointer<Void>
// CopyStrings : BOOL -> Int32
// ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RpcErrorGetNextRecord(
  EnumHandle: Pointer;   // RPC_ERROR_ENUM_HANDLE*
  CopyStrings: BOOL;   // BOOL
  ErrorInfo: Pointer   // RPC_EXTENDED_ERROR_INFO* out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcErrorGetNextRecord';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcErrorGetNextRecord"
  c_RpcErrorGetNextRecord :: Ptr () -> CInt -> Ptr () -> IO Int32
-- EnumHandle : RPC_ERROR_ENUM_HANDLE* -> Ptr ()
-- CopyStrings : BOOL -> CInt
-- ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rpcerrorgetnextrecord =
  foreign "RpcErrorGetNextRecord"
    ((ptr void) @-> int32_t @-> (ptr void) @-> returning int32_t)
(* EnumHandle : RPC_ERROR_ENUM_HANDLE* -> (ptr void) *)
(* CopyStrings : BOOL -> int32_t *)
(* ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("RpcErrorGetNextRecord" rpc-error-get-next-record :convention :stdcall) :int32
  (enum-handle :pointer)   ; RPC_ERROR_ENUM_HANDLE*
  (copy-strings :int32)   ; BOOL
  (error-info :pointer))   ; RPC_EXTENDED_ERROR_INFO* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RpcErrorGetNextRecord = Win32::API::More->new('RPCRT4',
    'int RpcErrorGetNextRecord(LPVOID EnumHandle, BOOL CopyStrings, LPVOID ErrorInfo)');
# my $ret = $RpcErrorGetNextRecord->Call($EnumHandle, $CopyStrings, $ErrorInfo);
# EnumHandle : RPC_ERROR_ENUM_HANDLE* -> LPVOID
# CopyStrings : BOOL -> BOOL
# ErrorInfo : RPC_EXTENDED_ERROR_INFO* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型