TIBBackupService, cannot attach to service manager

Good day

I am trying to backup my database from Delphi, but I am getting the following error.
cannot attach to service manager.

I read in the help but I am not sure what service component I must add.

Thank you

Henry


var srvBackup : TIBBackupService;
    lOptions  : TBackupOptions;
begin
    srvBackup := TIBBackupService.Create(nil);
    srvBackup.Params.Clear;
    Memo1.Clear;
    Screen.Cursor := crHourGlass;
    try
       srvBackup.Active := true;
       srvBackup.Attach();
       lOptions := [];
 
       if srvBackup.Active = true then
       begin
 
          with srvBackup do
          begin
            ServerName  := 'localhost';
            LoginPrompt := False;
            Params.Add('user_name=sysdba');
            Params.Add('password=masterkey');
            BackupFile.Add('c:\Backup');
            DatabaseName := 'c:\Databases\Database.fd2';
            Verbose := true;
            ServiceStart;
            while not srvBackup.Eof do
            begin
             Application.ProcessMessages;
             Memo1.Lines.Add(srvBackup.GetNextLine)
            end;
          end;
       end;
 
    finally
      if srvBackup.Active then
        srvBackup.Detach();
        Screen.Cursor := crDefault;
    end;

Open in new window

henryreynoldsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnjcesCommented:
You might try this to connect to the service manager and get a handle to you service.

Machine can be Null for the local machine or use standard \\Machine for a remote pc.

To get a handle to your backup service is the service name of your backup service. That which shows up in your Windows service manager.

John
var
  SVCManHandle, SvcHandle: SC_Handle;
begin
  // Open service manager handle.
  SVCManHandle := OpenSCManager('Machine', nil, SC_MANAGER_CONNECT);
  if (SVCManHandle > 0) then
  begin
    SvcHandle := OpenService(SVCManHandle, 'Service', SERVICE_QUERY_STATUS);
    // if Service installed
    if (SvcHandle > 0) then
    begin
      // I think once you get a handle you can do your backup stuff
      // here.. Make surfe the service is running. There is a structure here,
      // TServiceStatus, that you can query for the status as well.
    end;
    CloseServiceHandle(SvcHandle);
  end;
   CloseServiceHandle(SVCManHandle);
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
henryreynoldsAuthor Commented:
Hi John

Sorry but it does not work, it does not open the first service:
SVCManHandle := OpenSCManager('Machine', nil, SC_MANAGER_CONNECT);

0
JohnjcesCommented:
What error do you get?

Machine := '' (Null) for your local machine. Do not put in \\Machine.

and Service := your service name...

and in the uses clause make sure you have

uses
 WinSvc;

John

0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

JohnjcesCommented:
Are you still stuck?

John
0
henryreynoldsAuthor Commented:
Hi John

I only got back at work today, but I think it is something todo with the protocol you must specify.
You can specify LOCAL, TCP or SPX.

I will let you know
0
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.