Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to simply make a program in Delphi that you can not close
11-25-2009, 07:49 AM
Post: #1
How to simply make a program in Delphi that you can not close
So this is tut on how to make a program that you can not close using standard methods (except restart). I remember when XIO-X2 was showing me this kind of tricks few years ago. This tutorial can be considered as Virus making tutorial, but this is only for teaching purposes and you can use this as a joke. This tut is for programmers that know basics of Delphi, because i didn't explain every single fact. I used Delphi 7 for this.
So this program will make whole screen black and mouse invisible, Alt+F4 would not work and Ctrl+Alt+Del would not work also, so restart is going to be main. First of all you need to open Delphi and then we need to set full screen.
So go to Object Inspector and set this parameters :
Code:
WindowState:=wsMaximized;
FormStyle:=fsStayOnTop;
BorderStyle:=bsNone;
Color:=clBlack;
You can even copy this into "Form Create" part, just do double click on form.
And to disable Mouse we will use this code and input that in "Form Create" :
Code:
ShowCursor(False);
So everything in "Form Create" should look like this :
Code:
procedure TForm1.FormCreate(Sender: TObject);
begin
  WindowState:=wsMaximized;
  FormStyle:=fsStayOnTop;
  BorderStyle:=bsNone;
  Color:=clBlack;
  ShowCursor(False);
end;
Now you can test this, whole screen will be black and Alf+F4 will work also Ctrl+Alt+Del so don't worry to run this.
Okay now we need to disable Alt+F4, or to prevent program from closing. Since whole program has only this Form and that Form is main, we need to prevent that Form from closing. Now go to Object Inspector of Form1 and click Events, there you should find "OnClose", so just double click on it and you should get part where you need to put your code.
You should type there next thing :
Code:
Action:=caNone;
So with everything, this part should look like this :
Code:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caNone;
end;
Now you can run this program, but you need to close it by using Task Manager, so Ctrl+Alt+Del and kill process.
Now after this part we need to make Ctrl+Alt+Del disable, but we will make an exit from program to prevent that Virus making it's job on us LOL. We really don't want to infect us with our own virus.
Go to Form1 Object Inspector and find Events and "OnKeyDown" and paste this code there :
Code:
if key=vk_f1 then
    Application.Terminate;
So if you press F1 key application will terminate. Everything in "OnKeyDown" part of the code should look like this :
Code:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if key=vk_f1 then
    Application.Terminate;
end;
After preventing this virus from infecting us, we will disable Ctrl+Alt+Del. Basically keys pressed all together Ctrl+Alt+Del will run Task Manager (taskmgr.exe) and we will make a batch file that closes Task Manager or just kills process. Paste this and save as "kill.bat" :
Code:
taskkill /im taskmgr.exe /f
So this "taskkill" means that it kills process "/im" means image name, or process name and "/f" means that it will forcefully kill that process.
Now if we run that batch file every second it will kill "taskmgr.exe" every second and nobody can do anything in that little time.
First we need to make the code that runs this batch. Go to Standard Palette and drag on form "ActionList". When you drag it double click on it and go to "New Standard Action", you can see that on the picture :

[Image: 20695_standardactionsdelphi1.jpg]

After that you need to register class "TFileRun" as you can see on the picture :

[Image: 20696_standardactionsdelphi2.jpg]

Now in the Object Tree View that is above Object Inspector by Default you can see "FileRun1". Now click on it to get it in the Object Inspector and in the file name specify "kill.bat". Now go to ShowCmd in Object Inspector and choose scHide. That should look like this :

[Image: 20709_objectinspectordelphi.jpg]

Now as we said we need to make it to run every second. Go to System Palette and drag Timer on to form. After that we need to write a code for running and that is "FileRun1" execution or :
Code:
FileRun1.Execute;
So with Timer code that is this :
Code:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  FileRun1.Execute;
end;
We are finished. Now you can run your program. If you have done everything okay that should work. Remember to press F1 to close the program. If you want Enter to close your program, except "vk_f1" use "vk_return". After you save this you should get this files :

[Image: 20714_projfiles.jpg]

You have my code inside of attachment if you don't want to type your one. In my code F1 closes the program.
Hope that you like this tut, as i said this is for teaching purposes, you can use it as a joke. You can change the code by your own and add something written on the Form and paste it on StartUp, so it will run if computer runs.
But that is dangerous if you don't make escape key (in my case F1), then only entrance is running Safe Mode of Windows.
Enjoy !


Attached File(s)
.rar  source.rar (Size: 163.64 KB / Downloads: 1)

"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein
Visit this user's website Find all posts by this user
Quote this message in a reply
11-25-2009, 08:53 AM
Post: #2
RE: How to simply make a program in Delphi that you can not close
i think you showed me things like this before.
i think i forgot all i knew in delphi.

[Image: 45669_pythonlogo.png][Image: 45668_javalogo.png]
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: