1 | Unit WebBrowserUnit;
|
---|
2 |
|
---|
3 | // NewView - a new OS/2 Help Viewer
|
---|
4 | // Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
|
---|
5 | // Copyright 2006-2009 Ronald Brill (rbri at rbri dot de)
|
---|
6 | // This software is released under the Gnu Public License - see readme.txt
|
---|
7 |
|
---|
8 | Interface
|
---|
9 |
|
---|
10 | // Code for running the default browser.
|
---|
11 | // Doesn't implement DDE!
|
---|
12 | Procedure LaunchURL(const aURL: String);
|
---|
13 |
|
---|
14 |
|
---|
15 | Implementation
|
---|
16 |
|
---|
17 | uses
|
---|
18 | PMSHL,
|
---|
19 | OS2Def,
|
---|
20 | ACLUtility,
|
---|
21 | SysUtils,
|
---|
22 | RunProgramUnit,
|
---|
23 | FileUtilsUnit;
|
---|
24 |
|
---|
25 | const
|
---|
26 | PROFILE_KEY_WPURLDEFAULTSETTINGS = 'WPURLDEFAULTSETTINGS';
|
---|
27 |
|
---|
28 |
|
---|
29 | Function GetDefaultBrowserPath : String;
|
---|
30 | begin
|
---|
31 | Result := GetUserProfileString(PROFILE_KEY_WPURLDEFAULTSETTINGS, 'DefaultBrowserExe', '');
|
---|
32 | if Result = '' then
|
---|
33 | begin
|
---|
34 | // try Web Explorer
|
---|
35 | SearchPath('PATH', 'explore.exe', Result);
|
---|
36 | end;
|
---|
37 | end;
|
---|
38 |
|
---|
39 |
|
---|
40 | Function GetDefaultBrowserWorkingDir : String;
|
---|
41 | begin
|
---|
42 | Result := GetUserProfileString(PROFILE_KEY_WPURLDEFAULTSETTINGS, 'DefaultWorkingDir', '');
|
---|
43 | if Result = '' then
|
---|
44 | begin
|
---|
45 | Result := ExtractFilePath(GetDefaultBrowserPath);
|
---|
46 | end;
|
---|
47 | end;
|
---|
48 |
|
---|
49 |
|
---|
50 | Function GetDefaultParameters : String;
|
---|
51 | begin
|
---|
52 | Result := GetUserProfileString(PROFILE_KEY_WPURLDEFAULTSETTINGS, 'DefaultParameters', '');
|
---|
53 | end;
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | Procedure LaunchURL(const aURL: String);
|
---|
58 | var
|
---|
59 | tmpBrowserPath : String;
|
---|
60 | tmpBrowserWorkingDir : String;
|
---|
61 | tmpBrowserParameters : String;
|
---|
62 | begin
|
---|
63 | tmpBrowserPath := GetDefaultBrowserPath;
|
---|
64 | tmpBrowserWorkingDir := GetDefaultBrowserWorkingDir;
|
---|
65 | tmpBrowserParameters := GetDefaultParameters;
|
---|
66 |
|
---|
67 | if tmpBrowserPath = '' then
|
---|
68 | begin
|
---|
69 | raise Exception.Create('You don''t have a default browser configured.');
|
---|
70 | end;
|
---|
71 |
|
---|
72 | if not FileExists(tmpBrowserPath) then
|
---|
73 | begin
|
---|
74 | raise Exception.Create('Browser program doesn''t exist: ' + tmpBrowserPath);
|
---|
75 | end;
|
---|
76 |
|
---|
77 | ChDir(RemoveRightDirectorySeparator(tmpBrowserWorkingDir));
|
---|
78 |
|
---|
79 | LaunchProgram(tmpBrowserPath, tmpBrowserParameters + ' ' + aURL, tmpBrowserWorkingDir);
|
---|
80 | end;
|
---|
81 |
|
---|
82 | Initialization
|
---|
83 | End.
|
---|