Link to home
Start Free TrialLog in
Avatar of nafa2221
nafa2221

asked on

Hide Program

How do I hide my program from the CTRL + ALT + DEL and from ALT + TAB etc...I want it to be completely hiddeen
Avatar of Epsylon
Epsylon

This works in Windows 95/98:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Hide: TButton;
    Show: TButton;
    procedure HideClick(Sender: TObject);
    procedure ShowClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.HideClick(Sender: TObject);
begin
  RegisterServiceProcess(GetCurrentProcessId, 1);
end;

procedure TForm1.ShowClick(Sender: TObject);
begin
  RegisterServiceProcess(GetCurrentProcessId, 0);
end;

end.
Hmmm... it doesn't hide it from ctrl -tab...
It does when form1.visible := false

:o)
Avatar of nafa2221

ASKER

I need code that works under Windows2000 as well ;]
I think you can better forget that...
why is that?
yep you wont get code for nt or win2k..

i suggest add epsylons functions as he did and also add these 2 functions after implementation word:

procedure TurnSysKeysOff;
var
  OldVal : LongInt;
begin
  SystemParametersInfo (97, Word (True), @OldVal, 0)
end;

procedure TurnSysKeysBackOn;
var
  OldVal : LongInt;
begin
  SystemParametersInfo (97, Word (False), @OldVal, 0)
end;

instead of buttonclick etc use the
formcreate or formactivate event to call both:

RegisterServiceProcess(GetCurrentProcessId, 1);
TurnSysKeysOff;

and on form destroy call both:
RegisterServiceProcess(GetCurrentProcessId, 0);
TurnSysKeysOn;

that will also Disables alt/tab and crtl/esc..
can you give me code that will determain if I am in Windows NT and if I am disable CTRL + ALT + DEL all together, and if it is windows 98/95 hide it from the task list? Thanks
i gave you code in the other question to tell what operating system your in.

as you are new to delphi it really wont help you learn very well if we paste the whole of your project here and im sure you like to learn it ;-)

to disable ctrl-alt-del in nt is no beginner stuff.
it is also not good practice because nt is a multitasking operating system and ctrl-alt-del gives the user access to important functions of the os.
if your program gets stuck how do they kill it?apart from hard reboot..
Here you go:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TRegServ = function (dwProcessID,dwType : DWORD) : DWORD; stdcall;
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var Handle: HINST;
    RegServ: TRegServ;
begin
  if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
  begin
    Handle := LoadLibrary('KERNEL32.DLL');
    if Handle <> 0 then
    begin
      RegServ := GetProcAddress(Handle, 'RegisterServiceProcess');
      RegServ(GetCurrentProcessID, 1);
      FreeLibrary(Handle);
    end;
  end;
end;

end.
Btw, hiding from ctrl-tab works on all platforms by hiding the form (or just using no forms at all).

Form1.Visible := false;
listenning
You can do this in the OnActivate (at least that's what I do)

Procedure Form1.FormActivate(Sender:TObject);
Begin
  ShowWindow(Handle,SW_HIDE);
  ShowWindow(Application.Handle,SW_HIDE);
End;
Listening
ASKER CERTIFIED SOLUTION
Avatar of hhamster
hhamster
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hhamster, Barry (inthe) already mentioned that...
hhamster ,
how on earth can you propose that as an answer if there are already other comments in the question mentioning it and you havent even tried yet ?

I don't like this......
Sorry, folks.
Just wanted to help the guy.
I read the question, the threas was still going on and I have this example in some tips downloaded earlier.
I apologise to everyone once again.
Hi all,

Epsylon please see your question at:

https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10325449 

nafa2221 please choose the comment you accept carefully if you want the help of our Experts - most only want to be treated fairly for the effort they put in to solving YOUR problems.

hhamster, thank you for understanding how the other Experts feel about having their comments reposted as an answer.

darinw
Customer Service
Thanks to darinw and Barry. hhamster, apologies accepted.