Solved

RegisterServiceProcess to stop closure

Posted on 1998-06-06
4
167 Views
Last Modified: 2010-04-06
I have written a program that needs to be running 100% of the time the computer is running. It starts from the RunServices section of the W95 Registry so it loads before the log-on screen, but all RunServices programs are closed on logoff.

W32s help says that I need to call RegisterServiceProcess so my app isn't closed, but it gives no other information on it.  I would imagine it is in a dll, probably kernel32.dll - but I have no idea how to access this.

I have tried looking for the WM_ENDSESSION and WM_QUERYENDSESSION messages to see if they are passing me the "yes, user is logging off" message, but my app gets closed whatever I do then and sometimes the messages don't even come through.

TIA,

Ed Moore
0
Comment
Question by:edmoore
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
Comment Utility
Hi

RegisterServiceProcess is in kernel32, so add this to your app and it should work:

function RegisterServiceProcess(ThreadID: THandle; Flags: Integer): Integer; stdcall; external kernel32 name 'RegisterServiceProcess';

This also removes the task from the task list when you press Ctrl-Alt-Del in Win 95 (not NT).

Cheers,
JB
0
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
P.S.  Call as follows:

const
  RSP_SIMPLE_SERVICE = 1;
  RSP_UNREGISTER_SERVICE = 0;

procedure TMyForm.FormShow(Sender: TObject);
begin
  RegisterServiceProcess(0, RSP_SIMPLE_SERVICE);
end;

Cheers,
JB
0
 
LVL 1

Expert Comment

by:mories
Comment Utility
There is also a message called WM_USERCHANGED this message is sent when has logged in or out.

Mories
0
 
LVL 1

Expert Comment

by:mories
Comment Utility
There is also a message called WM_USERCHANGED this message is sent when has logged in or out.

Mories
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now