using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
class Program
{
[DllImport("wer.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public extern static int WerAddExcludedApplication(string exeName, bool allUsers);
[DllImport("wer.dll", CharSet = CharSet.Unicode)]
public extern static int WerRemoveExcludedApplication(string exeName, bool allUsers);
static void Main(string[] args)
{
string exeName = Process.GetCurrentProcess().ProcessName + ".exe";
Console.WriteLine(exeName);
int result = WerAddExcludedApplication(exeName, true);
int win32Error = Marshal.GetLastWin32Error();
if (result != 0)
{
Console.WriteLine("Error: " + result + ", Win32Error: " + win32Error);
// 1300: Not all privileges or groups referenced are assigned to the caller.
}
Console.ReadLine();
WerRemoveExcludedApplication(exeName, true);
}
}