Go to the Windows Service series & mdash; Use Boost. Application to quickly build Windows Services and compile boostwindows

Source: Internet
Author: User

Turn to the Windows Service series-use Boost. Application to quickly build Windows Services, boostwindows Compilation

The article "Create a Windows Service" describes how to quickly use VS to build a Windows service. The registration and uninstallation of Debug and Release versions, as well as analysis of the Principles and service operation and stop processes respectively introduce the simple procedures of registering, uninstalling, running, and stopping Windows Services. Today we will introduce how to use the open-source library Boost. Application to quickly build a Windows service.

Introduction to Boost. Application

Boost. Application is an open-source C ++ library mainly used to build cross-platform services, including Windows, Unix, Linux, and MaxOS. Yes, this database can be used for cross-platform services. Boost. Application uses the open-source protocol Boost Software License, Version 1.0.

Boost. Application is not yet the official Boost library. to use it, you need to download the latest code from Github. The current version is 0.4.12.

Use Boost. Application to Build Windows Services

Step 1: Use VS to create a console program.

Step 2: configure the include path and lib path of Boost. Application and Boost.

Step 3: copy the sample code in the README. md file under the Boost. Application directory to myservice. cpp and overwrite all the original code.

Part 4: Set the compilation option to multi-byte

Step 5: Compile and run the program

Because the service has not been registered at this time, an error will be reported when running on the console.

Step 6: register the program as a Windows Service and execute the following command in the command line:

sc create myservice binpath= "D:\Code\C++\CommonCode\Win32\Debug\myservice.exe" type= own start= demand displayname= "service test"

For details about how to use SC commands, refer to "go to Windows Service series"-"command line" to manage Windows Services.

In Windows Service Manager, you can see the service you just created:

Start Log... running Arg List ------------------------------------------ myservice ----------------------------- 0, running... 1, running... 2, running... Stoping my application...

In this way, a complete Windows service is complete.

Register a service program

In the "Boost. Application \ example \ setup" Directory of Boost. Application, there is a sample code used to register and uninstall the service.

After compiling this example code as service_setup_ex.exe, you can use this program to register and uninstall services.

Install the service. You can set the program path, service name, display name, description, startup mode, and dependent services as follows:

service_setup_ex.exe -i --name="My Service" --path="c:\myservice\service.exe"service_setup_ex.exe -i --name="My Service" --path="c:\myservice\service.exe" --display="My Service"service_setup_ex.exe -i --name="My Service" --path="c:\myservice\service.exe" --display="My Service" --description "Service Description"service_setup_ex.exe -i --name="My Service" --path="c:\myservice\service.exe" --user=".\Renato Tegon Forti" --pass="x1x1x1"service_setup_ex.exe -i --name="My Service" --path="c:\myservice\service.exe" --start="manaul" --depends="service1\service2\service3"

Detection Service:

service_setup_ex.exe -c --name="My Service"

Uninstall the service:

service_setup_ex.exe -u --name="My Service" --path="c:\myservice\service.exe"

References

Boost. Application

Build a Server Application using Application Library

Series links

Go to the Windows Service series-create a Windows Service

How to register and uninstall the Debug and Release versions of the Windows Service series

Go to the Windows Service series -- Why Windows service fails to be started without the COM interface and the Solution

Go to the Windows Service series-analysis of service running and stopping Processes

Turn to the Windows Service series-Tips for Windows Services

Go to Windows Service series-command line management for Windows Services

Fun with Windows Service series-Windows Service Startup timeout

Go to the Windows Service series-use Boost. Application to quickly build Windows Services

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.