Mercurial > dwindows
comparison os2/dw.c @ 170:ee6858b7d1c3
Set DefaultWorkingDir before trying to start the web browser.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 30 Nov 2002 14:43:57 +0000 |
parents | b2211123274e |
children | b8e93557b2c7 |
comparison
equal
deleted
inserted
replaced
169:b2211123274e | 170:ee6858b7d1c3 |
---|---|
20 #include <stdarg.h> | 20 #include <stdarg.h> |
21 #include <stddef.h> | 21 #include <stddef.h> |
22 #include <ctype.h> | 22 #include <ctype.h> |
23 #include <process.h> | 23 #include <process.h> |
24 #include <time.h> | 24 #include <time.h> |
25 #include <direct.h> | |
25 #include "dw.h" | 26 #include "dw.h" |
26 | 27 |
27 #define QWP_USER 0 | 28 #define QWP_USER 0 |
28 | 29 |
29 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); | 30 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); |
7247 } | 7248 } |
7248 } | 7249 } |
7249 return NULL; | 7250 return NULL; |
7250 } | 7251 } |
7251 | 7252 |
7253 /* Internal function to set drive and directory */ | |
7254 int _SetPath(char *path) | |
7255 { | |
7256 if(strlen(path) > 2) | |
7257 { | |
7258 if(path[1] == ':') | |
7259 { | |
7260 char drive = toupper(path[0]); | |
7261 _chdrive((drive - 'A')+1); | |
7262 } | |
7263 } | |
7264 return chdir(path); | |
7265 } | |
7266 | |
7252 /* | 7267 /* |
7253 * Execute and external program in a seperate session. | 7268 * Execute and external program in a seperate session. |
7254 * Parameters: | 7269 * Parameters: |
7255 * program: Program name with optional path. | 7270 * program: Program name with optional path. |
7256 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | 7271 * type: Either DW_EXEC_CON or DW_EXEC_GUI. |
7269 * url: Uniform resource locator. | 7284 * url: Uniform resource locator. |
7270 */ | 7285 */ |
7271 int dw_browse(char *url) | 7286 int dw_browse(char *url) |
7272 { | 7287 { |
7273 /* Is there a way to find the webbrowser in Unix? */ | 7288 /* Is there a way to find the webbrowser in Unix? */ |
7274 char *execargs[3], browser[1024], *newurl = NULL; | 7289 char *execargs[3], browser[1024], *olddir, *newurl = NULL; |
7275 int len; | 7290 int len, ret; |
7291 | |
7292 olddir = _getcwd(NULL, 1024); | |
7293 | |
7294 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", | |
7295 "DefaultWorkingDir", NULL, browser, 1024); | |
7296 | |
7297 if(browser[0]) | |
7298 _SetPath(browser); | |
7276 | 7299 |
7277 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", | 7300 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", |
7278 "DefaultBrowserExe", NULL, browser, 1024); | 7301 "DefaultBrowserExe", NULL, browser, 1024); |
7279 | 7302 |
7280 len = strlen(browser) - strlen("explore.exe"); | 7303 len = strlen(browser) - strlen("explore.exe"); |
7303 } | 7326 } |
7304 execargs[1] = newurl; | 7327 execargs[1] = newurl; |
7305 } | 7328 } |
7306 } | 7329 } |
7307 | 7330 |
7308 return dw_exec(browser, DW_EXEC_GUI, execargs); | 7331 ret = dw_exec(browser, DW_EXEC_GUI, execargs); |
7332 | |
7333 if(olddir) | |
7334 { | |
7335 _SetPath(olddir); | |
7336 free(olddir); | |
7337 } | |
7338 return ret; | |
7309 } | 7339 } |
7310 | 7340 |
7311 /* | 7341 /* |
7312 * Returns a pointer to a static buffer which containes the | 7342 * Returns a pointer to a static buffer which containes the |
7313 * current user directory. Or the root directory (C:\ on | 7343 * current user directory. Or the root directory (C:\ on |