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 »

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: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

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?
Gnawer
Experienced Solver
Experienced Solver
Posts: 65
Joined: Thu Jun 29, 2006 11:10 am
Location: Ahlen, Germany

Re: Running wxWidgets app as a windows service

Post by Gnawer »

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: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Running wxWidgets app as a windows service

Post by evstevemd »

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?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Running wxWidgets app as a windows service

Post by doublemax »

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