Subject isc_service_attach in Delphi and Interbase Express
Author lacakus
Hi All,
I am trying write Delphi app which uses FB ServiceManager functions.
As a
template I study IBServices.pas from Interbase Express. Look please
at the
following piece of code :

procedure TIBCustomService.Attach;
var
SPB: String;
ConnectString: String;
begin
CheckInactive;
CheckServerName;

if FLoginPrompt and not Login then
IBError(ibxeOperationCancelled, [nil]);

{ Generate a new SPB if necessary }
if FParamsChanged then
begin
FParamsChanged := False;
GenerateSPB(FParams, SPB, FSPBLength);
IBAlloc(FSPB, 0, FsPBLength); //
<-------------------------Why we need this ?
Move(SPB[1], FSPB[0], FSPBLength); // <------------------------
-Why
we need this ?
end;
case FProtocol of
TCP: ConnectString := FServerName + ':service_mgr'; {do not
localize}
SPX: ConnectString := FServerName + '@service_mgr'; {do not
localize}
NamedPipe: ConnectString := '\\' + FServerName + '\service_mgr';
{do not
localize}
Local: ConnectString := 'service_mgr'; {do not localize}
end;
if call(FGDSLibrary.isc_service_attach(StatusVector,
Length(ConnectString), PChar(ConnectString), @FHandle,
FSPBLength, FSPB), False) > 0 then

//-----------------------------------------------------------------
Why we need call IBAlloc, which calls ReallocMem procedure and then
Move
data from SPB to FSPB buffer ?
Why not only use in isc_service_attach instead of
FSPB declared as PChar
this:
PChar(SPB) ?
For me this works, but I am not sure if I not missed something ???

TIA
-Laco.