Last active
July 9, 2018 15:13
-
-
Save ElyDotDev/53452042b48a6b6090c0311b879e6e00 to your computer and use it in GitHub Desktop.
windows-kill-library Usage examples. http://projects.allii.ir/list/windows-kill-library/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdexcept> | |
#include "windows-kill-library.h" | |
using WindowsKillLibrary::sendSignal; | |
using WindowsKillLibrary::SIGNAL_TYPE_CTRL_C; | |
using WindowsKillLibrary::SIGNAL_TYPE_CTRL_BREAK; | |
try { | |
sendSignal(signal_pid, signal_type); | |
std::cout << "Signal sent successfuly. type: " << signal_type << " | pid: " << signal_pid << "\n"; | |
} | |
catch (const std::invalid_argument& exception) { | |
if (strcmp(exception.what(), "ESRCH") == 0) { | |
std::cout << "Error: Pid dosen't exist." << std::endl; | |
} | |
else if(strcmp(exception.what(), "EINVAL") == 0){ | |
std::cout << "Error: Invalid signal type." << std::endl; | |
} | |
else { | |
std::cout << "InvalidArgument: windows-kill-library:" << exception.what() << std::endl; | |
} | |
} | |
catch (const std::system_error& exception) { | |
std::cout << "SystemError " << exception.code() << ": " << exception.what() << std::endl; | |
} | |
catch (const std::runtime_error& exception) { | |
if (strcmp(exception.what(), "EPERM") == 0) { | |
std::cout << "Not enough permission to send the signal." << std::endl; | |
} | |
else { | |
std::cout << "RuntimeError: windows-kill-library:" << exception.what() << std::endl; | |
} | |
} | |
catch (const std::exception& exception) { | |
std::cout << "Error: windows-kill-library:" << exception.what() << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Sends the signal. | |
/// </summary> | |
/// <param name="signal_pid">The signal target process id.</param> | |
/// <param name="signal_type">The signal type.</param> | |
void sendSignal(DWORD signal_pid, DWORD signal_type); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment