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