Skip to content

Instantly share code, notes, and snippets.

@the-nose-knows
Last active May 4, 2017 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-nose-knows/b1ec3f2697e4bf4d8ab8dd1fc6cec4b8 to your computer and use it in GitHub Desktop.
Save the-nose-knows/b1ec3f2697e4bf4d8ab8dd1fc6cec4b8 to your computer and use it in GitHub Desktop.
#include "Windows.h"
#include "tchar.h"
#include "stdio.h"
#include "stdlib.h"
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFOA startup_info = { 0 };
LPSTARTUPINFOA p_startup_info = &startup_info;
PROCESS_INFORMATION proc_info = { 0 };
LPPROCESS_INFORMATION p_proc_info = &proc_info;
if (!CreateProcess(("C:\\WINDOWS\\system32\\calc.exe"),
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
"C:\\WINDOWS\\system32",
p_startup_info,
p_proc_info))
{
printf("Doh!\n");
}
else
{
DWORD PID = GetProcessId(p_proc_info->hProcess);
printf("PID: %u\n", PID);
std::string task_killer = std::string("taskkill /F /T /PID ") + std::to_string(PID);
int result = system(task_killer.c_str());
return result;
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment