[RAPPS]
[reactos.git] / reactos / base / applications / rapps / loaddlg.c
index 206eb39..c4c17ff 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#define COBJMACROS
-#define WIN32_NO_STATUS
-
 #include "rapps.h"
-#include "resource.h"
-
-#include <commctrl.h>
-#include <shlobj.h>
-#include <shlwapi.h>
-#include <urlmon.h>
 
 static PAPPLICATION_INFO AppInfo;
 static HICON hIcon = NULL;
@@ -236,12 +227,16 @@ ThreadFunc(LPVOID Context)
             AppInfo->szUrlDownload[len - 1] == 'b')
         {
             bCab = TRUE;
-            if (!GetCurrentDirectoryW(MAX_PATH, path))
+            if (!GetStorageDirectory(path, sizeof(path) / sizeof(path[0])))
                 goto end;
         }
         else
         {
-            wcscpy(path, SettingsInfo.szDownloadDir);
+            if (FAILED(StringCbCopyW(path, sizeof(path),
+                                     SettingsInfo.szDownloadDir)))
+            {
+                goto end;
+            }
         }
     }
     else goto end;
@@ -252,8 +247,10 @@ ThreadFunc(LPVOID Context)
             goto end;
     }
 
-    wcscat(path, L"\\");
-    wcscat(path, p + 1);
+    if (FAILED(StringCbCatW(path, sizeof(path), L"\\")))
+        goto end;
+    if (FAILED(StringCbCatW(path, sizeof(path), p + 1)))
+        goto end;
 
     /* download it */
     bTempfile = TRUE;
@@ -266,7 +263,7 @@ ThreadFunc(LPVOID Context)
     ShowWindow(Dlg, SW_HIDE);
 
     /* run it */
-    memset(&si, 0, sizeof(si));
+    ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
     r = CreateProcessW(path, NULL, NULL, NULL, 0, 0, NULL, NULL, &si, &pi);
     if (0 == r) goto end;
@@ -362,7 +359,12 @@ DownloadApplicationsDB(LPWSTR lpUrl)
     APPLICATION_INFO IntInfo;
 
     ZeroMemory(&IntInfo, sizeof(APPLICATION_INFO));
-    wcscpy(IntInfo.szUrlDownload, lpUrl);
+    if (FAILED(StringCbCopyW(IntInfo.szUrlDownload,
+                             sizeof(IntInfo.szUrlDownload),
+                             lpUrl)))
+    {
+        return;
+    }
 
     AppInfo = &IntInfo;