Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- int wmain(int argc, wchar_t* argv[]) {
- assert(argc > 1);
- // build command line
- wchar_t commandLine[MAX_PATH * 2];
- ::lstrcpyW(commandLine, argv[1]);
- if (argc > 2) {
- ::lstrcatW(commandLine, L" ");
- ::lstrcatW(commandLine, argv[2]);
- }
- PROCESS_INFORMATION pi;
- STARTUPINFO si = { sizeof(si) };
- // create the actual process with the debug flag to avoid an infinite loop
- BOOL bCreated = ::CreateProcessW(nullptr, commandLine, nullptr, nullptr, FALSE, DEBUG_PROCESS, nullptr, nullptr, &si, &pi);
- if (bCreated) {
- WCHAR path[MAX_PATH];
- ::GetModuleFileName(nullptr, path, MAX_PATH);
- *::wcsrchr(path, L'\') = L'