Debian Codegraph @

plugins/wfx/ftp/src/FtpConfDlg.pas

raw
1 {
2 Double commander
3 -------------------------------------------------------------------------
4 Wfx plugin for working with File Transfer Protocol
5
6 Copyright (C) 2009-2024 Alexander Koblov ([email protected])
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 }
22
23 unit FtpConfDlg;
24
25 {$mode objfpc}{$H+}
26 {$include calling.inc}
27
28 {$R FtpConfDlg.lfm}
29
30 interface
31
32 uses
33 SysUtils, Extension, FtpFunc;
34
35 function ShowFtpConfDlg(Connection: TConnection): Boolean;
36
37 implementation
38
39 uses
40 LazUTF8, DynLibs, FtpUtils, blcksock, synaip, ssl_openssl_lib, libssh,
41 FtpProxy, TypInfo;
42
43 var
44 Protocol: PtrInt;
45 ProxyIndex: Integer;
46 gConnection: TConnection;
47
48 procedure ShowWarningSSL;
49 begin
50 with gStartupInfo do
51 begin
52 MessageBox(PAnsiChar('OpenSSL library not found!' + LineEnding +
53 'To use SSL connections, please install the OpenSSL ' +
54 'libraries (' + DLLSSLName + ' and ' + DLLUtilName + ')!'),
55 'OpenSSL', MB_OK or MB_ICONERROR
56 );
57 end;
58 end;
59
60 procedure ShowWarningSSH;
61 begin
62 with gStartupInfo do
63 begin
64 MessageBox(PAnsiChar('LibSSH2 library not found!' + LineEnding +
65 'To use SSH2 connections, please install the LibSSH2 ' +
66 'library (' + LibSSHName + ')!'),
67 'LibSSH2', MB_OK or MB_ICONERROR
68 );
69 end;
70 end;
71
72 procedure EnableControls(pDlg: PtrUInt);
73 begin
74 with gStartupInfo do
75 begin
76 SendDlgMsg(pDlg, 'gbSSH', DM_ENABLE, PtrInt(gConnection.OpenSSH), 0);
77 SendDlgMsg(pDlg, 'gbFTP', DM_ENABLE, PtrInt(not gConnection.OpenSSH), 0);
78 if not gConnection.OpenSSH then
79 begin
80 SendDlgMsg(pDlg, 'chkCopySCP', DM_SETCHECK, 0, 0);
81 SendDlgMsg(pDlg, 'chkAgentSSH', DM_SETCHECK, 0, 0);
82 end
83 else begin
84 SendDlgMsg(pDlg, 'chkShowHidden', DM_SETCHECK, 0, 0);
85 SendDlgMsg(pDlg, 'chkPassiveMode', DM_SETCHECK, 0, 0);
86 SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_SETCHECK, 0, 0);
87 SendDlgMsg(pDlg, 'chkCopySCP', DM_ENABLE, PtrInt(not gConnection.OnlySCP), 0);
88 end;
89 end;
90 end;
91
92 function CreateProxyID: String;
93 var
94 Guid: TGuid;
95 begin
96 if CreateGUID(Guid) = 0 then
97 Result := GUIDToString(Guid)
98 else
99 Result := IntToStr(Random(MaxInt));
100 end;
101
102 function GetProxyName(Proxy: TFtpProxy): String;
103 begin
104 Result:= Proxy.Host;
105 if Proxy.Port <> '' then Result+= ':' + Proxy.Port;
106 Result+= ' (' + GetEnumName(TypeInfo(TProxyType), Integer(Proxy.ProxyType)) + ')';
107 end;
108
109 procedure LoadProxy(pDlg: PtrUInt);
110 var
111 Data: PtrInt;
112 Text: String;
113 Proxy: TFtpProxy;
114 begin
115 with gStartupInfo do
116 begin
117 if (ProxyIndex > 0) then
118 begin
119 Proxy:= TFtpProxy(SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETDATA, ProxyIndex, 0));
120 SendDlgMsg(pDlg, 'rgProxyType', DM_LISTSETITEMINDEX, PtrInt(Proxy.ProxyType) - 1, 0);
121 Text:= Proxy.Host;
122 if Proxy.Port <> EmptyStr then Text+= ':' + Proxy.Port;
123 Data:= PtrInt(PAnsiChar(Text));
124 SendDlgMsg(pDlg, 'edtProxyHost', DM_SETTEXT, Data, 0);
125 Data:= PtrInt(PAnsiChar(Proxy.User));
126 SendDlgMsg(pDlg, 'edtProxyUser', DM_SETTEXT, Data, 0);
127 Data:= PtrInt(PAnsiChar(Proxy.Password));
128 SendDlgMsg(pDlg, 'edtProxyPassword', DM_SETTEXT, Data, 0);
129 end
130 else begin
131 SendDlgMsg(pDlg, 'rgProxyType', DM_LISTSETITEMINDEX, 0, 0);
132 SendDlgMsg(pDlg, 'edtProxyHost', DM_SETTEXT, 0, 0);
133 SendDlgMsg(pDlg, 'edtProxyUser', DM_SETTEXT, 0, 0);
134 SendDlgMsg(pDlg, 'edtProxyPassword', DM_SETTEXT, 0, 0);
135 end;
136 SendDlgMsg(pDlg, 'gbLogon', DM_ENABLE, ProxyIndex, 0);
137 SendDlgMsg(pDlg, 'rgProxyType', DM_ENABLE, ProxyIndex, 0);
138 SendDlgMsg(pDlg, 'btnDelete', DM_ENABLE, ProxyIndex, 0);
139 end;
140 end;
141
142 procedure UpdateProxy(pDlg: PtrUInt);
143 var
144 Data: PtrInt;
145 Text: String;
146 Proxy: TFtpProxy;
147 begin
148 if (ProxyIndex > 0) then
149 begin
150 with gStartupInfo do
151 begin
152 Proxy:= TFtpProxy(SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETDATA, ProxyIndex, 0));
153 Data:= SendDlgMsg(pDlg, 'rgProxyType', DM_LISTGETITEMINDEX, 0, 0);
154 Proxy.ProxyType:= TProxyType(Data + 1);
155 Text:= PAnsiChar(SendDlgMsg(pDlg, 'edtProxyHost', DM_GETTEXT, 0, 0));
156 Proxy.Host:= ExtractConnectionHost(Text);
157 Proxy.Port:= ExtractConnectionPort(Text);
158 if Length(Text) > 0 then
159 begin
160 Text:= GetProxyName(Proxy);
161 Data:= PtrInt(PAnsiChar(Text));
162 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTUPDATE, ProxyIndex, Data);
163 end;
164 Data:= SendDlgMsg(pDlg, 'edtProxyUser', DM_GETTEXT, 0, 0);
165 Proxy.User:= PAnsiChar(Data);
166 Data:= SendDlgMsg(pDlg, 'edtProxyPassword', DM_GETTEXT, 0, 0);
167 Proxy.Password:= PAnsiChar(Data);
168 end;
169 end;
170 end;
171
172 procedure LoadProxyList(pDlg: PtrUInt);
173 var
174 Data: PtrInt;
175 Text: String;
176 Index: Integer;
177 Proxy: TFtpProxy;
178 begin
179 ProxyIndex:= ProxyList.IndexOf(gConnection.Proxy) + 1;
180 with gStartupInfo do
181 begin
182 Data:= PtrInt(PAnsiChar('(None)'));
183 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTADDSTR, Data, 0);
184 for Index:= 0 to ProxyList.Count - 1 do
185 begin
186 Proxy:= TFtpProxy(ProxyList.Objects[Index]).Clone;
187 Text:= GetProxyName(Proxy);
188 Data:= PtrInt(PAnsiChar(Text));
189 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTADD, Data, PtrInt(Proxy));
190 end;
191 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTSETITEMINDEX, ProxyIndex, 0);
192 end;
193 LoadProxy(pDlg);
194 end;
195
196 procedure SaveProxyList(pDlg: PtrUInt);
197 var
198 Count: Integer;
199 Index: Integer;
200 Proxy: TFtpProxy;
201 begin
202 with gStartupInfo do
203 begin
204 ProxyList.Clear;
205 UpdateProxy(pDlg);
206 Count:= SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETCOUNT, 0, 0);
207 for Index:= 1 to Count - 1 do
208 begin
209 Proxy:= TFtpProxy(SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETDATA, Index, 0));
210 ProxyList.AddObject(Proxy.ID, Proxy);
211 end;
212 end;
213 if ProxyIndex > 0 then
214 gConnection.Proxy:= TFtpProxy(ProxyList.Objects[ProxyIndex - 1]).ID
215 else
216 gConnection.Proxy:= EmptyStr;
217 end;
218
219 procedure FreeProxyList(pDlg: PtrUInt);
220 var
221 Count: Integer;
222 Index: Integer;
223 begin
224 with gStartupInfo do
225 begin
226 Count:= SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETCOUNT, 0, 0);
227 for Index:= 1 to Count - 1 do
228 begin
229 TFtpProxy(SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETDATA, Index, 0)).Free;
230 end;
231 end;
232 end;
233
234 function DlgProc (pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam: PtrInt): PtrInt; dcpcall;
235 var
236 Data: PtrInt;
237 Text: String;
238 Proxy: TFtpProxy;
239 begin
240 Result:= 0;
241 with gStartupInfo do
242 begin
243 case Msg of
244 DN_INITDIALOG:
245 begin
246 Text:= gConnection.Encoding;
247 Data:= PtrInt(PAnsiChar(Text));
248 Data:= SendDlgMsg(pDlg, 'cmbEncoding', DM_LISTINDEXOF, 0, Data);
249 if Data >= 0 then SendDlgMsg(pDlg, 'cmbEncoding', DM_LISTSETITEMINDEX, Data, 0);
250 Text:= gConnection.ConnectionName;
251 Data:= PtrInt(PAnsiChar(Text));
252 SendDlgMsg(pDlg, 'edtName', DM_SETTEXT, Data, 0);
253 Text:= gConnection.Host;
254 if gConnection.Port <> EmptyStr then
255 begin
256 if IsIP6(Text) then Text := '[' + Text + ']';
257 Text += ':' + gConnection.Port;
258 end;
259 if gConnection.FullSSL then
260 Protocol:= 1
261 else if gConnection.AutoTLS then
262 Protocol:= 2
263 else if gConnection.OpenSSH then
264 begin
265 if gConnection.OnlySCP then
266 Protocol:= 3
267 else
268 Protocol:= 4;
269 end
270 else begin
271 Protocol:= 0;
272 end;
273 SendDlgMsg(pDlg, 'cmbProtocol', DM_LISTSETITEMINDEX, Protocol, 0);
274 Data:= PtrInt(PAnsiChar(Text));
275 SendDlgMsg(pDlg, 'edtHost', DM_SETTEXT, Data, 0);
276 Text:= gConnection.UserName;
277 Data:= PtrInt(PAnsiChar(Text));
278 SendDlgMsg(pDlg, 'edtUserName', DM_SETTEXT, Data, 0);
279 if gConnection.MasterPassword then
280 begin
281 SendDlgMsg(pDlg, 'chkMasterPassword', DM_SETCHECK, 1, 0);
282 SendDlgMsg(pDlg, 'chkMasterPassword', DM_ENABLE, 0, 0);
283 //SendDlgMsg(pDlg, 'edtPassword', DM_SHOWITEM, 0, 0);
284 SendDlgMsg(pDlg, 'btnChangePassword', DM_SHOWITEM, 1, 0);
285 end
286 else
287 begin
288 Text:= gConnection.Password;
289 Data:= PtrInt(PAnsiChar(Text));
290 SendDlgMsg(pDlg, 'edtPassword', DM_SETTEXT, Data, 0);
291 end;
292 Text:= SysToUTF8(gConnection.Path);
293 Data:= PtrInt(PAnsiChar(Text));
294 SendDlgMsg(pDlg, 'edtRemoteDir', DM_SETTEXT, Data, 0);
295 Text:= gConnection.InitCommands;
296 Data:= PtrInt(PAnsiChar(Text));
297 SendDlgMsg(pDlg, 'edtInitCommands', DM_SETTEXT, Data, 0);
298 Data:= PtrInt(gConnection.PassiveMode);
299 SendDlgMsg(pDlg, 'chkPassiveMode', DM_SETCHECK, Data, 0);
300 Data:= PtrInt(gConnection.AgentSSH);
301 SendDlgMsg(pDlg, 'chkAgentSSH', DM_SETCHECK, Data, 0);
302 Data:= PtrInt(gConnection.CopySCP);
303 SendDlgMsg(pDlg, 'chkCopySCP', DM_SETCHECK, Data, 0);
304 Data:= PtrInt(gConnection.ShowHiddenItems);
305 SendDlgMsg(pDlg, 'chkShowHidden', DM_SETCHECK, Data, 0);
306 Data:= PtrInt(gConnection.KeepAliveTransfer);
307 SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_SETCHECK, Data, 0);
308
309 Data:= PtrInt(PAnsiChar(gConnection.PublicKey));
310 SendDlgMsg(pDlg, 'fnePublicKey', DM_SETTEXT, Data, 0);
311 Data:= PtrInt(PAnsiChar(gConnection.PrivateKey));
312 SendDlgMsg(pDlg, 'fnePrivateKey', DM_SETTEXT, Data, 0);
313
314 if SameText(gConnection.ConnectionName, cQuickConnection) then
315 begin
316 SendDlgMsg(pDlg, 'edtName', DM_ENABLE, 0, 0);
317 SendDlgMsg(pDlg, 'chkMasterPassword', DM_SHOWITEM, 0, 0);
318 end;
319
320 EnableControls(pDlg);
321
322 LoadProxyList(pDlg);
323 end;
324 DN_CHANGE:
325 begin
326 if DlgItemName = 'chkMasterPassword' then
327 begin
328 Data:= SendDlgMsg(pDlg, 'chkMasterPassword', DM_GETCHECK, 0, 0);
329 gConnection.MasterPassword:= Boolean(Data);
330 gConnection.PasswordChanged:= True;
331 end
332 else if DlgItemName = 'cmbProtocol' then
333 begin
334 Data:= SendDlgMsg(pDlg, 'cmbProtocol', DM_LISTGETITEMINDEX, 0, 0);
335 case Data of
336 0: // FTP
337 begin
338 Protocol:= Data;
339 gConnection.OpenSSH:= False;
340 gConnection.OnlySCP:= False;
341 gConnection.FullSSL:= False;
342 gConnection.AutoTLS:= False;
343 end;
344 1, 2: // FTPS, FTPES
345 begin
346 if (SSLImplementation = TSSLNone) then
347 begin
348 ShowWarningSSL;
349 SendDlgMsg(pDlg, 'cmbProtocol', DM_LISTSETITEMINDEX, Protocol, 0);
350 end
351 else begin
352 Protocol:= Data;
353 gConnection.OpenSSH:= False;
354 gConnection.OnlySCP:= False;
355 gConnection.FullSSL:= (Data = 1);
356 gConnection.AutoTLS:= (Data = 2);
357 end;
358 end;
359 3, 4: // SSH+SCP, SFTP
360 begin
361 if libssh2 = NilHandle then
362 begin
363 ShowWarningSSH;
364 SendDlgMsg(pDlg, 'cmbProtocol', DM_LISTSETITEMINDEX, Protocol, 0);
365 end
366 else begin
367 Protocol:= Data;
368 gConnection.OpenSSH:= True;
369 gConnection.FullSSL:= False;
370 gConnection.AutoTLS:= False;
371 gConnection.OnlySCP:= (Data = 3);
372 SendDlgMsg(pDlg, 'chkCopySCP', DM_SETCHECK, PtrInt(Data = 3), 0);
373 end;
374 end;
375 end;
376 EnableControls(pDlg);
377 end
378 else if DlgItemName = 'cmbProxy' then
379 begin
380 UpdateProxy(pDlg);
381 ProxyIndex:= SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETITEMINDEX, 0, 0);
382 // Load current proxy settings
383 LoadProxy(pDlg);
384 end;
385 end;
386 DN_CLICK:
387 if DlgItemName = 'btnAnonymous' then
388 begin
389 Text:= 'anonymous';
390 Data:= PtrInt(PAnsiChar(Text));
391 SendDlgMsg(pDlg, 'edtUserName', DM_SETTEXT, Data, 0);
392 Text:= '[email protected]';
393 Data:= PtrInt(PAnsiChar(Text));
394 SendDlgMsg(pDlg, 'edtPassword', DM_SETTEXT, Data, 0);
395 end
396 else if DlgItemName = 'btnChangePassword' then
397 begin
398 if ReadPassword(gConnection.ConnectionName, Text) then
399 begin
400 Data:= PtrInt(PAnsiChar(Text));
401 SendDlgMsg(pDlg, 'edtPassword', DM_SETTEXT, Data, 0);
402 SendDlgMsg(pDlg, 'edtPassword', DM_SHOWITEM, 1, 0);
403 SendDlgMsg(pDlg, 'btnChangePassword', DM_SHOWITEM, 0, 0);
404 SendDlgMsg(pDlg, 'chkMasterPassword', DM_ENABLE, 1, 0);
405 gConnection.PasswordChanged:= True;
406 end;
407 end
408 else if DlgItemName = 'btnAdd' then
409 begin
410 UpdateProxy(pDlg);
411 Proxy:= TFtpProxy.Create;
412 Proxy.ID:= CreateProxyID;
413 Data:= PtrInt(PAnsiChar(Proxy.ID));
414 ProxyIndex:= SendDlgMsg(pDlg, 'cmbProxy', DM_LISTADD, Data, PtrInt(Proxy));
415 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTSETITEMINDEX, ProxyIndex, 0);
416 LoadProxy(pDlg);
417 end
418 else if DlgItemName = 'btnDelete' then
419 begin
420 Data:= SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETITEMINDEX, 0, 0);
421 TFtpProxy(SendDlgMsg(pDlg, 'cmbProxy', DM_LISTGETDATA, Data, 0)).Free;
422 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTDELETE, Data, 0);
423 ProxyIndex:= 0;
424 SendDlgMsg(pDlg, 'cmbProxy', DM_LISTSETITEMINDEX, 0, 0);
425 LoadProxy(pDlg);
426 end
427 else if DlgItemName = 'btnOK' then
428 begin
429 Data:= SendDlgMsg(pDlg, 'cmbEncoding', DM_GETTEXT, 0, 0);
430 Text:= PAnsiChar(Data);
431 gConnection.Encoding:= Text;
432 Data:= SendDlgMsg(pDlg, 'edtName', DM_GETTEXT, 0, 0);
433 Text:= PAnsiChar(Data);
434 gConnection.ConnectionName:= RepairConnectionName(Text);
435 Data:= SendDlgMsg(pDlg, 'edtHost', DM_GETTEXT, 0, 0);
436 Text:= PAnsiChar(Data);
437 if (Length(Text) = 0) or (Length(gConnection.ConnectionName) = 0) then
438 begin
439 gStartupInfo.MessageBox('You MUST at least specify a connection and host name!',
440 nil, MB_OK or MB_ICONERROR);
441 Exit;
442 end;
443 gConnection.Host:= ExtractConnectionHost(Text);
444 gConnection.Port:= ExtractConnectionPort(Text);
445 gConnection.FullSSL:= ExtractConnectionProt(Text) = 'ftps';
446 Data:= SendDlgMsg(pDlg, 'edtUserName', DM_GETTEXT, 0, 0);
447 Text:= PAnsiChar(Data);
448 gConnection.UserName:= Text;
449 Data:= SendDlgMsg(pDlg, 'edtPassword', DM_GETTEXT, 0, 0);
450 Text:= PAnsiChar(Data);
451 gConnection.Password:= Text;
452 Data:= SendDlgMsg(pDlg, 'chkMasterPassword', DM_GETCHECK, 0, 0);
453 gConnection.MasterPassword:= Boolean(Data);
454 Data:= SendDlgMsg(pDlg, 'edtRemoteDir', DM_GETTEXT, 0, 0);
455 Text:= PAnsiChar(Data);
456 gConnection.Path:= UTF8ToSys(Text);
457 Data:= SendDlgMsg(pDlg, 'edtInitCommands', DM_GETTEXT, 0, 0);
458 Text:= PAnsiChar(Data);
459 gConnection.InitCommands:= Text;
460 Data:= SendDlgMsg(pDlg, 'chkPassiveMode', DM_GETCHECK, 0, 0);
461 gConnection.PassiveMode:= Boolean(Data);
462 Data:= SendDlgMsg(pDlg, 'chkAgentSSH', DM_GETCHECK, 0, 0);
463 gConnection.AgentSSH:= Boolean(Data);
464 Data:= SendDlgMsg(pDlg, 'chkCopySCP', DM_GETCHECK, 0, 0);
465 gConnection.CopySCP:= Boolean(Data);
466 Data:= SendDlgMsg(pDlg, 'chkShowHidden', DM_GETCHECK, 0, 0);
467 gConnection.ShowHiddenItems:= Boolean(Data);
468 Data:= SendDlgMsg(pDlg, 'chkKeepAliveTransfer', DM_GETCHECK, 0, 0);
469 gConnection.KeepAliveTransfer:= Boolean(Data);
470
471 Data:= SendDlgMsg(pDlg, 'fnePublicKey', DM_GETTEXT, 0, 0);
472 gConnection.PublicKey:= PAnsiChar(Data);
473 Data:= SendDlgMsg(pDlg, 'fnePrivateKey', DM_GETTEXT, 0, 0);
474 gConnection.PrivateKey:= PAnsiChar(Data);
475
476 if gConnection.OpenSSH then
477 begin
478 if (Length(gConnection.PublicKey) > 0) and (Length(gConnection.PrivateKey) = 0) or
479 (Length(gConnection.PublicKey) = 0) and (Length(gConnection.PrivateKey) > 0) then
480 begin
481 gStartupInfo.MessageBox('You must enter the location of the public/private key pair!',
482 nil, MB_OK or MB_ICONERROR);
483 Exit;
484 end;
485 end;
486
487 if gConnection.FullSSL and (InitSSLInterface = False) then
488 begin;
489 ShowWarningSSL;
490 end;
491
492 SaveProxyList(pDlg);
493
494 // close dialog
495 SendDlgMsg(pDlg, DlgItemName, DM_CLOSE, 1, 0);
496 end
497 else if DlgItemName = 'btnCancel' then
498 begin
499 FreeProxyList(pDlg);
500 // close dialog
501 SendDlgMsg(pDlg, DlgItemName, DM_CLOSE, 2, 0);
502 end;
503 end;// case
504 end; // with
505 end;
506
507 function ShowFtpConfDlg(Connection: TConnection): Boolean;
508 var
509 ResHandle: TFPResourceHandle = 0;
510 ResGlobal: TFPResourceHGLOBAL = 0;
511 ResData: Pointer = nil;
512 ResSize: LongWord;
513 begin
514 Result := False;
515 try
516 ResHandle := FindResource(HINSTANCE, PChar('TDIALOGBOX'), MAKEINTRESOURCE(10) {RT_RCDATA});
517 if ResHandle <> 0 then
518 begin
519 ResGlobal := LoadResource(HINSTANCE, ResHandle);
520 if ResGlobal <> 0 then
521 begin
522 ResData := LockResource(ResGlobal);
523 ResSize := SizeofResource(HINSTANCE, ResHandle);
524
525 with gStartupInfo do
526 begin
527 gConnection := Connection;
528 Result := DialogBoxLRS(ResData, ResSize, @DlgProc);
529 end;
530 end;
531 end;
532
533 finally
534 if ResGlobal <> 0 then
535 begin
536 UnlockResource(ResGlobal);
537 FreeResource(ResGlobal);
538 end;
539 end;
540 end;
541
542 end.