Solved

RegisterServiceProcess to stop closure

Posted on 1998-06-06
4
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

623 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