Last active
July 16, 2020 21:28
-
-
Save iljavs/d0a7d34cb207156fedc72f6add9a2723 to your computer and use it in GitHub Desktop.
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 <stdio.h> | |
#include <windows.h> | |
int main(){ | |
STARTUPINFOW su; | |
PROCESS_INFORMATION pi; | |
memset(&su, 0x00, sizeof(su)); | |
memset(&pi, 0x00, sizeof(pi)); | |
su.cb = sizeof(su); | |
int r = CreateProcessW(L"c:\\windows\\system32\\mspaint.exe", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &su, &pi); | |
if (r) { | |
printf("CreateProcess() worked\n"); | |
DWORD r = WaitForSingleObject(pi.hProcess, 10000); | |
if (r == WAIT_OBJECT_0) { | |
printf("process closed\n"); | |
} | |
else { | |
printf("Process is still running\n"); | |
} | |
} | |
else { | |
DWORD e = GetLastError(); | |
printf("CreateProcess() failed :(, error: 0x%x \n", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment