bool FileSystemManager::launchFile(QString filePath, LPWSTR verb) { int rcVal = 0; // check if we should use the pidl LPCITEMIDLIST pidl = NULL; int virtualIconIndex = winOS->GetIconTypeFromFileName(filePath); if (virtualIconIndex > -1) pidl = winOS->GetPidlFromName(virtualIconIndex); // ensure that all the arguments are quoted QString wPath(filePath); ensureQuoted(wPath); SHELLEXECUTEINFO sei = {0}; sei.cbSize = sizeof(sei); sei.hwnd = winOS->GetWindowsHandle(); sei.lpVerb = verb; if (pidl) sei.lpIDList = (LPVOID) pidl; else sei.lpFile = (LPCTSTR) wPath.utf16(); sei.nShow = SW_SHOWNORMAL; return launchFile(sei,filePath); }
//return should I Quit this explore( path ) AndReenter using expore( void ) // only return true after change current dir. PSP_FileManager ::ExploreResult PSP_FileManager ::handleKeyCirclePressed ( CommonString &updatePathString, CommonString *selectedFilename ) { //const SceIoDirent *tempDirt = this->getItem( this->seletedFileItemIndex ); const dirent *tempDirt = this->getItem( this->seletedFileItemIndex ); if ( tempDirt-> d_stat.st_attr == FIO_SO_IFDIR ) { // Handle Dir ExploreResult r; r = handlePressDir ( updatePathString , tempDirt ); if ( r == reEnter ) { setTitle ( updatePathString.getChar_p_readonly() ); } return r; } else { CommonString selectedFile; selectedFile = updatePathString ; selectedFile.append( (unsigned char *) tempDirt->d_name ); if( selectedFilename ) { // Here Working fileSelector mode , select a file then doneExplore // update the return file name string *selectedFilename = selectedFile; //showMessage ( (char*)selectedFilename->getChar_p_readonly() ); return doneExplore; }else { // working in Explorer mode, select file and then laugch launchFile ( selectedFile ); refresh(); return notDone; } } // refresh(); // this->showMessage( "Quiting handleKeyCirclePressed() " ); return notDone; }
bool FileSystemManager::launchFile(QString filePath, QString arguments, QString workingDir, bool runAsElevated, bool quoteArgs, bool async) { QString errMsg; int rcVal = 0; // check if we should use the pidl LPCITEMIDLIST pidl = NULL; int virtualIconIndex = winOS->GetIconTypeFromFileName(filePath); if (virtualIconIndex > -1) pidl = winOS->GetPidlFromName(virtualIconIndex); // ensure that all the arguments are quoted QString wPath(filePath), wArgs(arguments), wDir(workingDir); ensureQuoted(wPath); if (quoteArgs) ensureQuoted(wArgs); ensureQuoted(wDir); // Try executing the file // Trying with ShellExecuteEx to see if we can fix the problems with .lnk not launching SHELLEXECUTEINFO sei = {0}; sei.cbSize = sizeof(sei); // #define SEE_MASK_NOZONECHECKS 0x00800000 sei.fMask = SEE_MASK_FLAG_LOG_USAGE | (pidl ? SEE_MASK_IDLIST : 0) | (async ? SEE_MASK_ASYNCOK : 0) | 0x00800000; sei.hwnd = winOS->GetWindowsHandle(); if (winOS->IsWindowsVersionGreaterThanOrEqualTo(WindowsVista) && runAsElevated) sei.lpVerb = L"runas"; // 'secret' verb to prompt for elevation on Vista else sei.lpVerb = NULL; // giving a null value for the verb forces it to use the default verb if (pidl) sei.lpIDList = (LPVOID) pidl; else sei.lpFile = (LPCTSTR) wPath.utf16(); sei.lpParameters = (LPCTSTR) wArgs.utf16(); sei.lpDirectory = (LPCTSTR) wDir.utf16(); sei.nShow = SW_SHOWNORMAL; return launchFile(sei,filePath); }
bool FileSystemManager::launchFileAsync(QString filePath, QString arguments, QString workingDir, bool runAsElevated, bool quoteArgs) { return launchFile(filePath, arguments, workingDir, runAsElevated, quoteArgs, true); }