-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplicationenvironment.pas
More file actions
101 lines (86 loc) · 2.67 KB
/
applicationenvironment.pas
File metadata and controls
101 lines (86 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit ApplicationEnvironment;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, lazfileutils, Dialogs;
type
{ TApplicationEnvironment }
TApplicationEnvironment = class
private
public
procedure CreateFolder(const BaseFolderPath : string; const NewFolderName : string);
procedure CreateSettingsFile(SettingsFileName : string);
function CheckDllFiles : Boolean;
end;
implementation
uses Settings;
{ TApplicationEnvironment }
procedure TApplicationEnvironment.CreateFolder(const BaseFolderPath: string;
const NewFolderName: string);
begin
if not DirectoryExists(BaseFolderPath + NewFolderName) then
begin
if DirectoryIsWritable(BaseFolderPath) then
begin
CreateDir(BaseFolderPath+NewFolderName);
end
else
begin
MessageDlg('Fout.', 'U heeft geen schrijfrechten in de map.' + '', mtWarning, [mbOk], 0);
end;
end;
end;
procedure TApplicationEnvironment.CreateSettingsFile(SettingsFileName: string);
var
UserName : string;
tfOut: TextFile;
begin
UserName := StringReplace(GetEnvironmentVariable('USERNAME') , ' ', '_', [rfIgnoreCase, rfReplaceAll]) + '_';
SettingsFileName := SettingsFileName + UserName + Settings.ConfigurationFile;
if not FileExists(SettingsFileName) then
begin
try
AssignFile(tfOut, SettingsFileName);
//FileCreate (SettingsFileName, fmShareDenyNone);
rewrite(tfOut); //create the file
CloseFile(tfOut);
except
MessageDlg('Fout.', 'Het maken van het settings bestand is mislukt.' + '', mtWarning, [mbOk], 0);
end;
end;
end;
function TApplicationEnvironment.CheckDllFiles : Boolean;
var
BaseFolder : string;
s : String;
Error : Boolean;
begin
s := 'Een belangrijk dll bestand ontbreekt. Alle functionaliteit wordt uitgezet.' + sLineBreak + sLineBreak +
'Deze 3 dll bestanden moeten in de programma map staan: ' + sLineBreak
+ sLineBreak +
'libeay32.dll (Nodig voor https request).' + sLineBreak +
'ssleay32.dll (Nodig voor https request).' + sLineBreak +
'sqlite3.dll (Nodig voor de SQlite applicatie database).';
Error := false;
BaseFolder := ExtractFilePath(Application.ExeName);
if not FileExists(BaseFolder + 'libeay32.dll') then
begin
Error := true;
end;
if not FileExists(BaseFolder + 'ssleay32.dll') then
begin
Error := true;
end;
if not FileExists(BaseFolder + 'sqlite3.dll') then
begin
begin
Error := true;
end;
end;
if Error then
begin
messageDlg('Fout.', s, mtInformation, [mbOK],0);
end;
Result := Error;
end;
end.