running app as a service - logoff user shuts down application

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
 
D

Dmytro Lapshyn [MVP]

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.
 
R

Rob Latour

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
 
D

Dmytro Lapshyn [MVP]

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.
 
R

Rob Latour

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top