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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
| library radiozuk;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
System.SysUtils,
System.Classes,
dialogs,
forms,
StdCtrls,
idhttp,
windows,
StrUtils;
type
thead = class(TThread)
public
{(доступные)}
constructor Create;
destructor Destroy;
procedure ms_loaded();
procedure ms_notinternet();
procedure ms_error();
// procedure synchronize(method: tthreadmethod);
private
{(закрытые)}
protected
{(защищенные)}
procedure execute(); override;
automated
{(автоматизированные)}
published
{(опубликованные)}
end;
{$R *.res}
function get_html(url:string):string; export; stdcall;
var http:TIdHTTP;
begin
try
if url<>'' then
begin
http:=TIdHTTP.Create(Application);
result:=http.Get(url);
end;
finally
http.Free;
end;
end;
//Функции работы с текстом
function parse(obj:string; o:string; t:string):String; export;stdcall;
var i1, i2:integer; data:String;
begin
try
if obj<>'' then
begin
i1:=pos(o, obj);
i2:=pos(t, obj)-length(t);
if i1>=0 then
begin
data:=Copy(obj, i1, i2-i1);
Delete(obj, i1, i2-i1);
Result:=data;
end else
begin
Result:='';
end;
end;
finally
end;
end;
//Сообщения
procedure thead.ms_loaded(); export;
begin
MessageDlg('Загрузка завершена!', mtInformation, [mbOK], 0);
end;
procedure thead.ms_notinternet(); export;
begin
MessageDlg('Нет интернета!', mtInformation, [mbOK], 0);
end;
procedure thead.ms_error(); export;
begin
MessageDlg('Ошибка!', mtError, [mbOK], 0);
end;
{ thead }
constructor thead.Create;
begin
Priority:=tpNormal;
end;
destructor thead.Destroy;
begin
end;
procedure thead.execute;
begin
inherited;
Synchronize(ms_loaded);
Synchronize(ms_notinternet);
Synchronize(ms_error);
//thead.Synchronize();
end;
function file_url(cfg:string):string; stdcall; export;
var s:string; http:TIdHTTP; o, d:integer;
begin
try
http:=TIdHTTP.Create(Application);
s:=http.Get('http://elektro-tob.ucoz.ru/file_config.inc');
o:=Pos(cfg+'::', s);
d:=Posex(';', s, o);
s:=Copy(s, o, d-o);
Result:=s;
finally
http.Free;
end;
end;
exports parse, get_html, file_url;
begin
end. |