GithubHelp home page GithubHelp logo

ifindikli / delphi-windowsserviceutils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daviladanielc/delphi-windowsserviceutils

0.0 0.0 0.0 50 KB

Create, delete, stop, start, and change configurations of Windows services.

License: MIT License

Pascal 100.00%

delphi-windowsserviceutils's Introduction

Delphi-WinServiceUtils

Create, delete, stop, start, and change configurations of Windows services.

Description

The ISvcUtils interface provides a comprehensive set of functionalities for managing Windows services. Developed by Daniel Carlos Davila, this component simplifies service-related operations, making it easy to work with service configurations, installations, and more.

Forget about creating .bat files and invoking everything through ShellExecute; now you can do all of that directly in Delphi.

Key Features:

Service Management:

  • Rebuild and query the states, names, and configurations of all services on a given machine.
  • Install and uninstall services effortlessly, with options for configuring service type, start type, and more.

Service Information:

  • Retrieve detailed information about services, including their current state, display name, dependencies, and startup type.
  • Pause, continue, start, and stop services with ease.

Service Enumeration:

  • Access the total number of services, find services by index or name, and check if a service exists.

Active Service Management:

  • Activate or deactivate the service manager, allowing seamless access to individual service properties.

Sorting and Exporting:

  • Sort services by display name for better organization.
  • Export service information to XML or CSV format.

How to install

To use the component is easy, simply add the "src" folder from this repository to the Library path settings in your Delphi or to the Search Path of your project. After that, you only need to declare the "SvcUtils.IntF" unit in the Delphi's uses clause.

Works with Delphi XE3 to 12.0

How to use

Declaration variable:

var
  LService: ISvcUtils;
begin
  LService:= TSvcUtils.New;
  if LService.GetServiceByName('MyService').isStarted then
    ShowMessage('The service is running');
end;

One line implementation

  TSvcUtils.New.
           .InstallService('MyService', 'My Service Display Name',
                           TSvcType.ServiceWin32OwnProcess, //default service instalation
                           TSvcStartType.ServiceDemandStart, //start manually
                           TSvcErrorControl.ServiceErrorNormal,
                           'C:\myservice.exe', //Service binary path, the path can also include arguments for an auto-start service. For example, "d:\myshare\myservice.exe arg1 arg2"
                           '', nil).ServiceStart;               

or

  TSvcUtils.New.
           .GetServiceByName('MyService').ServiceStart;               

Get the Service Info

var
  LSvcInfo: ISvcInfo;
begin
  LSvcInfo:= TSvcUtils.New.
           .InstallService('MyService', 'My Service Display Name',
                           TSvcType.ServiceWin32OwnProcess, //default service instalation
                           TSvcStartType.ServiceDemandStart, //start manually
                           TSvcErrorControl.ServiceErrorNormal,
                           'C:\myservice.exe', //Service binary path
                           '', nil);
// with LSvcInfo you can do a lot of things, stop, start, change configuration etc...
// Service description can be set calling LSvcInfo.ChangeDescription('My description');
end;           

Uninstall a Service

 if TSvcUtils.New.UninstallService('MyService') then
    ShowMessage('Done!');

Change service configuration

  TSvcUtils.New
           .GetServiceByName('MyService')
           .ChangeServiceType()
           .ChangeServiceStart()
           .ChangeServiceErrorControl()
           .ChangeBinaryPath()
           .ChangeAccountName()
           .ChangeDisplayName()
           .ChangeDescription(); 

ATTENTION

Make sure your application has administrative privileges.

Don't worry about freeing up memory objects, as everything is done based on interfaces

Delphi

Made with ❤️ for Delphi

delphi-windowsserviceutils's People

Contributors

daviladanielc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.