• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

How To hide my application from tasklist? (win95/98)

Hi!
    I tried to hide my application with following code:

    var i:longint;
        handle:longint;
    begin
    i:=GetCurrentProcessId;
    handle:=OpenProcess(PROCESS_ALL_ACCESS,true,i);
    RegisterServiceProcess(handle,1);
    end;

It do not work. Any idea?
0
drol
Asked:
drol
  • 4
  • 2
  • 2
  • +4
1 Solution
 
bdtikastCommented:
At designtime I set the mainform invisible and Application.ShowMainForm to false. Below is the part in the application's .DPR I changed (View, Project Source).

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.ShowMainForm:= false;
  Form1.Visible:= false;
  Application.Run;
end.

0
 
xpherCommented:
drol

I have done this to hide the button from the taskbar. Added this to the project source (you must also add Windows to uses)
example

program YourApplication;

uses
  Windows,
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {AboutForm};

{$R *.RES}

begin
  Application.Initialize;
  Application.ShowMainForm := False;
  Application.Title := 'Your Application';
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TAboutForm, AboutForm);
  ShowWindow(Application.Handle, SW_HIDE);
  Application.Run;
end.
0
 
xpherCommented:
if you wanted to show it again you would use SW_RESTORE inplace of SW_HIDE

Regards
Chris
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
ahalyaCommented:
drol,

even though "RegisterServiceProcess" is supposed to register the application with the given handle, i have never seen/heard that it worked with third party programs.

if you are trying to remove YOUR program from the tasklist then you can call RSP with a parameter of 0 rather than the handle. The following works perfectly in Delphi.

ok := RegisterServiceProcess (0, RSP_SIMPLE_SERVICE);
if ok  = 0 then ShowMessage ('Error Registering Service');

i guess this is the info you're looking for.
0
 
msac_mCommented:
Hi all,

  I could not undertand why you used OpenProcess, Simply try this

  RegisterServiceProcess(GetCurrentProcessID,1);

And as bdtikast  do not forget to hide the mainform

That is all I think,

Regards,

0
 
msac_mCommented:
Sorry for mistyping the third to last line of my comment, it  would be

"And as bdtikast  SAID,  do not forget to hide the mainform "

Regards.
0
 
drolAuthor Commented:
i want to hide my application from tasklist not from taskbar.
0
 
drolAuthor Commented:
registerserviceprocess(0,1) does not work.
i'm running win98.
I use delphi 3 and include the function from kernel32.dll as 'external'. is there a unit that includes the function?

where in the code you use the function?
0
 
ZifNabCommented:
Hi drol,

this should work :

const
  RSP_SIMPLE_SERVICE = 1;
  RSP_UNREGISTER_SERVICE = 0;

function RegisterServiceProcess(dwProcessID, dwType: DWORD):DWORD;
stdcall; external 'KERNEL32.DLL';

When the program starts :
RegisterServiceProcess(GetCurrentProcessID, RSP_SIMPLE_SERVICE);

When the program stops :
RegisterServiceProcess(GetCurrentProcessID, RSP_UNREGISTER_SERVICE);

Regards, Zif.
0
 
ahalyaCommented:
drol,

RegisterServiceProcess(0, 1) works in Win95.
i Register the my serivces in the FormCreate method.
0
 
drolAuthor Commented:
Thank you all!
Now, it works.
I forgot the 'stdcall' statement. :-)
0
 
sagerydCommented:
How do I hide the application from the taskbar and still have the main form unhidden?
0
 
drolAuthor Commented:
Hi Sageryd

try
Application.ShowMainForm:=false;
0
 
sagerydCommented:
WRONG! That hides the form AND the taskbar-button. I want something that only hides my application from the taskbar, not the MainForm!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 4
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now