The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Telefunken on July 13, 2006, 10:07:02 PM

Title: Folder Management
Post by: Telefunken on July 13, 2006, 10:07:02 PM
I'm basically a n00b as MASM so be patient.

I'm writing in MASM and i need to know how to rename a folder in my program.
So like, the user presses a button and it renames a folder.
I'm guessing theres an easy function or something but i don't know.
I already have most of the coding done except for that one function.

Any help is appreciated
Title: Re: Folder Management
Post by: Tedd on July 14, 2006, 12:55:02 PM
use MoveFileEx
(folders are really just files.)
Title: Re: Folder Management
Post by: Telefunken on July 14, 2006, 01:25:19 PM
Thanks. I'll try it out asap.  :U
Title: Re: Folder Management
Post by: Casper on July 14, 2006, 03:13:13 PM
You can get a handle to the directory you wish to delete/rename or move by using CreatFile


    invoke CreateFile, DirName, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL


MoveFileEx does not require this but if you wish to do any directory operations on files within the directory it is handy to know how.

One thing you need to be mindful of is renaming a folder can effect the shell and make it unstable in certain circumstances.  If you are unsure of the effect, ALWAYS notify the shell that you renamed a folder by using the WINSHELLAPI using the SHCNE_RENAMEFOLDER wEventID with the SHCNF_FLUSH and SHCNF_PATH flags.  If the renamed folder is part of an environment variable or is set in any of the ini files, the shell will fix everything for you if you make this call.  Since you are letting the user pick the folder to be renamed, this call is mandatory as you cannot safely make a prediction.  It is important to cover all bases so the shell does not crash and burn.

Paul

Title: Re: Folder Management
Post by: Telefunken on July 16, 2006, 07:52:20 AM
Thanks Paul, I'll keep that in mind  :toothy