Solved

RegisterServiceProcess to stop closure

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 72
Printing problem 2 80
Delphi XE10 Round Image 2 77
Run video youtube webbrowse 10 57
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

19 Experts available now in Live!

Get 1:1 Help Now