News:

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

Folder Management

Started by Telefunken, July 13, 2006, 10:07:02 PM

Previous topic - Next topic

Telefunken

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

Tedd

use MoveFileEx
(folders are really just files.)
No snowflake in an avalanche feels responsible.

Telefunken

Thanks. I'll try it out asap.  :U

Casper

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


Telefunken

Thanks Paul, I'll keep that in mind  :toothy