1 |
tony |
1 |
{************************************************************************}
|
2 |
|
|
{ }
|
3 |
|
|
{ Borland Delphi Visual Component Library }
|
4 |
|
|
{ InterBase Express core components }
|
5 |
|
|
{ }
|
6 |
|
|
{ Copyright (c) 1998-2000 Inprise Corporation }
|
7 |
|
|
{ }
|
8 |
|
|
{ InterBase Express is based in part on the product }
|
9 |
|
|
{ Free IB Components, written by Gregory H. Deatz for }
|
10 |
|
|
{ Hoagland, Longo, Moran, Dunst & Doukas Company. }
|
11 |
|
|
{ Free IB Components is used under license. }
|
12 |
|
|
{ }
|
13 |
|
|
{ The contents of this file are subject to the InterBase }
|
14 |
|
|
{ Public License Version 1.0 (the "License"); you may not }
|
15 |
|
|
{ use this file except in compliance with the License. You }
|
16 |
|
|
{ may obtain a copy of the License at http://www.Inprise.com/IPL.html }
|
17 |
|
|
{ Software distributed under the License is distributed on }
|
18 |
|
|
{ an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either }
|
19 |
|
|
{ express or implied. See the License for the specific language }
|
20 |
|
|
{ governing rights and limitations under the License. }
|
21 |
|
|
{ The Original Code was created by InterBase Software Corporation }
|
22 |
|
|
{ and its successors. }
|
23 |
|
|
{ Portions created by Inprise Corporation are Copyright (C) Inprise }
|
24 |
|
|
{ Corporation. All Rights Reserved. }
|
25 |
|
|
{ Contributor(s): Jeff Overcash }
|
26 |
|
|
{ }
|
27 |
|
|
{************************************************************************}
|
28 |
|
|
|
29 |
|
|
{
|
30 |
|
|
InterBase Express provides component interfaces to
|
31 |
|
|
functions introduced in InterBase 6.0. The Services
|
32 |
|
|
components (TIB*Service, TIBServerProperties) and
|
33 |
|
|
Install components (TIBInstall, TIBUninstall, TIBSetup)
|
34 |
|
|
function only if you have installed InterBase 6.0 or
|
35 |
|
|
later software
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
unit IBInstall;
|
39 |
|
|
|
40 |
|
|
interface
|
41 |
|
|
|
42 |
|
|
uses Windows, TypInfo,SysUtils, Classes, IB, IBInstallHeader, IBIntf, IBXConst;
|
43 |
|
|
|
44 |
|
|
type
|
45 |
|
|
|
46 |
|
|
TIscError = MSG_NO;
|
47 |
|
|
TIBInstallerError = (ieSuccess,
|
48 |
|
|
ieDelphiException,
|
49 |
|
|
ieNoOptionsSet,
|
50 |
|
|
ieNoDestinationDirectory,
|
51 |
|
|
ieNosourceDirectory,
|
52 |
|
|
ieNoUninstallFile,
|
53 |
|
|
ieOptionNeedsClient,
|
54 |
|
|
ieOptionNeedsServer,
|
55 |
|
|
ieInvalidOption,
|
56 |
|
|
ieInvalidOnErrorResult,
|
57 |
|
|
ieInvalidOnStatusResult);
|
58 |
|
|
|
59 |
|
|
TMainOption = (moServer,
|
60 |
|
|
moClient,
|
61 |
|
|
moConServer,
|
62 |
|
|
moGuiTools,
|
63 |
|
|
moDocumentation,
|
64 |
|
|
moDevelopment);
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
TExamplesOption = (exDB, exAPI);
|
68 |
|
|
TCmdOption = (cmDBMgmt, cmDBQuery, cmUsrMgmt);
|
69 |
|
|
TConnectivityOption = (cnODBC, cnOLEDB, cnJDBC);
|
70 |
|
|
|
71 |
|
|
TMainOptions = set of TMainOption;
|
72 |
|
|
TExamplesOptions = set of TExamplesOption;
|
73 |
|
|
TCmdOptions = set of TCmdOption;
|
74 |
|
|
TConnectivityOptions = set of TConnectivityOption;
|
75 |
|
|
|
76 |
|
|
TErrorResult = (erAbort, erContinue, erRetry);
|
77 |
|
|
TStatusResult = (srAbort, srContinue);
|
78 |
|
|
TWarningResult = (wrAbort, wrContinue);
|
79 |
|
|
|
80 |
|
|
TIBSetupOnStatus = function(Sender : TObject; StatusComment : string):
|
81 |
|
|
TStatusResult of object;
|
82 |
|
|
TIBSetupOnWarning = function(Sender :TObject; WarningCode: TIscError;
|
83 |
|
|
WarningMessage : string): TWarningResult of object;
|
84 |
|
|
TIBSetupOnError = function (Sender : TObject; IscCode : TIscError;
|
85 |
|
|
ErrorMessage, ErrorComment : string):
|
86 |
|
|
TErrorResult of object;
|
87 |
|
|
|
88 |
|
|
EIBInstall = class(Exception)
|
89 |
|
|
private
|
90 |
|
|
FIscError : MSG_NO;
|
91 |
|
|
FInstallerError : TIBInstallerError;
|
92 |
|
|
public
|
93 |
|
|
constructor Create(IscCode : MSG_NO; IscMessage : string); overload; virtual;
|
94 |
|
|
constructor Create(ECode : TIBInstallerError; EMessage : string); overload;
|
95 |
|
|
virtual;
|
96 |
|
|
property InstallError : MSG_NO read FIscError;
|
97 |
|
|
property InstallerError : TIBInstallerError read FInstallerError;
|
98 |
|
|
end;
|
99 |
|
|
|
100 |
|
|
EIBInstallError = class(EIBInstall);
|
101 |
|
|
|
102 |
|
|
EIBInstallerError = class(EIBInstall);
|
103 |
|
|
|
104 |
|
|
TInstallOptions = class(TPersistent)
|
105 |
|
|
private
|
106 |
|
|
FMainComponents : TMainOptions;
|
107 |
|
|
FExamples: TExamplesOptions;
|
108 |
|
|
FCmdLineTools: TCmdOptions;
|
109 |
|
|
FConnectivityClients: TConnectivityOptions;
|
110 |
|
|
published
|
111 |
|
|
property MainComponents : TMainOptions read FMainComponents write FMainComponents;
|
112 |
|
|
property CmdLineTools: TCmdOptions read FCmdLineTools write FCmdLineTools;
|
113 |
|
|
property ConnectivityClients: TConnectivityOptions read FConnectivityClients
|
114 |
|
|
write FConnectivityClients;
|
115 |
|
|
property Examples: TExamplesOptions read FExamples write FExamples;
|
116 |
|
|
end;
|
117 |
|
|
|
118 |
|
|
TIBSetup = class(TComponent)
|
119 |
|
|
private
|
120 |
|
|
FIBInstallLoaded: Boolean;
|
121 |
|
|
FRebootToComplete: Boolean;
|
122 |
|
|
FProgress: Integer;
|
123 |
|
|
FMsgFilePath: string;
|
124 |
|
|
FOnStatusChange: TIBSetupOnStatus;
|
125 |
|
|
FStatusContext : Pointer;
|
126 |
|
|
FOnError: TIBSetupOnError;
|
127 |
|
|
FErrorContext : Pointer;
|
128 |
|
|
FOnWarning: TIBSetupOnWarning;
|
129 |
|
|
procedure SetMsgFilePath(const Value: string);
|
130 |
|
|
protected
|
131 |
|
|
function StatusInternal(Status: Integer; const ActionDescription: TEXT):Integer;
|
132 |
|
|
function ErrorInternal(IscCode: MSG_NO; const ActionDescription: TEXT): Integer;
|
133 |
|
|
procedure Call(IscCode: MSG_NO);
|
134 |
|
|
procedure IBInstallError(IscCode: MSG_NO);
|
135 |
|
|
function GetInstallMessage(IscCode : MSG_NO) : string;
|
136 |
|
|
public
|
137 |
|
|
constructor Create(AOwner : TComponent); override;
|
138 |
|
|
property RebootToComplete : Boolean read FRebootToComplete;
|
139 |
|
|
property Progress : Integer read FProgress;
|
140 |
|
|
property StatusContext : Pointer read FStatusContext write FStatusContext;
|
141 |
|
|
property ErrorContext : Pointer read FErrorContext write FErrorContext;
|
142 |
|
|
property MsgFilePath: string read FMsgFilePath write SetMsgFilePath;
|
143 |
|
|
published
|
144 |
|
|
property OnWarning: TIBSetupOnWarning read FOnWarning write FOnWarning;
|
145 |
|
|
property OnError: TIBSetupOnError read FOnError write FOnError;
|
146 |
|
|
property OnStatusChange: TIBSetupOnStatus read FOnStatusChange write FOnStatusChange;
|
147 |
|
|
end;
|
148 |
|
|
|
149 |
|
|
TIBInstall = class(TIBSetup)
|
150 |
|
|
private
|
151 |
|
|
FUnInstallFile: string;
|
152 |
|
|
FSourceDir: string;
|
153 |
|
|
FDestinationDir: string;
|
154 |
|
|
FSuggestedDestination: string;
|
155 |
|
|
FInstallOptions: TInstallOptions;
|
156 |
|
|
procedure GetOptionProperty(InfoType : Integer; Option : TExamplesOption;
|
157 |
|
|
Buffer : Pointer; BufferLen : Cardinal); overload;
|
158 |
|
|
procedure GetOptionProperty(InfoType : Integer; Option : TMainOption;
|
159 |
|
|
Buffer : Pointer; BufferLen : Cardinal); overload;
|
160 |
|
|
procedure GetOptionProperty(InfoType : Integer; Option : TConnectivityOption;
|
161 |
|
|
Buffer : Pointer; BufferLen : Cardinal); overload;
|
162 |
|
|
procedure GetOptionProperty(InfoType : Integer; Option : TCmdOption;
|
163 |
|
|
Buffer : Pointer; BufferLen : Cardinal); overload;
|
164 |
|
|
procedure InternalSetOptions(pHandle : POPTIONS_HANDLE);
|
165 |
|
|
procedure SetDestination(const Value: string);
|
166 |
|
|
procedure SetSource(const Value: string);
|
167 |
|
|
procedure SetInstallOptions(const Value: TInstallOptions);
|
168 |
|
|
procedure SuggestDestination;
|
169 |
|
|
public
|
170 |
|
|
Constructor Create(AOwner: TComponent); override;
|
171 |
|
|
Destructor Destroy; override;
|
172 |
|
|
|
173 |
|
|
procedure InstallCheck;
|
174 |
|
|
procedure InstallExecute;
|
175 |
|
|
|
176 |
|
|
function GetOptionDescription (Option : TExamplesOption): string; overload;
|
177 |
|
|
function GetOptionDescription (Option : TMainOption) : string; overload;
|
178 |
|
|
function GetOptionDescription (Option : TConnectivityOption) : string; overload;
|
179 |
|
|
function GetOptionDescription (Option : TCmdOption) :string; overload;
|
180 |
|
|
|
181 |
|
|
function GetOptionName (Option : TExamplesOption): string; overload;
|
182 |
|
|
function GetOptionName (Option : TMainOption) :string; overload;
|
183 |
|
|
function GetOptionName (Option : TConnectivityOption) : string; overload;
|
184 |
|
|
function GetOptionName (Option : TCmdOption) : string; overload;
|
185 |
|
|
|
186 |
|
|
function GetOptionSpaceRequired (Option : TExamplesOption): longword; overload;
|
187 |
|
|
function GetOptionSpaceRequired (Option : TMainOption): longword; overload;
|
188 |
|
|
function GetOptionSpaceRequired (Option : TConnectivityOption): longword; overload;
|
189 |
|
|
function GetOptionSpaceRequired (Option : TCmdOption): longword; overload;
|
190 |
|
|
|
191 |
|
|
property UnInstallFile: string read FUnInstallFile;
|
192 |
|
|
property SuggestedDestination: string read FSuggestedDestination;
|
193 |
|
|
|
194 |
|
|
published
|
195 |
|
|
property SourceDirectory: string read FSourceDir write SetSource;
|
196 |
|
|
property DestinationDirectory: string read FDestinationDir write SetDestination;
|
197 |
|
|
property InstallOptions: TInstallOptions read FInstallOptions write SetInstallOptions;
|
198 |
|
|
end;
|
199 |
|
|
|
200 |
|
|
TIBUnInstall = class(TIBSetup)
|
201 |
|
|
private
|
202 |
|
|
FUnInstallFile: string;
|
203 |
|
|
public
|
204 |
|
|
procedure UnInstallCheck;
|
205 |
|
|
procedure UnInstallExecute;
|
206 |
|
|
property UnInstallFile: string read FUnInstallFile write FUnInstallFile;
|
207 |
|
|
published
|
208 |
|
|
end;
|
209 |
|
|
|
210 |
|
|
implementation
|
211 |
|
|
|
212 |
|
|
const
|
213 |
|
|
IBInstallerMessages : array[TIBInstallerError] of string = (
|
214 |
|
|
SSuccess,
|
215 |
|
|
SDelphiException,
|
216 |
|
|
SNoOptionsSet,
|
217 |
|
|
SNoDestinationDirectory,
|
218 |
|
|
SNosourceDirectory,
|
219 |
|
|
SNoUninstallFile,
|
220 |
|
|
SOptionNeedsClient,
|
221 |
|
|
SOptionNeedsServer,
|
222 |
|
|
SInvalidOption,
|
223 |
|
|
SInvalidOnErrorResult,
|
224 |
|
|
SInvalidOnStatusResult
|
225 |
|
|
);
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
procedure IBInstallerError(ECode: TIBInstallerError; const Args: array of const);
|
230 |
|
|
begin
|
231 |
|
|
raise EIBInstallerError.Create(ECode, Format(IBInstallerMessages[ECode], Args));
|
232 |
|
|
end;
|
233 |
|
|
|
234 |
|
|
function ErrorCallback(IscCode: MSG_NO; UserContext: Pointer; const ActionDescription:
|
235 |
|
|
TEXT): Integer; stdcall;
|
236 |
|
|
begin
|
237 |
|
|
Result := TIBSetup(UserContext).ErrorInternal(IscCode, ActionDescription);
|
238 |
|
|
end;
|
239 |
|
|
|
240 |
|
|
function StatusCallback(Status : Integer; UserContext: Pointer; const ActionDescription:
|
241 |
|
|
TEXT): Integer; stdcall;
|
242 |
|
|
begin
|
243 |
|
|
Result := TIBSetup(UserContext).StatusInternal(Status, ActionDescription);
|
244 |
|
|
end;
|
245 |
|
|
|
246 |
|
|
{ TIBSetup }
|
247 |
|
|
|
248 |
|
|
function TIBSetup.ErrorInternal(IscCode: MSG_NO; const ActionDescription: TEXT):
|
249 |
|
|
Integer;
|
250 |
|
|
var
|
251 |
|
|
ErrorComment : string;
|
252 |
|
|
begin
|
253 |
|
|
if(ActionDescription <> nil) and (ActionDescription[0] <> #0) then
|
254 |
|
|
begin
|
255 |
|
|
SetLength(ErrorComment, StrLen(ActionDescription));
|
256 |
|
|
StrCopy(PChar(ErrorComment), ActionDescription);
|
257 |
|
|
end
|
258 |
|
|
else
|
259 |
|
|
ErrorComment := '';
|
260 |
|
|
|
261 |
|
|
if(Isccode = isc_install_fp_copy_delayed) or
|
262 |
|
|
(Isccode = isc_install_fp_delete_delayed) then
|
263 |
|
|
begin
|
264 |
|
|
FRebootToComplete := True;
|
265 |
|
|
Result := isc_install_fp_continue;
|
266 |
|
|
exit;
|
267 |
|
|
end;
|
268 |
|
|
|
269 |
|
|
if Assigned(FOnError) then
|
270 |
|
|
case FOnError(self, IscCode, GetInstallMessage(IscCode), ErrorComment) of
|
271 |
|
|
erAbort:
|
272 |
|
|
Result := isc_install_fp_abort;
|
273 |
|
|
erContinue:
|
274 |
|
|
Result := isc_install_fp_continue;
|
275 |
|
|
erRetry:
|
276 |
|
|
Result := isc_install_fp_retry;
|
277 |
|
|
else
|
278 |
|
|
Result := isc_install_fp_abort;
|
279 |
|
|
end
|
280 |
|
|
else
|
281 |
|
|
Result := isc_install_fp_abort;
|
282 |
|
|
end;
|
283 |
|
|
|
284 |
|
|
function TIBSetup.StatusInternal(Status: Integer; const ActionDescription: TEXT):
|
285 |
|
|
Integer;
|
286 |
|
|
var
|
287 |
|
|
StatusComment : string;
|
288 |
|
|
begin
|
289 |
|
|
FProgress := Status;
|
290 |
|
|
if(ActionDescription <> nil) and (ActionDescription[0] <> #0) then
|
291 |
|
|
begin
|
292 |
|
|
SetLength(StatusComment, StrLen(ActionDescription));
|
293 |
|
|
StrCopy(PChar(StatusComment), ActionDescription);
|
294 |
|
|
end
|
295 |
|
|
else
|
296 |
|
|
StatusComment := '';
|
297 |
|
|
|
298 |
|
|
if Assigned(FOnStatusChange) then
|
299 |
|
|
case FOnStatusChange(self, StatusComment) of
|
300 |
|
|
srAbort:
|
301 |
|
|
Result := isc_install_fp_abort;
|
302 |
|
|
srContinue:
|
303 |
|
|
Result := isc_install_fp_continue;
|
304 |
|
|
else
|
305 |
|
|
Result := isc_install_fp_continue;
|
306 |
|
|
end
|
307 |
|
|
else
|
308 |
|
|
Result := isc_install_fp_continue;
|
309 |
|
|
end;
|
310 |
|
|
|
311 |
|
|
procedure TIBSetup.SetMsgFilePath(const Value: string);
|
312 |
|
|
begin
|
313 |
|
|
if FMsgFilePath <> Value then
|
314 |
|
|
begin
|
315 |
|
|
Call(isc_install_load_external_text(PChar(Value)));
|
316 |
|
|
FMsgFilePath := Value;
|
317 |
|
|
end;
|
318 |
|
|
end;
|
319 |
|
|
|
320 |
|
|
procedure TIBSetup.Call(IscCode: MSG_NO);
|
321 |
|
|
begin
|
322 |
|
|
if IscCode = isc_install_success then
|
323 |
|
|
Exit;
|
324 |
|
|
|
325 |
|
|
if IscCode < isc_install_success then
|
326 |
|
|
begin
|
327 |
|
|
if Assigned(FOnWarning) then
|
328 |
|
|
begin
|
329 |
|
|
if FOnWarning(self, IscCode, GetInstallMessage(IscCode)) = wrAbort then
|
330 |
|
|
IBInstallError(IscCode);
|
331 |
|
|
Exit;
|
332 |
|
|
end
|
333 |
|
|
else
|
334 |
|
|
IBInstallError(IscCode);
|
335 |
|
|
end;
|
336 |
|
|
IBInstallError(IscCode);
|
337 |
|
|
end;
|
338 |
|
|
|
339 |
|
|
procedure TIBSetup.IBInstallError(IscCode: MSG_NO);
|
340 |
|
|
begin
|
341 |
|
|
raise EIBInstallError.Create(IscCode, GetInstallMessage(IscCode));
|
342 |
|
|
end;
|
343 |
|
|
|
344 |
|
|
function TIBSetup.GetInstallMessage(IscCode : MSG_NO) : string;
|
345 |
|
|
var
|
346 |
|
|
status : MSG_NO;
|
347 |
|
|
IscMessage : string;
|
348 |
|
|
begin
|
349 |
|
|
SetLength(IscMessage, ISC_INSTALL_MAX_MESSAGE_LEN * 2);
|
350 |
|
|
status := isc_install_get_message(0, IscCode, PChar(IscMessage),
|
351 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN * 2);
|
352 |
|
|
|
353 |
|
|
if status <> isc_install_success then
|
354 |
|
|
isc_install_get_message(0, status, PChar(IscMessage),
|
355 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN * 2);
|
356 |
|
|
|
357 |
|
|
SetLength(IscMessage, StrLen(PChar(IscMessage)));
|
358 |
|
|
result := IscMessage;
|
359 |
|
|
end;
|
360 |
|
|
|
361 |
|
|
constructor TIBSetup.Create(AOwner : TComponent);
|
362 |
|
|
begin
|
363 |
|
|
inherited Create(AOwner);
|
364 |
|
|
FIBInstallLoaded := False;
|
365 |
|
|
CheckIBInstallLoaded;
|
366 |
|
|
FIBInstallLoaded := True;
|
367 |
|
|
FRebootToComplete := False;
|
368 |
|
|
FProgress := 0;
|
369 |
|
|
end;
|
370 |
|
|
|
371 |
|
|
{ TIBInstall }
|
372 |
|
|
|
373 |
|
|
constructor TIBInstall.Create(AOwner: TComponent);
|
374 |
|
|
begin
|
375 |
|
|
inherited Create(AOwner);
|
376 |
|
|
FIBInstallLoaded := False;
|
377 |
|
|
CheckIBInstallLoaded;
|
378 |
|
|
FIBInstallLoaded := True;
|
379 |
|
|
FInstallOptions := TInstallOptions.Create;
|
380 |
|
|
SuggestDestination;
|
381 |
|
|
end;
|
382 |
|
|
|
383 |
|
|
destructor TIBInstall.Destroy;
|
384 |
|
|
begin
|
385 |
|
|
if FIBInstallLoaded then
|
386 |
|
|
FInstallOptions.Free;
|
387 |
|
|
inherited;
|
388 |
|
|
end;
|
389 |
|
|
|
390 |
|
|
procedure TIBInstall.InstallCheck;
|
391 |
|
|
var
|
392 |
|
|
Handle : OPTIONS_HANDLE;
|
393 |
|
|
SrcDir, DestDir : PChar;
|
394 |
|
|
begin
|
395 |
|
|
Handle := 0;
|
396 |
|
|
InternalSetOptions(@Handle);
|
397 |
|
|
|
398 |
|
|
if FSourceDir = '' then
|
399 |
|
|
SrcDir := nil
|
400 |
|
|
else
|
401 |
|
|
SrcDir := PChar(FSourceDir);
|
402 |
|
|
|
403 |
|
|
if FDestinationDir = '' then
|
404 |
|
|
DestDir := nil
|
405 |
|
|
else
|
406 |
|
|
DestDir := PChar(FDestinationDir);
|
407 |
|
|
|
408 |
|
|
try
|
409 |
|
|
Call(isc_install_precheck(Handle, SrcDir, DestDir));
|
410 |
|
|
finally
|
411 |
|
|
isc_install_clear_options(@Handle);
|
412 |
|
|
end;
|
413 |
|
|
end;
|
414 |
|
|
|
415 |
|
|
procedure TIBInstall.InstallExecute;
|
416 |
|
|
var
|
417 |
|
|
Handle : OPTIONS_HANDLE;
|
418 |
|
|
begin
|
419 |
|
|
Handle := 0;
|
420 |
|
|
InternalSetOptions(@Handle);
|
421 |
|
|
|
422 |
|
|
if Handle = 0 then
|
423 |
|
|
IBInstallerError(ieNoOptionsSet, []);
|
424 |
|
|
|
425 |
|
|
try
|
426 |
|
|
SetLength(FUninstallFile, ISC_INSTALL_MAX_PATH);
|
427 |
|
|
Call(isc_install_execute(Handle, PChar(FSourceDir), PChar(FDestinationDir),
|
428 |
|
|
StatusCallback, Pointer(self), ErrorCallback,
|
429 |
|
|
Pointer(self), PChar(FUninstallFile)));
|
430 |
|
|
SetLength(FUninstallFile, StrLen(PChar(FUninstallFile)));
|
431 |
|
|
finally
|
432 |
|
|
isc_install_clear_options(@Handle);
|
433 |
|
|
end;
|
434 |
|
|
end;
|
435 |
|
|
|
436 |
|
|
procedure TIBInstall.InternalSetOptions(pHandle: POPTIONS_HANDLE);
|
437 |
|
|
begin
|
438 |
|
|
with FInstallOptions do
|
439 |
|
|
begin
|
440 |
|
|
if FMainComponents <> [] then
|
441 |
|
|
begin
|
442 |
|
|
if moClient in FMainComponents then
|
443 |
|
|
isc_install_set_option(pHandle, IB_CLIENT);
|
444 |
|
|
if moDevelopment in FMainComponents then
|
445 |
|
|
isc_install_set_option(pHandle, IB_DEV);
|
446 |
|
|
if moServer in FMainComponents then
|
447 |
|
|
isc_install_set_option(pHandle, IB_SERVER);
|
448 |
|
|
if moDocumentation in FMainComponents then
|
449 |
|
|
isc_install_set_option(pHandle, IB_DOC);
|
450 |
|
|
if moConServer in FMainComponents then
|
451 |
|
|
isc_install_set_option(pHandle, IB_CONNECTIVITY_SERVER);
|
452 |
|
|
if moGuiTools in FMainComponents then
|
453 |
|
|
isc_install_set_option(pHandle, IB_GUI_TOOLS);
|
454 |
|
|
end;
|
455 |
|
|
|
456 |
|
|
if FExamples <> [] then
|
457 |
|
|
begin
|
458 |
|
|
if exDB in FExamples then
|
459 |
|
|
isc_install_set_option(pHandle, IB_EXAMPLE_DB);
|
460 |
|
|
if exAPI in FExamples then
|
461 |
|
|
isc_install_set_option(pHandle, IB_EXAMPLE_API);
|
462 |
|
|
end;
|
463 |
|
|
|
464 |
|
|
if FCmdLineTools <> [] then
|
465 |
|
|
begin
|
466 |
|
|
if cmDBMgmt in FCmdLineTools then
|
467 |
|
|
isc_install_set_option(pHandle, IB_CMD_TOOLS_DB_MGMT);
|
468 |
|
|
if cmDBQuery in FCmdLineTools then
|
469 |
|
|
isc_install_set_option(pHandle, IB_CMD_TOOLS_DB_QUERY);
|
470 |
|
|
if cmUsrMgmt in FCmdLineTools then
|
471 |
|
|
isc_install_set_option(pHandle, IB_CMD_TOOLS_USR_MGMT);
|
472 |
|
|
end;
|
473 |
|
|
|
474 |
|
|
if FConnectivityClients <> [] then
|
475 |
|
|
begin
|
476 |
|
|
if cnODBC in FConnectivityClients then
|
477 |
|
|
isc_install_set_option(pHandle, IB_ODBC_CLIENT);
|
478 |
|
|
if cnOLEDB in FConnectivityClients then
|
479 |
|
|
isc_install_set_option(pHandle, IB_OLEDB_CLIENT);
|
480 |
|
|
if cnJDBC in FConnectivityClients then
|
481 |
|
|
isc_install_set_option(pHandle, IB_JDBC_CLIENT);
|
482 |
|
|
end;
|
483 |
|
|
end;
|
484 |
|
|
end;
|
485 |
|
|
|
486 |
|
|
procedure TIBInstall.SetDestination(const Value: string);
|
487 |
|
|
var
|
488 |
|
|
IscCode : MSG_NO;
|
489 |
|
|
begin
|
490 |
|
|
if Value <> '' then
|
491 |
|
|
begin
|
492 |
|
|
IscCode := isc_install_precheck(0, nil, PChar(Value));
|
493 |
|
|
if(IscCode > isc_install_success) then
|
494 |
|
|
IBInstallError(IscCode);
|
495 |
|
|
end;
|
496 |
|
|
FDestinationDir := Value;
|
497 |
|
|
end;
|
498 |
|
|
|
499 |
|
|
procedure TIBInstall.SetInstallOptions(const Value: TInstallOptions);
|
500 |
|
|
begin
|
501 |
|
|
if FInstallOptions <> Value then
|
502 |
|
|
FInstallOptions.Assign(Value);
|
503 |
|
|
end;
|
504 |
|
|
|
505 |
|
|
procedure TIBInstall.SetSource(const Value: string);
|
506 |
|
|
var
|
507 |
|
|
IscCode : MSG_NO;
|
508 |
|
|
begin
|
509 |
|
|
if Value <> '' then
|
510 |
|
|
begin
|
511 |
|
|
IscCode := isc_install_precheck(0, PChar(Value), nil);
|
512 |
|
|
if(IscCode > isc_install_success) then
|
513 |
|
|
IBInstallError(IscCode);
|
514 |
|
|
end;
|
515 |
|
|
FSourceDir := Value;
|
516 |
|
|
end;
|
517 |
|
|
|
518 |
|
|
procedure TIBInstall.SuggestDestination;
|
519 |
|
|
begin
|
520 |
|
|
SetLength(FSuggestedDestination, ISC_INSTALL_MAX_PATH);
|
521 |
|
|
Call(isc_install_get_info(isc_install_info_destination, 0, PChar(FSuggestedDestination),
|
522 |
|
|
ISC_INSTALL_MAX_PATH));
|
523 |
|
|
SetLength(FSuggestedDestination, StrLen(PChar(FSuggestedDestination)));
|
524 |
|
|
end;
|
525 |
|
|
|
526 |
|
|
function TIBInstall.GetOptionDescription(Option: TExamplesOption): string;
|
527 |
|
|
var
|
528 |
|
|
OptionDesc : string;
|
529 |
|
|
begin
|
530 |
|
|
SetLength(OptionDesc, ISC_INSTALL_MAX_MESSAGE_LEN);
|
531 |
|
|
GetOptionProperty(isc_install_info_opdescription, Option, PChar(OptionDesc),
|
532 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
533 |
|
|
SetLength(OptionDesc, StrLen(PChar(OptionDesc)));
|
534 |
|
|
Result := OptionDesc;
|
535 |
|
|
end;
|
536 |
|
|
|
537 |
|
|
function TIBInstall.GetOptionDescription(Option: TCmdOption): string;
|
538 |
|
|
var
|
539 |
|
|
OptionDesc : string;
|
540 |
|
|
begin
|
541 |
|
|
SetLength(OptionDesc, ISC_INSTALL_MAX_MESSAGE_LEN);
|
542 |
|
|
GetOptionProperty(isc_install_info_opdescription, Option, PChar(OptionDesc),
|
543 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
544 |
|
|
SetLength(OptionDesc, StrLen(PChar(OptionDesc)));
|
545 |
|
|
Result := OptionDesc;
|
546 |
|
|
end;
|
547 |
|
|
|
548 |
|
|
function TIBInstall.GetOptionDescription(Option: TConnectivityOption): string;
|
549 |
|
|
var
|
550 |
|
|
OptionDesc : string;
|
551 |
|
|
begin
|
552 |
|
|
SetLength(OptionDesc, ISC_INSTALL_MAX_MESSAGE_LEN);
|
553 |
|
|
GetOptionProperty(isc_install_info_opdescription, Option, PChar(OptionDesc),
|
554 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
555 |
|
|
SetLength(OptionDesc, StrLen(PChar(OptionDesc)));
|
556 |
|
|
Result := OptionDesc;
|
557 |
|
|
end;
|
558 |
|
|
|
559 |
|
|
function TIBInstall.GetOptionDescription(Option: TMainOption): string;
|
560 |
|
|
var
|
561 |
|
|
OptionDesc : string;
|
562 |
|
|
begin
|
563 |
|
|
SetLength(OptionDesc, ISC_INSTALL_MAX_MESSAGE_LEN);
|
564 |
|
|
GetOptionProperty(isc_install_info_opdescription, Option, PChar(OptionDesc),
|
565 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
566 |
|
|
SetLength(OptionDesc, StrLen(PChar(OptionDesc)));
|
567 |
|
|
Result := OptionDesc;
|
568 |
|
|
end;
|
569 |
|
|
|
570 |
|
|
function TIBInstall.GetOptionName(Option: TExamplesOption): string;
|
571 |
|
|
var
|
572 |
|
|
OptionName : string;
|
573 |
|
|
begin
|
574 |
|
|
SetLength(OptionName, ISC_INSTALL_MAX_MESSAGE_LEN);
|
575 |
|
|
GetOptionProperty(isc_install_info_opname, Option, PChar(OptionName),
|
576 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
577 |
|
|
SetLength(OptionName, StrLen(PChar(OptionName)));
|
578 |
|
|
Result := OptionName;
|
579 |
|
|
end;
|
580 |
|
|
|
581 |
|
|
function TIBInstall.GetOptionName(Option: TCmdOption): string;
|
582 |
|
|
var
|
583 |
|
|
OptionName : string;
|
584 |
|
|
begin
|
585 |
|
|
SetLength(OptionName, ISC_INSTALL_MAX_MESSAGE_LEN);
|
586 |
|
|
GetOptionProperty(isc_install_info_opname, Option, PChar(OptionName),
|
587 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
588 |
|
|
SetLength(OptionName, StrLen(PChar(OptionName)));
|
589 |
|
|
Result := OptionName;
|
590 |
|
|
end;
|
591 |
|
|
|
592 |
|
|
function TIBInstall.GetOptionName(Option: TConnectivityOption): string;
|
593 |
|
|
var
|
594 |
|
|
OptionName : string;
|
595 |
|
|
begin
|
596 |
|
|
SetLength(OptionName, ISC_INSTALL_MAX_MESSAGE_LEN);
|
597 |
|
|
GetOptionProperty(isc_install_info_opname, Option, PChar(OptionName),
|
598 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
599 |
|
|
SetLength(OptionName, StrLen(PChar(OptionName)));
|
600 |
|
|
Result := OptionName;
|
601 |
|
|
end;
|
602 |
|
|
|
603 |
|
|
function TIBInstall.GetOptionName(Option: TMainOption): string;
|
604 |
|
|
var
|
605 |
|
|
OptionName : string;
|
606 |
|
|
begin
|
607 |
|
|
SetLength(OptionName, ISC_INSTALL_MAX_MESSAGE_LEN);
|
608 |
|
|
GetOptionProperty(isc_install_info_opname, Option, PChar(OptionName),
|
609 |
|
|
ISC_INSTALL_MAX_MESSAGE_LEN);
|
610 |
|
|
SetLength(OptionName, StrLen(PChar(OptionName)));
|
611 |
|
|
Result := OptionName;
|
612 |
|
|
end;
|
613 |
|
|
|
614 |
|
|
function TIBInstall.GetOptionSpaceRequired(Option: TExamplesOption): longword;
|
615 |
|
|
var
|
616 |
|
|
OptionSpace : Longword;
|
617 |
|
|
begin
|
618 |
|
|
GetOptionProperty(isc_install_info_opspace, Option, @OptionSpace,
|
619 |
|
|
Cardinal(SizeOf(OptionSpace)));
|
620 |
|
|
Result := OptionSpace;
|
621 |
|
|
end;
|
622 |
|
|
|
623 |
|
|
function TIBInstall.GetOptionSpaceRequired(Option: TMainOption): longword;
|
624 |
|
|
var
|
625 |
|
|
OptionSpace : Longword;
|
626 |
|
|
begin
|
627 |
|
|
GetOptionProperty(isc_install_info_opspace, Option, @OptionSpace,
|
628 |
|
|
Cardinal(SizeOf(OptionSpace)));
|
629 |
|
|
Result := OptionSpace;
|
630 |
|
|
end;
|
631 |
|
|
|
632 |
|
|
function TIBInstall.GetOptionSpaceRequired(Option: TConnectivityOption): longword;
|
633 |
|
|
var
|
634 |
|
|
OptionSpace : Longword;
|
635 |
|
|
begin
|
636 |
|
|
GetOptionProperty(isc_install_info_opspace, Option, @OptionSpace,
|
637 |
|
|
Cardinal(SizeOf(OptionSpace)));
|
638 |
|
|
Result := OptionSpace;
|
639 |
|
|
end;
|
640 |
|
|
|
641 |
|
|
function TIBInstall.GetOptionSpaceRequired(Option: TCmdOption): longword;
|
642 |
|
|
var
|
643 |
|
|
OptionSpace : Longword;
|
644 |
|
|
begin
|
645 |
|
|
GetOptionProperty(isc_install_info_opspace, Option, @OptionSpace,
|
646 |
|
|
Cardinal(SizeOf(OptionSpace)));
|
647 |
|
|
Result := OptionSpace;
|
648 |
|
|
end;
|
649 |
|
|
|
650 |
|
|
procedure TIBInstall.GetOptionProperty(InfoType: Integer; Option : TMainOption;
|
651 |
|
|
Buffer: Pointer; BufferLen : Cardinal);
|
652 |
|
|
var
|
653 |
|
|
IscOption : OPT;
|
654 |
|
|
begin
|
655 |
|
|
case Option of
|
656 |
|
|
moClient:
|
657 |
|
|
IscOption := IB_CLIENT;
|
658 |
|
|
moDevelopment:
|
659 |
|
|
IscOption := IB_DEV;
|
660 |
|
|
moServer:
|
661 |
|
|
IscOption := IB_SERVER;
|
662 |
|
|
moDocumentation:
|
663 |
|
|
IscOption := IB_DOC;
|
664 |
|
|
moGuiTools:
|
665 |
|
|
IscOption := IB_GUI_TOOLS;
|
666 |
|
|
else
|
667 |
|
|
IscOption := IB_CONNECTIVITY_SERVER;
|
668 |
|
|
end;
|
669 |
|
|
Call(isc_install_get_info(InfoType, IscOption, Buffer, BufferLen));
|
670 |
|
|
end;
|
671 |
|
|
|
672 |
|
|
procedure TIBInstall.GetOptionProperty(InfoType: Integer; Option: TExamplesOption;
|
673 |
|
|
Buffer: Pointer; BufferLen : Cardinal);
|
674 |
|
|
var
|
675 |
|
|
IscOption : OPT;
|
676 |
|
|
begin
|
677 |
|
|
case Option of
|
678 |
|
|
exDB:
|
679 |
|
|
IscOption := IB_EXAMPLE_DB;
|
680 |
|
|
else
|
681 |
|
|
IscOption := IB_EXAMPLE_API;
|
682 |
|
|
end;
|
683 |
|
|
Call(isc_install_get_info(InfoType, IscOption, Buffer, BufferLen));
|
684 |
|
|
end;
|
685 |
|
|
|
686 |
|
|
procedure TIBInstall.GetOptionProperty(InfoType: Integer; Option: TCmdOption;
|
687 |
|
|
Buffer: Pointer; BufferLen : Cardinal);
|
688 |
|
|
var
|
689 |
|
|
IscOption : OPT;
|
690 |
|
|
begin
|
691 |
|
|
case Option of
|
692 |
|
|
cmDBMgmt:
|
693 |
|
|
IscOption := IB_CMD_TOOLS_DB_MGMT;
|
694 |
|
|
cmDBQuery:
|
695 |
|
|
IscOption := IB_CMD_TOOLS_DB_QUERY;
|
696 |
|
|
else
|
697 |
|
|
IscOption := IB_CMD_TOOLS_USR_MGMT;
|
698 |
|
|
end;
|
699 |
|
|
Call(isc_install_get_info(InfoType, IscOption, Buffer, BufferLen));
|
700 |
|
|
end;
|
701 |
|
|
|
702 |
|
|
procedure TIBInstall.GetOptionProperty(InfoType: Integer; Option: TConnectivityOption;
|
703 |
|
|
Buffer: Pointer; BufferLen : Cardinal);
|
704 |
|
|
var
|
705 |
|
|
IscOption : OPT;
|
706 |
|
|
begin
|
707 |
|
|
case Option of
|
708 |
|
|
cnODBC:
|
709 |
|
|
IscOption := IB_ODBC_CLIENT;
|
710 |
|
|
cnOLEDB:
|
711 |
|
|
IscOption := IB_OLEDB_CLIENT;
|
712 |
|
|
else
|
713 |
|
|
IscOption := IB_JDBC_CLIENT;
|
714 |
|
|
end;
|
715 |
|
|
Call(isc_install_get_info(InfoType, IscOption, Buffer, BufferLen));
|
716 |
|
|
end;
|
717 |
|
|
|
718 |
|
|
{ TIBUnInstall }
|
719 |
|
|
|
720 |
|
|
procedure TIBUnInstall.UnInstallCheck;
|
721 |
|
|
begin
|
722 |
|
|
if FUninstallFile = '' then
|
723 |
|
|
IBInstallerError(ieNoUninstallFile, []);
|
724 |
|
|
|
725 |
|
|
Call(isc_uninstall_precheck(PChar(FUninstallFile)));
|
726 |
|
|
end;
|
727 |
|
|
|
728 |
|
|
procedure TIBUnInstall.UnInstallExecute;
|
729 |
|
|
begin
|
730 |
|
|
if FUninstallFile = '' then
|
731 |
|
|
IBInstallerError(ieNoUninstallFile, []);
|
732 |
|
|
|
733 |
|
|
Call(isc_uninstall_execute(PChar(FUninstallFile), StatusCallback, Pointer(self),
|
734 |
|
|
ErrorCallback, Pointer(self)));
|
735 |
|
|
end;
|
736 |
|
|
|
737 |
|
|
{ EIBInstall }
|
738 |
|
|
|
739 |
|
|
constructor EIBInstall.Create(IscCode: MSG_NO; IscMessage: string);
|
740 |
|
|
begin
|
741 |
|
|
inherited Create(IscMessage);
|
742 |
|
|
FIscError := IscCode;
|
743 |
|
|
FInstallerError := ieSuccess;
|
744 |
|
|
end;
|
745 |
|
|
|
746 |
|
|
constructor EIBInstall.Create(ECode: TIBInstallerError; EMessage: string);
|
747 |
|
|
begin
|
748 |
|
|
inherited Create(EMessage);
|
749 |
|
|
FInstallerError := ECode;
|
750 |
|
|
FIscError := isc_install_success;
|
751 |
|
|
end;
|
752 |
|
|
|
753 |
|
|
end.
|