The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hfheatherfox07 on July 14, 2011, 11:24:56 PM

Title: INVOKE DeleteFolder
Post by: hfheatherfox07 on July 14, 2011, 11:24:56 PM
Hi, I was wondering if anybody ever used the "INVOKE DeleteFolder" and has an example ... NOT the same as "INVOKE DeleteFile"

I can not understand how to write a proc for it....

Also here is an example that I made of "INVOKE DeleteFile" ...what I was trying to do is delete all the files "Recent" folder....

The files in there are .lnk so if you have short cut file called "test.asm" it is really  "test.asm.lnk" ....My example works fine if I actually do one folder at a time and name it each time....
Why does \*.lnk  Work?

Is there a way to do it this way with out an open file name were I have to chose the files ?

Thank You!

Title: Re: INVOKE DeleteFolder
Post by: Tedd on July 15, 2011, 12:29:58 PM
SHFileOperation should do what you want.

http://msdn.microsoft.com/en-us/library/bb762164%28v=VS.85%29.aspx
Title: Re: INVOKE DeleteFolder
Post by: hfheatherfox07 on July 16, 2011, 02:19:06 AM
Quote from: Tedd on July 15, 2011, 12:29:58 PM
SHFileOperation should do what you want.

http://msdn.microsoft.com/en-us/library/bb762164%28v=VS.85%29.aspx


Thank you ,
I found an example right here on the forum , now that I know to look for SHFileOperation

http://www.masm32.com/board/index.php?PHPSESSID=45161102b7e9b36e503418a4d40f36ce&action=printpage;topic=10083.0

I will try it Tonight
Title: Re: INVOKE DeleteFolder
Post by: Vortex on July 16, 2011, 07:33:36 AM
Hi hfheatherfox07,

The SHAddToRecentDocs function can be used to clear the recent documents list.


.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\shell32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\shell32.lib

.code

start:

    invoke  SHAddToRecentDocs,SHARD_PATH,NULL
    invoke  ExitProcess,0

END start
Title: Re: INVOKE DeleteFolder
Post by: hfheatherfox07 on July 16, 2011, 05:45:50 PM
Thank you Vortex, I was not aware of "SHARD_PATH" ... I was going about it the long way by first getting the user name ....

:U
Title: Re: INVOKE DeleteFolder
Post by: hfheatherfox07 on July 17, 2011, 03:18:57 PM
Quote from: Vortex on July 16, 2011, 07:33:36 AM
Hi hfheatherfox07,

The SHAddToRecentDocs function can be used to clear the recent documents list.


.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\shell32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\shell32.lib

.code

start:

    invoke  SHAddToRecentDocs,SHARD_PATH,NULL
    invoke  ExitProcess,0

END start


Sorry vortex that did not work for me; it deletes the whole Recent folder ...but when you look for hidden folders it seemed only to make the entire folder's attribute "hidden"
and the whole folder and it's contents are still there just with hidden attributes...weird ....
Here is something that I came up with thanks to another code that I have seen on this forum... I used parts to make my original example work ...
Title: Re: INVOKE DeleteFolder
Post by: -Alex- on July 17, 2011, 04:29:05 PM
If u want just to delete a folder, here is my code:

include masm32rt.inc

.data
fileop SHFILEOPSTRUCT<>
Dir db "C:\Users\Alex\AppData\Local\Temp",0

.code
start:
mov fileop.wFunc,FO_DELETE
mov fileop.pFrom,offset Dir
mov fileop.fFlags,FOF_NOCONFIRMATION
invoke SHFileOperation,addr fileop
invoke ExitProcess,0
end start


It will delete the whole folder, and ofcourse all subfolders and files, will not ask u, if u r really sure, and it will display an error, if something gone wrong.
Title: Re: INVOKE DeleteFolder
Post by: hfheatherfox07 on July 17, 2011, 04:31:26 PM
Thank You