progman: start programs in correct directories

Mikołaj Zalewski mikolaj at zalewski.pl
Wed Oct 18 09:46:07 CDT 2006


On old patch I've found on my disc.
-------------- next part --------------
From 778164c88d67a1981698ec249976385459b33859 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Wed, 18 Oct 2006 16:42:52 +0200
Subject: [PATCH] progman: start the programs in the correct directory

---
 programs/progman/Cs.rc     |    3 +++
 programs/progman/De.rc     |    3 +++
 programs/progman/En.rc     |    3 +++
 programs/progman/Es.rc     |    3 +++
 programs/progman/Fr.rc     |    3 +++
 programs/progman/Hu.rc     |    3 +++
 programs/progman/It.rc     |    3 +++
 programs/progman/Ko.rc     |    3 +++
 programs/progman/Nl.rc     |    3 +++
 programs/progman/No.rc     |    3 +++
 programs/progman/Pt.rc     |    6 ++++++
 programs/progman/Ru.rc     |    3 +++
 programs/progman/Si.rc     |    3 +++
 programs/progman/Tr.rc     |    3 +++
 programs/progman/Xx.rc     |    4 ++++
 programs/progman/Zh.rc     |    3 +++
 programs/progman/main.c    |   10 ++++++++++
 programs/progman/progman.h |    3 +++
 programs/progman/program.c |   12 +++++++++---
 19 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/programs/progman/Cs.rc b/programs/progman/Cs.rc
index ccda8a7..16f5f7e 100644
--- a/programs/progman/Cs.rc
+++ b/programs/progman/Cs.rc
@@ -222,4 +222,7 @@ IDS_PROGRAMS,			"Programy"
 IDS_LIBRARIES_DLL,		"Knihovny (*.dll)"
 IDS_SYMBOL_FILES,		"Soubory ikon"
 IDS_SYMBOLS_ICO,		"Ikony (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/De.rc b/programs/progman/De.rc
index 485c65c..26d47b9 100644
--- a/programs/progman/De.rc
+++ b/programs/progman/De.rc
@@ -217,4 +217,7 @@ IDS_PROGRAMS,			"Programme"
 IDS_LIBRARIES_DLL,		"Bibliotheken (*.dll)"
 IDS_SYMBOL_FILES,		"Symboldateien"
 IDS_SYMBOLS_ICO,		"Symbole (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/En.rc b/programs/progman/En.rc
index e893364..fe9b67d 100644
--- a/programs/progman/En.rc
+++ b/programs/progman/En.rc
@@ -218,6 +218,9 @@ IDS_PROGRAMS,			"Programs"
 IDS_LIBRARIES_DLL,		"Libraries (*.dll)"
 IDS_SYMBOL_FILES,		"Icon files"
 IDS_SYMBOLS_ICO,		"Icons (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
 
 STRINGTABLE DISCARDABLE LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
diff --git a/programs/progman/Es.rc b/programs/progman/Es.rc
index 4f536b2..130fc1f 100644
--- a/programs/progman/Es.rc
+++ b/programs/progman/Es.rc
@@ -212,4 +212,7 @@ IDS_PROGRAMS,			"Programas"
 IDS_LIBRARIES_DLL,		"Librarías (*.dll)"
 IDS_SYMBOL_FILES,		"Archivos de iconos"
 IDS_SYMBOLS_ICO,		"Iconos (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/Fr.rc b/programs/progman/Fr.rc
index 39a9be6..961ecda 100644
--- a/programs/progman/Fr.rc
+++ b/programs/progman/Fr.rc
@@ -216,6 +216,9 @@ IDS_PROGRAMS,			"Programmes"
 IDS_LIBRARIES_DLL,		"Bibliothèques (*.dll)"
 IDS_SYMBOL_FILES,		"Icônes"
 IDS_SYMBOLS_ICO,		"Icônes (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
 
 STRINGTABLE DISCARDABLE LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
diff --git a/programs/progman/Hu.rc b/programs/progman/Hu.rc
index 854289e..b7bbaef 100644
--- a/programs/progman/Hu.rc
+++ b/programs/progman/Hu.rc
@@ -219,4 +219,7 @@ IDS_PROGRAMS,			"Programok"
 IDS_LIBRARIES_DLL,		"Eljáráskönyvtár (*.dll)"
 IDS_SYMBOL_FILES,		"Ikon fájlok"
 IDS_SYMBOLS_ICO,		"Ikonok (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/It.rc b/programs/progman/It.rc
index 0a7cfe4..136f4d7 100644
--- a/programs/progman/It.rc
+++ b/programs/progman/It.rc
@@ -219,4 +219,7 @@ IDS_PROGRAMS,			"Programmi"
 IDS_LIBRARIES_DLL,		"Librerie (*.dll)"
 IDS_SYMBOL_FILES,		"File icona"
 IDS_SYMBOLS_ICO,		"Icone (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/Ko.rc b/programs/progman/Ko.rc
