The winform program is started with Windows service.

Source: Internet
Author: User

Sometimes some programs need to run as services, but cannot be made into services. For example, ActiveX controls are called on winform and ActiveX controls cannot be run in services.

There are two solutions:

1. Make a scheduled task. Here, the focus is on running the task before logging on to all users.

2. Start the winform program as a Service. The disadvantage is that you need to run two processes,CodeRefer to the following:

 

Code

Private Process = Null ;
Public Service1 ()
{
Initializecomponent ();
}

protected override void onstart ( string [] ARGs)
{< br> // Start the winform program, here, the winfrom program and service are in the same directory
Process = process. start (appdomain. currentdomain. basedirectory + " test.exe " );
}

Protected Override VoidOnstop ()
{
//Close winform Program
Process. closemainwindow ();
Process. Close ();
Process. Dispose ();
}

 

 

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.