Running wxWidgets app as a windows service

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Sickboy
Experienced Solver
Experienced Solver
Posts: 91
Joined: Wed Mar 16, 2005 10:30 pm
Location: Germany

Post by Sickboy » Sat Mar 22, 2008 11:57 pm

I can compile and install the service without problems but i'm not sure where to place my methods.

I tried it in line 41:

Code: Select all

...
// INIT THE REAL SERVICE HERE AND LET THE MAIN LOOP RUN
while(true)
{
  wxSleep(2);
  ::wxBell();
}
...
But if i start the service, the "Service Startup Dialog" doesn't disappear and the startup timed out after a while with the error 1053.

The same happen if i put the while loop into the int MainApp::OnRun().

I've also removed the SERVICE_INTERACTIVE_PROCESS in the MainApp::Install(void) method, reinstalled the service, without success.

Any idea what i'm doing wrong ?

thx,
Stefan

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2168
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Mon Apr 19, 2010 5:33 pm

priyank_bolia wrote:http://priyank.co.in/downloads/wxWin32Service.7z
Added unicode support...
Disclamatory warning: I had just compiled the above code, haven't tested whether it works on not.
Link is broken, can you fix it?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

Gnawer
Experienced Solver
Experienced Solver
Posts: 53
Joined: Thu Jun 29, 2006 11:10 am
Location: Ahlen, Germany

Re: Running wxWidgets app as a windows service

Post by Gnawer » Mon Oct 19, 2015 11:22 am

Great Code!
I was able to create a service that handles socket events.
A last problem I have to solve: an administrator launches Service Control Manager and stops the service.
This event can be catched by "WaitForSingleObject" method, so I read in MSDN.
But I want to catch it by a wx Event handler, same way as socket events.
wxEVT_END_SESSION etc. does not work.
Did anybody make it already?
Best regards
Gnawer

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2168
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Running wxWidgets app as a windows service

Post by evstevemd » Mon Oct 19, 2015 1:36 pm

If you know how to do it in MSDN way then catch it and create new custom event which you can dispatch it using wxPostEvent
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
doublemax
Moderator
Moderator
Posts: 13552
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Running wxWidgets app as a windows service

Post by doublemax » Mon Oct 19, 2015 2:02 pm

BTW: There was a more recent post about creating a Windows service with wxWidgets.

Maybe it helps: viewtopic.php?f=10&t=41497
Use the source, Luke!

Post Reply