index e2d1f6e..d5ae613 100644
--- a/programs/progman/Ko.rc
+++ b/programs/progman/Ko.rc
@@ -217,6 +217,9 @@ IDS_PROGRAMS,			"Ç®±×¸²"
 IDS_LIBRARIES_DLL,		"¶óÀ̺귯¸® ÆÄÀÏ(*.dll)"
 IDS_SYMBOL_FILES,		"¾ÆÀÌÄÜ ÆÄÀÏ"
 IDS_SYMBOLS_ICO,		"¾ÆÀÌÄÜ (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
 
 STRINGTABLE DISCARDABLE LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
diff --git a/programs/progman/Nl.rc b/programs/progman/Nl.rc
index 06319e3..616fb56 100644
--- a/programs/progman/Nl.rc
+++ b/programs/progman/Nl.rc
@@ -217,4 +217,7 @@ IDS_PROGRAMS,			"Programma's"
 IDS_LIBRARIES_DLL,		"Programmabibliotheekbestanden (*.dll)"
 IDS_SYMBOL_FILES,		"Pictogrambestanden"
 IDS_SYMBOLS_ICO,		"Pictogrammen (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/No.rc b/programs/progman/No.rc
index feedbfa..1bbafa5 100644
--- a/programs/progman/No.rc
+++ b/programs/progman/No.rc
@@ -217,6 +217,9 @@ IDS_PROGRAMS,			"Programmer"
 IDS_LIBRARIES_DLL,		"Biblioteker (*.dll)"
 IDS_SYMBOL_FILES,		"Ikonfiler"
 IDS_SYMBOLS_ICO,		"Ikoner (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
 
 STRINGTABLE DISCARDABLE LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
diff --git a/programs/progman/Pt.rc b/programs/progman/Pt.rc
index 06ad271..cea179e 100644
--- a/programs/progman/Pt.rc
+++ b/programs/progman/Pt.rc
@@ -312,6 +312,9 @@ IDS_PROGRAMS,			"Programas"
 IDS_LIBRARIES_DLL,		"Bibliotecas (*.dll)"
 IDS_SYMBOL_FILES,		"Arquivos de ícones"
 IDS_SYMBOLS_ICO,		"Ícones (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
 
 LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE
@@ -340,4 +343,7 @@ IDS_PROGRAMS,			"Programas"
 IDS_LIBRARIES_DLL,		"Bibliotecas (*.dll)"
 IDS_SYMBOL_FILES,		"Ficheiros de ícones"
 IDS_SYMBOLS_ICO,		"Ícones (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/Ru.rc b/programs/progman/Ru.rc
index 6b68b92..193b32f 100644
--- a/programs/progman/Ru.rc
+++ b/programs/progman/Ru.rc
@@ -218,4 +218,7 @@ IDS_PROGRAMS,			"Ïðîãðàììû"
 IDS_LIBRARIES_DLL,		"Áèáëèîòåêè (*.dll)"
 IDS_SYMBOL_FILES,		"Ôàéëû çíà÷êîâ"
 IDS_SYMBOLS_ICO,		"Çíà÷êè (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/Si.rc b/programs/progman/Si.rc
index 838e2a2..3e87a29 100644
--- a/programs/progman/Si.rc
+++ b/programs/progman/Si.rc
@@ -218,4 +218,7 @@ IDS_PROGRAMS,			"Programi"
 IDS_LIBRARIES_DLL,		"Knjižnice (*.dll)"
 IDS_SYMBOL_FILES,		"Ikonske datoteke"
 IDS_SYMBOLS_ICO,		"Ikone (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/Tr.rc b/programs/progman/Tr.rc
index a9ba7fd..d5b9ff9 100644
--- a/programs/progman/Tr.rc
+++ b/programs/progman/Tr.rc
@@ -217,4 +217,7 @@ IDS_PROGRAMS,			"Programlar"
 IDS_LIBRARIES_DLL,		"Kitaplýklar (*.dll)"
 IDS_SYMBOL_FILES,		"Simge dosyalarý"
 IDS_SYMBOLS_ICO,		"Simgeler (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/Xx.rc b/programs/progman/Xx.rc
index 8ffd828..f53850a 100644
--- a/programs/progman/Xx.rc
+++ b/programs/progman/Xx.rc
@@ -216,6 +216,8 @@ ADDSTRING(PROGRAMS)
 ADDSTRING(LIBRARIES_DLL)
 ADDSTRING(SYMBOL_FILES)
 ADDSTRING(SYMBOLS_ICO)
+ADDSTRING(WRONG_WINDOWS_DIR_s)
+ADDSTRING(CHDIR_ERROR_s)
 }
 
 
