News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DeleteFile

Started by Warmt, February 23, 2008, 05:29:12 PM

Previous topic - Next topic

Warmt

Hi folks,

In my (masm32) project, I make a call (in the WM_CREATE message) to a proc which drops a file (ReadMe.txt)
into the system directory of the user (x:\WINDOWS\system32). Doesn't matter on which partition
(A: B: C: D: [or whatever]) the \WINDOWS\system32 directory is. The file gets dropped there.

When the user closes/terminates the program, I want to make a call (which would then happen in
the WM_DESTROY message). The call to this proc has to delete the previously created ReadMe.txt file,
because I don't want that it stays there forever.

My question now is:
How EXACTLY does this proc, which deletes the file, has to look like?
As you can see I am not very good in masm, but thats why there are forums, right? ;)
So I would be greatful if someone has/makes a complete proc for me.
I know that 'Invoke DeleteFile' can delete files, but how can it be used when the
system32 dir could be on any partition/etc? And since I'd need the 'lpFileName' to delete it, how
do I define the correct path to the ReadMe.txt?

ToutEnMasm

Hello,
i don't understand very well your language,but when I see
Quote
How EXACTLY does this proc, which deletes the file, has to look like?
I can say you only one thing,WINHELP is the answer,it's the god of asm.

BogdanOntanu

Warmt,

1) Please explain me WHY do you want to "drop a file" in the user's system folder?

This kind of action is not very nice and might be picked up by anti virus software as being offending to the user's system.

2)This forum is nice but it is not here for us to write code for you. Esp. code that you can later on use for debatable purposes.

Instead we like to guide you into your own efforts for understanding until you become capable to write and debug your own code.

One such  guidance is to kindly advise you against debatable coding practices.
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

donkey

You should never use a hard coded folder for the system directory, instead call GetSystemDirectory to find it as a user can name the Windows folder anything they like at install time.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Warmt

BogdanOntanu:

1) As I've said it's a ReadMe.txt. So it's a textfile giving the user instructions of how to use the program,
inluding support/etc. I think you get the idea.
I've only picked the system32 directory randomly. When the program is finished, I'll probably let it get
dropped into the TEMP directory.
Yes, I know most ReadMe's are simply seperately included with the programs .exe and I know I could
also easily create it in the runtime directory.

2) Sorry, didn't knew that. Well, I'm grateful for any useful help/advice of course. No need to entirely
code the stuff for me.
However, advices like:
QuoteI can say you only one thing,WINHELP is the answer,it's the god of asm.
are pretty useless for me, seeing that neither the author of this post, nor WINHELP, does exactly answer my question.

Draakie

Is it just me or is something really wrong with this post......

[Firstly Warmt - You posted...]

In my (masm32) project, I make a call (in the WM_CREATE message) to a proc which drops a file (ReadMe.txt)
into the system directory of the user (x:\WINDOWS\system32). Doesn't matter on which partition
(A: B: C: D: [or whatever]) the \WINDOWS\system32 directory is


[Then Warmt - Your Question goes on to say...]

I know that 'Invoke DeleteFile' can delete files, but how can it be used when the
system32 dir could be on any partition/etc? And since I'd need the 'lpFileName' to delete it, how
do I define the correct path to the ReadMe.txt?


The answer to your question is obvious - your motives are'nt - I'am with BogdanOntanu on this one......
Does'nt it stand to reason if you create the file with path - you would know the path ?
Does this code make me look bloated ? (wink)

Sorex

Why not install or drop it in the folder where the program is located?

if the user has limited rights and folder rights are set incorrect you won't be even able to drop it in "program files" or the systemroot