Unit u_svc

---------------------------------------------------- // u_svc // Delphi unit to control Windows services // Feedback / latest version: // http://www.chamisplace.com/tips/delphi/services/ // (C) Chami.com // ----------------------------------------------------

Classes

Functions

ServiceGetStatus - ------------------------------------- get service status // return status code if successful -1 if not // return codes: SERVICE_STOPPED SERVICE_RUNNING SERVICE_PAUSED // following return codes are used to indicate that the service is in the middle of getting to one of the above states: SERVICE_START_PENDING SERVICE_STOP_PENDING SERVICE_CONTINUE_PENDING SERVICE_PAUSE_PENDING // sMachine: machine name, ie: \\SERVER empty = local machine // sService service name, ie: Alerter //
ServiceGetStrCode - ------------------------------------- convert status codes returned by ServiceGetStatus() to string values //
ServiceRunning - ------------------------------------- return TRUE if the specified service is running, defined by the status code SERVICE_RUNNING.
ServiceStart - ------------------------------------- start service // return TRUE if successful // sMachine: machine name, ie: \\SERVER empty = local machine // sService service name, ie: Alerter //
ServiceStop - ------------------------------------- stop service // return TRUE if successful // sMachine: machine name, ie: \\SERVER empty = local machine // sService service name, ie: Alerter //
ServiceStopped - ------------------------------------- return TRUE if the specified service was stopped, defined by the status code SERVICE_STOPPED.

Types

Constants

Variables


Functions


function ServiceGetStatus( sMachine, sService : string ) : DWord;

------------------------------------- get service status // return status code if successful -1 if not // return codes: SERVICE_STOPPED SERVICE_RUNNING SERVICE_PAUSED // following return codes are used to indicate that the service is in the middle of getting to one of the above states: SERVICE_START_PENDING SERVICE_STOP_PENDING SERVICE_CONTINUE_PENDING SERVICE_PAUSE_PENDING // sMachine: machine name, ie: \\SERVER empty = local machine // sService service name, ie: Alerter //

function ServiceGetStrCode( nID : integer ) : string;

------------------------------------- convert status codes returned by ServiceGetStatus() to string values //

function ServiceRunning( sMachine, sService : string ) : boolean;

------------------------------------- return TRUE if the specified service is running, defined by the status code SERVICE_RUNNING. return FALSE if the service is in any other state, including any pending states //

function ServiceStart( sMachine, sService : string ) : boolean;

------------------------------------- start service // return TRUE if successful // sMachine: machine name, ie: \\SERVER empty = local machine // sService service name, ie: Alerter //

function ServiceStop( sMachine, sService : string ) : boolean;

------------------------------------- stop service // return TRUE if successful // sMachine: machine name, ie: \\SERVER empty = local machine // sService service name, ie: Alerter //

function ServiceStopped( sMachine, sService : string ) : boolean;

------------------------------------- return TRUE if the specified service was stopped, defined by the status code SERVICE_STOPPED. //

Types


Constants


Variables