ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
ShellBrowser.TShellBrowser.RenameObject

Use RenameObject to rename the current object.

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

HResult: NO_ERROR in case the rename succeeded, an OLE Errror code if the rename failed.

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;