Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there an API call to rename a folder
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00178253
Message ID:
00178449
Views:
25
>Hi Juan:
>
>>I know this question may have probably come up before. Is there an API call that would allow me to rename a folder?
>
>I do this for files and folders:
>
>declare MoveFileA in kernel32 as foxmove string, string, int
>* and later in the code...
>=foxmove(oldname, newname)
>
>(If anyone can point out how I should do this better/more carefully, please do -- I'm a dufus with the API)
>
Hi Kevin,

The correct syntax for the declaration should be:
DECLARE SHORT MoveFile IN Win32API AS FoxMove;
  STRING @lpExistingFileName, STRING @lpNewFileName
llresult = (FoxMove(@oldname, @newname) # 0)
The return value should preceed the function name. I use SHORTs to indicate that the return value is actually a boolean value.

The actual library name has been replaced by "Win32API". VFP will automatically search certain dlls to find the function. The listing of these can be found in the help file.

The Windows SDK indicates that the strings are to be passed by reference (the lp prefix designation of the parameters). While passing them by value will work, I've found it a good habit to follow the SDK as closely as possible. This is a necessity when passing buffers that the function filles, such as GetPrivateProfileString(). I've also included the indication of what the parameters mean. This helps makes the code self-documenting.

Finally, while it's perfectly OK to give the function an alias, it's only required when the function name conflicts with an exsisting VFP function. Two examples of this that come immediately to mind would be MESSAGEBOX() and GETOBJECT(). In both cases, functions in the API exist, and if you were to declare them, you would have to give them an alias. Syntax coloring really helps in this regard.

hth,
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform