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

AddERExcludedApplicationA

関数
エラー報告の除外アプリを追加する(ANSI版)。
DLLfaultrep.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// faultrep.dll  (ANSI / -A)
#include <windows.h>

BOOL AddERExcludedApplicationA(
    LPCSTR szApplication
);

パラメーター

名前方向説明
szApplicationLPCSTRinエラー報告から除外するアプリケーション名を指すANSI文字列。

戻り値の型: BOOL

各言語での呼び出し定義

// faultrep.dll  (ANSI / -A)
#include <windows.h>

BOOL AddERExcludedApplicationA(
    LPCSTR szApplication
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("faultrep.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool AddERExcludedApplicationA(
    [MarshalAs(UnmanagedType.LPStr)] string szApplication   // LPCSTR
);
<DllImport("faultrep.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AddERExcludedApplicationA(
    <MarshalAs(UnmanagedType.LPStr)> szApplication As String   ' LPCSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' szApplication : LPCSTR
Declare PtrSafe Function AddERExcludedApplicationA Lib "faultrep" ( _
    ByVal szApplication As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AddERExcludedApplicationA = ctypes.windll.faultrep.AddERExcludedApplicationA
AddERExcludedApplicationA.restype = wintypes.BOOL
AddERExcludedApplicationA.argtypes = [
    wintypes.LPCSTR,  # szApplication : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('faultrep.dll')
AddERExcludedApplicationA = Fiddle::Function.new(
  lib['AddERExcludedApplicationA'],
  [
    Fiddle::TYPE_VOIDP,  # szApplication : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "faultrep")]
extern "system" {
    fn AddERExcludedApplicationA(
        szApplication: *const u8  // LPCSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("faultrep.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool AddERExcludedApplicationA([MarshalAs(UnmanagedType.LPStr)] string szApplication);
"@
$api = Add-Type -MemberDefinition $sig -Name 'faultrep_AddERExcludedApplicationA' -Namespace Win32 -PassThru
# $api::AddERExcludedApplicationA(szApplication)
#uselib "faultrep.dll"
#func global AddERExcludedApplicationA "AddERExcludedApplicationA" sptr
; AddERExcludedApplicationA szApplication   ; 戻り値は stat
; szApplication : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "faultrep.dll"
#cfunc global AddERExcludedApplicationA "AddERExcludedApplicationA" str
; res = AddERExcludedApplicationA(szApplication)
; szApplication : LPCSTR -> "str"
; BOOL AddERExcludedApplicationA(LPCSTR szApplication)
#uselib "faultrep.dll"
#cfunc global AddERExcludedApplicationA "AddERExcludedApplicationA" str
; res = AddERExcludedApplicationA(szApplication)
; szApplication : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	faultrep = windows.NewLazySystemDLL("faultrep.dll")
	procAddERExcludedApplicationA = faultrep.NewProc("AddERExcludedApplicationA")
)

// szApplication (LPCSTR)
r1, _, err := procAddERExcludedApplicationA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szApplication))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AddERExcludedApplicationA(
  szApplication: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'faultrep.dll' name 'AddERExcludedApplicationA';
result := DllCall("faultrep\AddERExcludedApplicationA"
    , "AStr", szApplication   ; LPCSTR
    , "Int")   ; return: BOOL
●AddERExcludedApplicationA(szApplication) = DLL("faultrep.dll", "bool AddERExcludedApplicationA(char*)")
# 呼び出し: AddERExcludedApplicationA(szApplication)
# szApplication : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "faultrep" fn AddERExcludedApplicationA(
    szApplication: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;
proc AddERExcludedApplicationA(
    szApplication: cstring  # LPCSTR
): int32 {.importc: "AddERExcludedApplicationA", stdcall, dynlib: "faultrep.dll".}
pragma(lib, "faultrep");
extern(Windows)
int AddERExcludedApplicationA(
    const(char)* szApplication   // LPCSTR
);
ccall((:AddERExcludedApplicationA, "faultrep.dll"), stdcall, Int32,
      (Cstring,),
      szApplication)
# szApplication : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t AddERExcludedApplicationA(
    const char* szApplication);
]]
local faultrep = ffi.load("faultrep")
-- faultrep.AddERExcludedApplicationA(szApplication)
-- szApplication : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('faultrep.dll');
const AddERExcludedApplicationA = lib.func('__stdcall', 'AddERExcludedApplicationA', 'int32_t', ['str']);
// AddERExcludedApplicationA(szApplication)
// szApplication : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("faultrep.dll", {
  AddERExcludedApplicationA: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.AddERExcludedApplicationA(szApplication)
// szApplication : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t AddERExcludedApplicationA(
    const char* szApplication);
C, "faultrep.dll");
// $ffi->AddERExcludedApplicationA(szApplication);
// szApplication : LPCSTR
// 構造体/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 Faultrep extends StdCallLibrary {
    Faultrep INSTANCE = Native.load("faultrep", Faultrep.class, W32APIOptions.ASCII_OPTIONS);
    boolean AddERExcludedApplicationA(
        String szApplication   // LPCSTR
    );
}
@[Link("faultrep")]
lib Libfaultrep
  fun AddERExcludedApplicationA = AddERExcludedApplicationA(
    szApplication : UInt8*   # LPCSTR
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef AddERExcludedApplicationANative = Int32 Function(Pointer<Utf8>);
typedef AddERExcludedApplicationADart = int Function(Pointer<Utf8>);
final AddERExcludedApplicationA = DynamicLibrary.open('faultrep.dll')
    .lookupFunction<AddERExcludedApplicationANative, AddERExcludedApplicationADart>('AddERExcludedApplicationA');
// szApplication : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function AddERExcludedApplicationA(
  szApplication: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'faultrep.dll' name 'AddERExcludedApplicationA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "AddERExcludedApplicationA"
  c_AddERExcludedApplicationA :: CString -> IO CInt
-- szApplication : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let adderexcludedapplicationa =
  foreign "AddERExcludedApplicationA"
    (string @-> returning int32_t)
(* szApplication : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library faultrep (t "faultrep.dll"))
(cffi:use-foreign-library faultrep)

(cffi:defcfun ("AddERExcludedApplicationA" add-erexcluded-application-a :convention :stdcall) :int32
  (sz-application :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $AddERExcludedApplicationA = Win32::API::More->new('faultrep',
    'BOOL AddERExcludedApplicationA(LPCSTR szApplication)');
# my $ret = $AddERExcludedApplicationA->Call($szApplication);
# szApplication : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い