コード例 #1
0
ファイル: dirstatdoc.cpp プロジェクト: JDuverge/windirstat
void CDirstatDoc::CallUserDefinedCleanup(bool isDirectory, const CString& format, const CString& rootPath, const CString& currentPath, bool showConsoleWindow, bool wait)
{
    CString userCommandLine = BuildUserDefinedCleanupCommandLine(format, rootPath, currentPath);

    CString app = GetCOMSPEC();
    CString cmdline;
    cmdline.Format(_T("%s /C %s"), GetBaseNameFromPath(app), userCommandLine);
    CString directory = isDirectory ? currentPath : GetFolderNameFromPath(currentPath);

    STARTUPINFO si;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = showConsoleWindow ? SW_SHOWNORMAL : SW_HIDE;

    PROCESS_INFORMATION pi;
    ZeroMemory(&pi, sizeof(pi));

    BOOL b = CreateProcess(
        app,
        cmdline.GetBuffer(),
        NULL,
        NULL,
        false,
        0,
        NULL,
        directory,
        &si,
        &pi
    );
    cmdline.ReleaseBuffer();
    if(!b)
    {
        MdThrowStringExceptionF(IDS_COULDNOTCREATEPROCESSssss,
            app, cmdline, directory, MdGetWinErrorText(::GetLastError())
        );
        return;
    }

    CloseHandle(pi.hThread);

    if(wait)
    {
        WaitForHandleWithRepainting(pi.hProcess);
    }

    CloseHandle(pi.hProcess);
}
コード例 #2
0
void CDirstatDoc::OnCommandPromptHere()
{
	try
	{
		CItem *item= GetSelection();
		ASSERT(item != NULL);
		
		CString cmd= GetCOMSPEC();

		MyShellExecute(*AfxGetMainWnd(), _T("open"), cmd, NULL, item->GetFolderPath(), SW_SHOWNORMAL);
	}
	catch (CException *pe)
	{
		pe->ReportError();
		pe->Delete();
	}
}