Author: pschweitzer
Date: Sun Nov 25 18:46:06 2007
New Revision: 30740
URL:
http://svn.reactos.org/svn/reactos?rev=30740&view=rev
Log:
Use a default path if there are no settings
Modified:
trunk/rosapps/downloader/download.c
Modified: trunk/rosapps/downloader/download.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/downloader/download.c?rev=…
==============================================================================
--- trunk/rosapps/downloader/download.c (original)
+++ trunk/rosapps/downloader/download.c Sun Nov 25 18:46:06 2007
@@ -229,30 +229,50 @@
BOOL bCancelled = FALSE;
BOOL bTempfile = FALSE;
HKEY hKey;
+ DWORD dwSize = MAX_PATH;
/* built the path for the download */
p = wcsrchr(SelectedApplication->Location, L'/');
if (NULL == p)
- {
- goto end;
- }
- if (RegOpenKey(HKEY_LOCAL_MACHINE,
- TEXT("Software\\ReactOS\\Downloader"),
- &hKey) != ERROR_SUCCESS)
{
goto end;
}
-
- DWORD dwSize = MAX_PATH;
- if (RegQueryValueEx(hKey,
+
+ /* Create default download path */
+ if (GetWindowsDirectory(path, sizeof(path) / sizeof(WCHAR)))
+ {
+ 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);
+ }
+
+ if (RegOpenKey(HKEY_LOCAL_MACHINE,
+ TEXT("Software\\ReactOS\\Downloader"),
+ &hKey) == ERROR_SUCCESS)
+ {
+ if ((RegQueryValueEx(hKey,
L"DownloadFolder",
NULL,
NULL,
(LPBYTE)&path,
- &dwSize) != ERROR_SUCCESS)
- {
- goto end;
+ &dwSize) != ERROR_SUCCESS) && (path[0] == 0))
+ {
+ goto end;
+ }
}
+
+
if (GetFileAttributes(path) == 0xFFFFFFFF)
if (!CreateDirectory((LPCTSTR)path,NULL))