tThe Windows installer no longer hardcodes C:\Program Files, so should work with non-English versions of Windows. - vaccinewars - be a doctor and try to vaccinate the world
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit 53f0a86cc9127b029d4d1933d4db6db256262d7e
parent 0e46ea041de2ddc184132b01bf9f5e6a0c526b8c
Author: Ben Webb 
Date:   Mon, 27 Sep 2004 05:35:18 +0000

The Windows installer no longer hardcodes C:\Program Files, so should work
with non-English versions of Windows.


Diffstat:
  M ChangeLog                           |       2 ++
  M win32/filelist                      |       2 +-
  M win32/setup.c                       |       7 ++++++-
  M win32/util.c                        |      29 +++++++++++++++++++++++++++++
  M win32/util.h                        |       2 ++

5 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
t@@ -10,6 +10,8 @@ cvs
     - Quique's Spanish translation is now available both in standard Spanish
       (es.po) and es_ES.po, which uses drugs slang from Spain
     - Fix for a trivial DOS of the server
+    - Windows installer no longer hardcodes 'C:\Program Files' so should
+      work with non-English versions of Windows
 
 1.5.9   07-06-2003
     - The messages window in the curses client can now be scrolled with the
diff --git a/win32/filelist b/win32/filelist
t@@ -2,7 +2,7 @@
 dopewars-1.5.9
 
 [instdir]
-C:\Program Files\dopewars-1.5.9
+dopewars-1.5.9
 
 [NT Service]
 dopewars-server
diff --git a/win32/setup.c b/win32/setup.c
t@@ -333,6 +333,7 @@ InstData *ReadInstData()
   InstFiles *lastinst = NULL, *lastextra = NULL, *lastkeep = NULL;
   InstLink *lastmenu = NULL, *lastdesktop = NULL;
   char *instdata, *pt, *filename, *line2, *line3, *line4;
+  bstr *idir;
   DWORD filesize;
   InstData *idata;
 
t@@ -351,7 +352,11 @@ InstData *ReadInstData()
   idata->product = bstrdup(pt);
   pt += strlen(pt) + 1;
 
-  idata->installdir = bstrdup(pt);
+  idir = bstr_new();
+  bstr_assign_progfilesdir(idir);
+  bstr_appendpath(idir, pt);
+  idata->installdir = idir->text;
+  bstr_free(idir, FALSE);
   pt += strlen(pt) + 1;
 
   idata->startmenudir = bstrdup(pt);
diff --git a/win32/util.c b/win32/util.c
t@@ -200,6 +200,35 @@ void bstr_assign_curdir(bstr *str)
   bstr_append_curdir(str);
 }
 
+void bstr_assign_progfilesdir(bstr *str)
+{
+  bstr_setlength(str, 0);
+  bstr_append_progfilesdir(str);
+}
+
+void bstr_append_progfilesdir(bstr *str)
+{
+  HKEY key;
+  int len;
+  static const *subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion";
+  static const *subval = "ProgramFilesDir";
+  BOOL ok = FALSE;
+
+  len = str->bufsiz - str->length;
+  if (RegGetValue(HKEY_LOCAL_MACHINE, subkey, subval, RRF_RT_REG_SZ, NULL,
+                  NULL, &len) == ERROR_SUCCESS) {
+    len += 5;
+    bstr_expandby(str, len);
+    if (RegGetValue(HKEY_LOCAL_MACHINE, subkey, subval, RRF_RT_REG_SZ, NULL,
+                    str->text + str->length, &len) == ERROR_SUCCESS) {
+      ok = TRUE;
+    }
+  }
+  if (!ok) {
+    bstr_append(str, "C:\\Program Files");
+  }
+}
+
 void bstr_append_dir(bstr *str, BOOL windir)
 {
   unsigned spaceleft;
diff --git a/win32/util.h b/win32/util.h
t@@ -87,6 +87,8 @@ void bstr_append_windir(bstr *str);
 void bstr_append_curdir(bstr *str);
 void bstr_assign_windir(bstr *str);
 void bstr_assign_curdir(bstr *str);
+void bstr_assign_progfilesdir(bstr *str);
+void bstr_append_progfilesdir(bstr *str);
 
 void DisplayError(const char *errtext, BOOL addsyserr, BOOL fatal);
 void AddInstFiles(char *filename, DWORD filesize, InstFiles **lastpt,