source: trunk/NewView/WebBrowserUnit.pas@ 92

Last change on this file since 92 was 92, checked in by RBRi, 18 years ago

again small refactoring

  • Property svn:eol-style set to native
File size: 1.7 KB
RevLine 
[92]1Unit WebBrowserUnit;
2
3// NewView - a new OS/2 Help Viewer
4// Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
5// Copyright 2006-2007 Ronald Brill (rbri at rbri dot de)
6// This software is released under the Gnu Public License - see readme.txt
7
8Interface
9
10 // Code for running the default browser.
11 // Doesn't implement DDE!
12 Procedure LaunchURL(const aURL: String);
13
14
15Implementation
16
17uses
18 PMSHL,
19 OS2Def,
20 ACLUtility,
21 SysUtils,
22 RunProgramUnit,
23 FileUtilsUnit;
24
25const
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 Procedure LaunchURL(const aURL: String);
51 var
52 tmpBrowserPath : String;
53 tmpBrowserWorkingDir : String;
54 begin
55 tmpBrowserPath := GetDefaultBrowserPath;
56 tmpBrowserWorkingDir := GetDefaultBrowserWorkingDir;
57 if tmpBrowserPath = '' then
58 begin
59 raise Exception.Create('You don''t have a default browser configured.');
60 end;
61
62 if not FileExists(tmpBrowserPath) then
63 begin
64 raise Exception.Create('Browser program doesn''t exist: ' + tmpBrowserPath);
65 end;
66
67 ChDir(RemoveRightDirectorySeparator(tmpBrowserWorkingDir));
68
69 LaunchProgram(tmpBrowserPath, aURL, tmpBrowserWorkingDir);
70 end;
71
72Initialization
73End.
Note: See TracBrowser for help on using the repository browser.