Solved

RegisterServiceProcess to stop closure

Posted on 1998-06-06
4
172 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
ID: 1351053
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
ID: 1351054
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
ID: 1351055
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
ID: 1351056
There is also a message called WM_USERCHANGED this message is sent when has logged in or out.

Mories
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

762 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