running app as a service - logoff user shuts down application

  • Thread starter Thread starter Rob Latour
  • Start date Start date
R

Rob Latour

I've set up an application to run as a service using srvany

the application starts fine as a service when my pc is powered up

everything stays fine when a user logs on

however when a user logs off (with out shuting down) the application ends

is there an event or something I can work with to prevent my application
(written in vb.net using vs 2005)
from ending when the user logs off

thanks in advance

Rob
 
Hi Rob,

Does your app interact with the desktop? I just have a guess that since
there might be no window station available after the user logging off,
srvany might have to shut down your application if it is designed to
interact with the user (which services should mostly never do).

I might also suppose this is a srvany bug, but I have absolutely nothing to
prove this - so what you might do is to search for a list of srvany's known
issues.
 
Hi

Yes my app does interact with the desktop, and the appropriate check box is
checked in the service properties window.

The research I have done to date seems to indicate my app needs to handle
the CTRL_LOGOFF_EVENT
but I can't seem to find anything inteligable to says how to go about this
espicially in visual basic .net
 
Hi again,

You can use the SetConsoleCtrlHandler function to specify the handler
routine. I believe this can be done in .NET (with P/Invoke), and you might
want to post a corresponding question to the
microsoft.public.dotnet.framework.interop.

Unfortunately I never did WinAPI callbacks in .NET so I really can't be very
helpful. You might be just fine with declaring the API function with
[DllImport] and declaring a delegate corresponding to the handler function's
prototype (the return value and the arguments), but it might turn out to be
more complex than that.
 
thank you

Dmytro Lapshyn said:
Hi again,

You can use the SetConsoleCtrlHandler function to specify the handler
routine. I believe this can be done in .NET (with P/Invoke), and you might
want to post a corresponding question to the
microsoft.public.dotnet.framework.interop.

Unfortunately I never did WinAPI callbacks in .NET so I really can't be
very helpful. You might be just fine with declaring the API function with
[DllImport] and declaring a delegate corresponding to the handler
function's prototype (the return value and the arguments), but it might
turn out to be more complex than that.

Rob Latour said:
Hi

Yes my app does interact with the desktop, and the appropriate check box
is checked in the service properties window.

The research I have done to date seems to indicate my app needs to handle
the CTRL_LOGOFF_EVENT
but I can't seem to find anything inteligable to says how to go about
this espicially in visual basic .net
 
Back
Top