News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

A question on RemoveDirectory

Started by clamicun, May 19, 2015, 07:44:35 PM

Previous topic - Next topic

clamicun

We all know that the  MS-DOS command  "rd [dirname]"  doesn't work on notempty directories.
Same with the API function "RemoveDirectory".

But MS-DOS  "rd /s/q [dirname]"  does it.

I checked for an API function which does it too. Can't find one.
Is there a possibility to remove a notempty directory without deleting the files before?

I can do it this way...

"
fOpen   TCHAR 'open',0
fDatei   TCHAR 'deldir.bat',0
INVOKE ShellExecute,NULL,offset fOpen,offset fDatei,NULL,NULL,SW_SHOWNORMAL
"

Does the job, but it is not very satisfying.

hutch--

You would normally remove (delete) the contents of the directory first.

Vortex

Hello clamicun,

Here is an example :

include     \masm32\include\masm32rt.inc

.data

directory   db 'test',0

.data?

shfs        SHFILEOPSTRUCT <?>

.code

start:

    mov     edx,OFFSET shfs

    mov     SHFILEOPSTRUCT.hwnd[edx],0
    mov     SHFILEOPSTRUCT.wFunc[edx],FO_DELETE
    mov     SHFILEOPSTRUCT.pFrom[edx],OFFSET directory
    mov     SHFILEOPSTRUCT.pTo[edx],0
    mov     SHFILEOPSTRUCT.fFlags[edx],FOF_NOCONFIRMATION or FOF_SILENT

    invoke  SHFileOperation,ADDR shfs

    invoke  ExitProcess,0

END start

clamicun

vortex,
yes - it works fine. Combine this with "Browse4Folder" and you have a very dangerous tool.

dedndave

i think the FOF_ALLOWUNDO flag will send it to the recycle bin, if desired