source: trunk/Components/WebBrowserUnit.pas@ 15

Last change on this file since 15 was 15, checked in by RBRi, 19 years ago

+ components stuff

  • Property svn:eol-style set to native
File size: 1.7 KB
RevLine 
[15]1Unit 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
7Interface
8
9// Code for running the default browser.
10// Doesn't implement DDE!
11
12procedure LaunchURL( const URL: string );
13
14Implementation
15
16uses
17 PMSHL, OS2Def,
18 ACLFileUtility, ACLUtility, ACLDialogs, SysUtils, RunProgramUnit;
19
20function GetDefaultBrowserPath: string;
21begin
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;
30end;
31
32function GetDefaultBrowserWorkingDir: string;
33begin
34 Result := GetUserProfileString( 'WPURLDEFAULTSETTINGS',
35 'DefaultWorkingDir',
36 '' );
37 if Result = '' then
38 begin
39 Result := ExtractFilePath( GetDefaultBrowserPath );
40 end;
41
42end;
43
44procedure LaunchURL( const URL: string );
45var
46 BrowserPath: string;
47 BrowserWorkingDir: string;
48begin
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 );
71end;
72
73Initialization
74End.
Note: See TracBrowser for help on using the repository browser.