---
Run-time error '75':
Path/File access error
---
Which file did your friend delete?
There are methods using which an EXE can delete itself but its not as
straight-forward as using DeleteFile(). One of the methods involves using a
batch file that deletes the running exe file. You may want to generate this
batch file in code:
deleteme.bat
---
:deleteit
del "<your exe file name with full path here>"
if exist "<your exe file name with full path here>" goto deleteit
del deleteme.bat
---
Some points to note here:
1. This batch file deletes itself after deleting the exe.
2. Make sure not to leave any line after the "del deleteme.bat" line.
You may want to create this batch file in some temporary folder.
ShellExecute() this batch file with SW_HIDE as the show parameter.
I hope this helps.
- Chirag
http://chiragdalal.tripod.com/
TAnimationFX - Perform animation effects on images
http://chiragdalal.tripod.com/animfx.html
Stanimir <sa_ml...@dir.bg> wrote in message news:3bfe126a$1_2@dnews...
from Krasimir Stoyanov found in this groups.
[\Quote]
I converted this to Delphi and can confirm it works on Win95, Win NT 4.0 and Windows
2000: The poster tested it on Windows 98, so remainsWindows XP, anyone?
procedure DeleteSelf;
var hModule:THandle;
szModuleName:array[0..MAX_PATH] of char;
hKrnl32 : THandle;
pExitProcess, pDeleteFile, pFreeLibrary,pUnmapViewOfFile : pointer;
ExitCode:UINT;
begin
hModule:= GetModuleHandle(nil);
GetModuleFileName(hModule, szModuleName, sizeof(szModuleName));
hKrnl32 := GetModuleHandle ( 'kernel32' );
pExitProcess := GetProcAddress ( hKrnl32, 'ExitProcess' );
pDeleteFile := GetProcAddress ( hKrnl32, 'DeleteFileA' );
pFreeLibrary := GetProcAddress ( hKrnl32, 'FreeLibrary' );
pUnmapViewOfFile := GetProcAddress ( hKrnl32, 'UnmapViewOfFile' );
ExitCode := system.ExitCode;
if($80000000 and GetVersion())<>0 then
// Win95, 98, Me
asm
lea eax, szModuleName
push ExitCode
push 0
push eax
push pExitProcess
push hModule
push pDeleteFile
push pFreeLibrary
ret
end
else
begin
CloseHandle(THANDLE(4));
asm
lea eax, szModuleName
push ExitCode
push 0
push eax
push pExitProcess
push hModule
push pDeleteFile
push pUnmapViewOfFile
ret
end
end
end;
[Quote/]
As far as I know it doesn't work on XP.
Regards
Johnnie.
regards
Johnnie.
"Chirag Dalal" <dalal....@iname.com> wrote:
>Is that true!? I tried it in VB6 and it failed with
>
>---
>Run-time error '75':
>
>Path/File access error
>---
>
>Which file did your friend delete?
>
Yes, it is true.
Here is his code on VB3.
In Main form just run this code:
Unload Me
Kill app.Path + "\" + app.EXEName + ".EXE"
Tested on Windows 98!!!
Thanks about the idia for Batch file.
Thank you for your kind words but I'm not to be thanked here.
You must thank Krasimir Stoyanov and a number of other
developers (that I do not recall at the moment ) that have
spend a significant amount of time to produce this procedure.
Regards
Johnnie.
ganesh
A console program runs before Windows loads any lib, check if it is a
wininit.ini and process the script in it. Then, deletes the old.dll in the
example and renames new.bak to new.dll. At the and, renames the wininit.ini
to wininit.bak.
When this happens, windows shows a text message like this :
Updating System Config. This take a few time . . .
Refer to Installation Section of SDK and look at that files in your win
directories.
Ömür Ölmez
It's amazing the recent advances in AI! Here we have an AI good
enough to ask a reasonable question and what does it want to do but
commit suicide?!
What you can do is add an entry to
HkLM\Software\Microsoft\Windows\CurrentVersion\RunOnce (in the registry) to
run a delete command once window stars up.
Other than that you could have a monitor process checking to see if your app
is running and as soon as it stops, delete it.
--
Dan
Paolo Gelato wrote in message <3c07472a$2_2@dnews>...