Bug 290735 - When launching a file use download path as working directory. r=jimm

This commit is contained in:
Brian R. Bondy 2012-05-14 09:19:22 -04:00
parent a7a14d5740
commit 4ff5da23f1

View File

@ -254,8 +254,20 @@ private:
seinfo.lpDirectory = NULL;
seinfo.nShow = SW_SHOWNORMAL;
if (ShellExecuteExW(&seinfo))
// Use the directory of the file we're launching as the working
// directory. That way if we have a self extracting EXE it won't
// suggest to extract to the install directory.
WCHAR workingDirectory[MAX_PATH + 1] = { L'\0' };
wcsncpy(workingDirectory, mResolvedPath.get(), MAX_PATH);
if (PathRemoveFileSpecW(workingDirectory)) {
seinfo.lpDirectory = workingDirectory;
} else {
NS_WARNING("Could not set working directory for launched file.");
}
if (ShellExecuteExW(&seinfo)) {
return NS_OK;
}
DWORD r = GetLastError();
// if the file has no association, we launch windows'
// "what do you want to do" dialog