void CSetupApp::DoStartApplication() { try { MyShellExecute(NULL, _T("open"), GetDestExecutable(), NULL, NULL, SW_SHOWNORMAL); } catch (CException *pe) { pe->ReportError(); pe->Delete(); } }
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(); } }
void CDirstatDoc::OnExplorerHere() { try { const CItem *item= GetSelection(); ASSERT(item != NULL); if (item->GetType() == IT_MYCOMPUTER) { SHELLEXECUTEINFO sei; ZeroMemory(&sei, sizeof(sei)); sei.cbSize= sizeof(sei); sei.hwnd= *AfxGetMainWnd(); sei.lpVerb= _T("explore"); sei.nShow= SW_SHOWNORMAL; CCoTaskMem<LPITEMIDLIST> pidl; GetPidlOfMyComputer(&pidl); sei.lpIDList= pidl; sei.fMask|= SEE_MASK_IDLIST; ShellExecuteEx(&sei); // ShellExecuteEx seems to display its own Messagebox on error. } else { MyShellExecute(*AfxGetMainWnd(), _T("explore"), item->GetFolderPath(), NULL, NULL, SW_SHOWNORMAL); } } catch (CException *pe) { pe->ReportError(); pe->Delete(); } }
/////////////////////////////////////////////////////////////// // // SharedUtil::ShellExecuteNonBlocking // // // /////////////////////////////////////////////////////////////// bool SharedUtil::ShellExecuteNonBlocking ( const SString& strAction, const SString& strFile, const SString& strParameters, const SString& strDirectory, int nShowCmd ) { return MyShellExecute ( false, strAction, strFile, strParameters, strDirectory ); }