Using CreateProcess() and exit/close the opened Application
<p>I am building a program that would open Sublime text and after a period of time would close the application itself . I can't figure out how to close the application using the existing code .</p>

<p>This is what I have so far :</p>

<pre><code>STARTUPINFO         siStartupInfo;
PROCESS_INFORMATION piProcessInfo;

memset(&amp;siStartupInfo, 0, sizeof(siStartupInfo));
memset(&amp;piProcessInfo, 0, sizeof(piProcessInfo));

siStartupInfo.cb = sizeof(siStartupInfo);

if (CreateProcess(L"C:\\Program Files\\Sublime Text 2\\sublime_text.exe",       
    L" source.cpp",                 
    NULL,
    NULL,
    FALSE,
    CREATE_DEFAULT_ERROR_MODE,
    NULL,
    NULL,
    &amp;siStartupInfo,
    &amp;piProcessInfo) == FALSE)

    WaitForSingleObject(piProcessInfo.hProcess, INFINITE);

::CloseHandle(piProcessInfo.hThread);
::CloseHandle(piProcessInfo.hProcess);
</code></pre>