Use a default path if there are no settings

svn path=/trunk/; revision=30740
This commit is contained in:
Pierre Schweitzer 2007-11-25 15:46:06 +00:00
parent fb7fa3afaf
commit 1b3dd9fe0e

View file

@ -229,6 +229,7 @@ ThreadFunc(LPVOID Context)
BOOL bCancelled = FALSE; BOOL bCancelled = FALSE;
BOOL bTempfile = FALSE; BOOL bTempfile = FALSE;
HKEY hKey; HKEY hKey;
DWORD dwSize = MAX_PATH;
/* built the path for the download */ /* built the path for the download */
p = wcsrchr(SelectedApplication->Location, L'/'); p = wcsrchr(SelectedApplication->Location, L'/');
@ -236,23 +237,42 @@ ThreadFunc(LPVOID Context)
{ {
goto end; goto end;
} }
if (RegOpenKey(HKEY_LOCAL_MACHINE,
TEXT("Software\\ReactOS\\Downloader"), /* Create default download path */
&hKey) != ERROR_SUCCESS) if (GetWindowsDirectory(path, sizeof(path) / sizeof(WCHAR)))
{ {
goto end; WCHAR DPath[256];
int i;
for (i = 0; i < 4; i++)
{
if (i == 3)
{
DPath[i] = '\0';
break;
}
DPath[i] = path[i];
}
LoadString(GetModuleHandle(NULL), IDS_DOWNLOAD_FOLDER, path, sizeof(path) / sizeof(WCHAR));
wcscat((LPWSTR)DPath, path);
wcscpy(path, DPath);
} }
DWORD dwSize = MAX_PATH; if (RegOpenKey(HKEY_LOCAL_MACHINE,
if (RegQueryValueEx(hKey, TEXT("Software\\ReactOS\\Downloader"),
&hKey) == ERROR_SUCCESS)
{
if ((RegQueryValueEx(hKey,
L"DownloadFolder", L"DownloadFolder",
NULL, NULL,
NULL, NULL,
(LPBYTE)&path, (LPBYTE)&path,
&dwSize) != ERROR_SUCCESS) &dwSize) != ERROR_SUCCESS) && (path[0] == 0))
{ {
goto end; goto end;
} }
}
if (GetFileAttributes(path) == 0xFFFFFFFF) if (GetFileAttributes(path) == 0xFFFFFFFF)
if (!CreateDirectory((LPCTSTR)path,NULL)) if (!CreateDirectory((LPCTSTR)path,NULL))