@@ -310,3 +312,5 @@ #undef STRING_PROGRAMS
 #undef STRING_LIBRARIES_DLL
 #undef STRING_SYMBOL_FILES
 #undef STRING_SYMBOLS_ICO
+#undef STRING_WRONG_WINDOWS_DIR_s
+#under STRING_CHDIR_ERROR_s
diff --git a/programs/progman/Zh.rc b/programs/progman/Zh.rc
index dfbfb26..1d5ae8b 100644
--- a/programs/progman/Zh.rc
+++ b/programs/progman/Zh.rc
@@ -218,4 +218,7 @@ IDS_PROGRAMS,			"³ÌÐò"
 IDS_LIBRARIES_DLL,		"¶¯Ì¬Á¬½Ó¿â (*.dll)"
 IDS_SYMBOL_FILES,		"ͼ±êÎļþ"
 IDS_SYMBOLS_ICO,		"ͼ±ê (*.ico)"
+/*** not translated yet ***/
+IDS_WRONG_WINDOWS_DIR_s, "Couldn't enter the Windows directory `%s'! All programs may run incorrectly"
+IDS_CHDIR_ERROR_s, "The program working directory `%s' is invalid"
 }
diff --git a/programs/progman/main.c b/programs/progman/main.c
index 0671ac2..946003a 100644
--- a/programs/progman/main.c
+++ b/programs/progman/main.c
@@ -52,6 +52,8 @@ int PASCAL WinMain (HINSTANCE hInstance,
   Globals.hInstance           = hInstance;
   Globals.hGroups             = 0;
   Globals.hActiveGroup        = 0;
+  
+  GetWindowsDirectory(Globals.szWindowsDirectory, MAX_PATHNAME_LEN);
 
   /* Read Options from `progman.ini' */
   Globals.bAutoArrange =
@@ -81,6 +83,14 @@ int PASCAL WinMain (HINSTANCE hInstance,
   MAIN_CreateMainWindow();
   Globals.hAccel = LoadAccelerators(Globals.hInstance, STRING_ACCEL);
 
+  /* Set the current directory to the Windows directory */
+  if (!SetCurrentDirectory(Globals.szWindowsDirectory))
+  {
+    MAIN_MessageBoxIDS_s(IDS_WRONG_WINDOWS_DIR_s, Globals.szWindowsDirectory,
+      IDS_ERROR, MB_ICONEXCLAMATION | MB_OK);
+    /* try to continue anyway */
+  }
+
   /* Setup menu, stringtable and resourcenames */
   STRING_LoadMenus();
 
diff --git a/programs/progman/progman.h b/programs/progman/progman.h
index 59004b9..b4ede82 100644
--- a/programs/progman/progman.h
+++ b/programs/progman/progman.h
@@ -132,6 +132,7 @@ typedef struct
   BOOL    bMinOnRun;
   HLOCAL  hGroups;
   HLOCAL  hActiveGroup;
+  CHAR    szWindowsDirectory[MAX_PATHNAME_LEN];
 } GLOBALS;
 
 extern GLOBALS Globals;
@@ -232,6 +233,8 @@ #define IDS_PROGRAMS                   0
 #define IDS_LIBRARIES_DLL              0x15
 #define IDS_SYMBOL_FILES               0x16
 #define IDS_SYMBOLS_ICO                0x17
+#define IDS_WRONG_WINDOWS_DIR_s        0x18
+#define IDS_CHDIR_ERROR_s              0x19
 
 #define IDS_LICENSE_CAPTION            0x20
 #define IDS_LICENSE                    0x21
diff --git a/programs/progman/program.c b/programs/progman/program.c
index 347378c..86cd39c 100644
--- a/programs/progman/program.c
+++ b/programs/progman/program.c
@@ -274,11 +274,17 @@ VOID PROGRAM_ExecuteProgram(HLOCAL hProg
   LPSTR lpszCmdLine = LocalLock(program->hCmdLine);
   LPSTR lpszWorkDir = LocalLock(program->hWorkDir);
 
-  /* FIXME set working directory */
-  lpszWorkDir = lpszWorkDir;
+  if (!SetCurrentDirectory(lpszWorkDir))
+  {
+    MAIN_MessageBoxIDS_s(IDS_CHDIR_ERROR_s, lpszWorkDir, IDS_ERROR,
+      MB_ICONEXCLAMATION | MB_OK);
+    return;
+  }
 
   WinExec(lpszCmdLine, program->nCmdShow);
-  if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
+  SetCurrentDirectory(Globals.szWindowsDirectory);
+  if (Globals.bMinOnRun)
+    CloseWindow(Globals.hMainWnd);
 }
 
 /***********************************************************************
-- 
1.4.2.3


More information about the wine-patches mailing list