Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,
I have one application call FullScreenDisplay of AppWizard type.
In OnCreate() of mainfrm.cpp i written code that hide the Task bar and start menu.
so only application desktop can saw.

If i create application that hide the Task bar and start menu.but not shows the Application window that is a application that only hide the Task bar and start menu.

i was successful in this by writting code for same in OnCreate() of mainfrm.cpp and returning 0

now i want to delete executable after running what i can do?

that in simple a person that run that exe will hide the Task bar and start menu.
And same time .exe also deleted.

All Related information are most WELCOME.

EDIT:-

Can any body tell me what wrong with deleting running executable. After that lots of discussion.
Posted
Updated 15-Mar-11 17:28pm
v2

As far as I know it is not possible to delete the executable file from which your code is running because the file is locked by the operating system after being loaded.

And why would you need such a strange thing??
 
Share this answer
 
Comments
[no name] 15-Mar-11 7:40am    
Not strange thing its part of my application.will execute only when any undesire user access my system
next he/she doesnt even not get my .exe

please any suggestion are welcome from you.
Olivier Levrey 15-Mar-11 8:29am    
I told you it is not possible. If you try to delete the file, you will have an "access denied" error.
Sergey Alexandrovich Kryukov 15-Mar-11 15:34pm    
Olivier,

Yes, this is possible, but I'm sure you're well aware of that. You probably did not want to consider the opportunity, because such solution is too dirty, should be discouraged.

Anyway, I decided to answer, let OP breaking the head, not mine...
Please see.

--SA
Olivier Levrey 15-Mar-11 15:57pm    
No I didn't know it was and I answered honestly.
Sergey Alexandrovich Kryukov 15-Mar-11 17:37pm    
You did anyway.
Good to know :-) Thank you.
--SA
More exactly, you can delete it in the following way:

1) Locate the process holding the file and obtain its handle in your process's address space.

2) Using the process handle, call TerminateProcess, see http://msdn.microsoft.com/en-us/library/ms686714(v=vs.85).aspx[^].

3) Delete the file.

Doing of all this is highly discouraged; you don't want to take the risk of destabilizing your system.
I suggest you only do it for research purpose.

What is the purpose of your Question? I'm sure there is a better resolution, if you explain your ultimate goals.

—SA
 
Share this answer
 
v4
Comments
Espen Harlinn 15-Mar-11 15:52pm    
My 5 - one possible use of hiding the taskbar and start menu, is to display your own.

If I was writing an application that hijacked the users desktop - I would proably like to hide my tracks too, by deleting the executable, and delete any other trace of it's existence, before it terminated. I expect this is not OPs intention, but it's an obvious possible use :)
Sergey Alexandrovich Kryukov 15-Mar-11 15:55pm    
Thank you, Espen.
Unfortunately, we're discussing stuff which is all too dirty for development and not tricky enough for hijacking...
--SA
Espen Harlinn 15-Mar-11 16:33pm    
If I could, I'd 5ed that reply - but it is actually posible to delete the executable of a running process, but it has to be created with this in mind ...
Olivier Levrey 15-Mar-11 15:58pm    
I don't know if it is good to know but I learned something! :) My 5.
Sergey Alexandrovich Kryukov 15-Mar-11 16:50pm    
It's always good to know, even if it is from the "Don't repeat at home!" series. :-)
Thank you, Olivier.
--SA
I can't remember the name of the API/registry key, but I know that you can tell Windows to automatically delete specified files on boot.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Mar-11 17:40pm    
That is true, something used in installers. Sysinternals should help I guess. My 5 for the note.
--SA
Just a note of caution.

If you ever succeed in achieving your aims, you need to be aware of the law in the markets you are aiming at. In the UK a program that deletes itself could well be considered illegal, since it modifies the users system. I realize that many programs modify systems (saving settings etc.) and I cannot be bothered to look up the correct wording, but believe me it is illegal.
 
Share this answer
 
Comments
Espen Harlinn 15-Mar-11 17:31pm    
I believe you - a 5 since I can't give you a 100 - but that's definitely something to be aware of.
Sergey Alexandrovich Kryukov 15-Mar-11 17:40pm    
My 5, however the fact of illegal program of the sort is quite weird. How about the program which install itself -- also "modifies the users system"? Sounds ridiculous.
--SA
Henry Minute 15-Mar-11 17:49pm    
Yep does sound odd and as I said I can't be bothered to dig out the exact wording but it is aimed at viruses, trojans etc. that might delete applications and data. However, because of the way it is worded it also applies to a program that deletes itself without explicit permission at the time of deletion.
Sergey Alexandrovich Kryukov 15-Mar-11 17:57pm    
Thank you for those notes.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900