ShellBrowser Delphi Edition Documentation
ContentsIndexHome
PreviousUpNext
TShellBrowser.RenameObject Method

Use RenameObject to rename the current object.

Syntax
Pascal
function RenameObject(var NewName: UnicodeString): Boolean;
Parameters 
Description 
var NewName: UnicodeString 
the new name that should be set for the current object. 

The actual name of the current object after the attempt to rename it. It may happen that Windows does not allow the rename, then the old name will be returned. Otherwise the new name should be returned.

When you call RenameObject with a new name, the ShellBrowser tries to rename the current object. It may happen, that the windows shell doesn't allow the renaming. After calling RenameObject, you find the name the current object finally got in the variable NewName and the return value indicates if renaming was successful.

Let's say you have your files listed in a ListView, which property ReadOnly is false. The user can rename the objects in the ListView and you can use the Event OnEdited of the ListView to handle the renaming:

procedure TMainForm.ListViewEdited(Sender: TObject; Item: TListItem; var S: String); var newName: WideString; begin ShellBrowser.ObjectName := Item.Caption;//the complete path must be in the caption newName := ExtractFileName(S);//ExtractFileName is contained in SysUtils ShellBrowser.RenameObject(newName); end;
Copyright (c) 2011. All rights reserved.