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

WerRemoveExcludedApplication

関数
WERの除外アプリ登録を解除する。
DLLwer.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT WerRemoveExcludedApplication(
    LPCWSTR pwzExeName,
    BOOL bAllUsers
);

パラメーター

名前方向説明
pwzExeNameLPCWSTRin除外登録を解除する実行ファイル名を指すワイド文字列。
bAllUsersBOOLin全ユーザー対象か(TRUE)現在のユーザーのみか(FALSE)を示すブール値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WerRemoveExcludedApplication(
    LPCWSTR pwzExeName,
    BOOL bAllUsers
);
[DllImport("wer.dll", ExactSpelling = true)]
static extern int WerRemoveExcludedApplication(
    [MarshalAs(UnmanagedType.LPWStr)] string pwzExeName,   // LPCWSTR
    bool bAllUsers   // BOOL
);
<DllImport("wer.dll", ExactSpelling:=True)>
Public Shared Function WerRemoveExcludedApplication(
    <MarshalAs(UnmanagedType.LPWStr)> pwzExeName As String,   ' LPCWSTR
    bAllUsers As Boolean   ' BOOL
) As Integer
End Function
' pwzExeName : LPCWSTR
' bAllUsers : BOOL
Declare PtrSafe Function WerRemoveExcludedApplication Lib "wer" ( _
    ByVal pwzExeName As LongPtr, _
    ByVal bAllUsers As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WerRemoveExcludedApplication = ctypes.windll.wer.WerRemoveExcludedApplication
WerRemoveExcludedApplication.restype = ctypes.c_int
WerRemoveExcludedApplication.argtypes = [
    wintypes.LPCWSTR,  # pwzExeName : LPCWSTR
    wintypes.BOOL,  # bAllUsers : BOOL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wer = windows.NewLazySystemDLL("wer.dll")
	procWerRemoveExcludedApplication = wer.NewProc("WerRemoveExcludedApplication")
)

// pwzExeName (LPCWSTR), bAllUsers (BOOL)
r1, _, err := procWerRemoveExcludedApplication.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzExeName))),
	uintptr(bAllUsers),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WerRemoveExcludedApplication(
  pwzExeName: PWideChar;   // LPCWSTR
  bAllUsers: BOOL   // BOOL
): Integer; stdcall;
  external 'wer.dll' name 'WerRemoveExcludedApplication';
result := DllCall("wer\WerRemoveExcludedApplication"
    , "WStr", pwzExeName   ; LPCWSTR
    , "Int", bAllUsers   ; BOOL
    , "Int")   ; return: HRESULT
●WerRemoveExcludedApplication(pwzExeName, bAllUsers) = DLL("wer.dll", "int WerRemoveExcludedApplication(char*, bool)")
# 呼び出し: WerRemoveExcludedApplication(pwzExeName, bAllUsers)
# pwzExeName : LPCWSTR -> "char*"
# bAllUsers : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef WerRemoveExcludedApplicationNative = Int32 Function(Pointer<Utf16>, Int32);
typedef WerRemoveExcludedApplicationDart = int Function(Pointer<Utf16>, int);
final WerRemoveExcludedApplication = DynamicLibrary.open('wer.dll')
    .lookupFunction<WerRemoveExcludedApplicationNative, WerRemoveExcludedApplicationDart>('WerRemoveExcludedApplication');
// pwzExeName : LPCWSTR -> Pointer<Utf16>
// bAllUsers : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WerRemoveExcludedApplication(
  pwzExeName: PWideChar;   // LPCWSTR
  bAllUsers: BOOL   // BOOL
): Integer; stdcall;
  external 'wer.dll' name 'WerRemoveExcludedApplication';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WerRemoveExcludedApplication"
  c_WerRemoveExcludedApplication :: CWString -> CInt -> IO Int32
-- pwzExeName : LPCWSTR -> CWString
-- bAllUsers : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let werremoveexcludedapplication =
  foreign "WerRemoveExcludedApplication"
    ((ptr uint16_t) @-> int32_t @-> returning int32_t)
(* pwzExeName : LPCWSTR -> (ptr uint16_t) *)
(* bAllUsers : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wer (t "wer.dll"))
(cffi:use-foreign-library wer)

(cffi:defcfun ("WerRemoveExcludedApplication" wer-remove-excluded-application :convention :stdcall) :int32
  (pwz-exe-name (:string :encoding :utf-16le))   ; LPCWSTR
  (b-all-users :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WerRemoveExcludedApplication = Win32::API::More->new('wer',
    'int WerRemoveExcludedApplication(LPCWSTR pwzExeName, BOOL bAllUsers)');
# my $ret = $WerRemoveExcludedApplication->Call($pwzExeName, $bAllUsers);
# pwzExeName : LPCWSTR -> LPCWSTR
# bAllUsers : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。