Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using WinSvc CreateService to install a service...?

Status
Not open for further replies.

djjd47130

Programmer
Nov 1, 2010
480
US
I have been building a service manager through the WinSvc unit in Delphi7. I have almost everything done, start/stop/pause/continue/restart/get config/set config/uninstall - everything except for Install. I know you need to use CreateService to install it, but it seems as if the function presumes you already know the information about it (Name, Display Name, etc.) when all I have available is a Filename (to the EXE service). In the past, I have intalled using ShellExecuteEx calling the filename with /install. Now I need to use WinSvc entirely.

How can I install a service using WinSvc when all I have is a filename, and no info?

Code:
function ServiceInstall(sMgr: SC_Handle; sFilename: String): SC_Handle;
begin
  Result:= 0;
  if sMgr > 0 then begin
    Result:= CreateService(sMgr, ...... sFilename, ....);
  end;
end;


JD Solutions
 
I have an installation program to install a service I wrote, and from the installer, I use this to install the service:

Code:
WinExec('cmd.exe /c <yourexefilename.exe> /install /silent', SW_HIDE);

The /silent gives no feedback to the user on the installation of the service and can be removed.

Additionally, if you want to automatically start your service once it is installed (rather than manually start it after install) then read this article as Delphi3000.com

 
Thanks, but as mentioned above, I am already executing a command line and don't want to. I want to use the specific function CreateService in the API. This is because the WinSvc method can connect to another machine. Plus the whole point is just to be able to use the WinSvc unit. It's just sloppy how everything I have is using the WinSvc unit, except for the installing, which is using a command line. If the API has the ability, I want to stick with that method.

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top