Solved

RegisterServiceProcess to stop closure

Posted on 1998-06-06
4
170 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 76
update joined tables 2 46
RESTRequest Parameter 4 31
Delphi: sending SMS on android platform 1 21
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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