Ich habe eine Lösung mit @Richard Hodges gefunden. UI Fehlermeldung, wenn ein Programmabsturz zu deaktivieren, indem Sie diesen Wert in der Registrierung zu ändern
#include <Windows.h>
#include <string>
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
int main(int argc, const char**argv) {
while (true) {
TCHAR ProcessName[256];
STARTUPINFO si;
PROCESS_INFORMATION pi;
wcscpy(ProcessName, L"FaultyProgram.exe");
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// Start the child process.
if (!CreateProcess(NULL, // No module name (use command line)
ProcessName, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
CREATE_NEW_CONSOLE, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
printf("CreateProcess failed (%d).\n", GetLastError());
return 0;
}
// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);
// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
return 0;
}
Und der wichtigste Teil ist:
Machen Sie ein neues Programm mit dem diesem Code
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Windows Error Reporting
"DontShowUI"=dword:00000001
anstelle von:
"DontShowUI"=dword:00000000
'CreateProcess' gibt einen Punkt zurück, den Sie abfragen können, nicht wahr? –
sollte ich WaitForSingleObject (pi.hProcess, INFINITE); ? Ist dies der Fall, wenn die Anwendung abgestürzt ist? –
sollte leicht zu lesen, die Dokumentation und ein wenig Test –