interface
uses Windows, Messages, SysUtils, Classes, Registry, ShellApi;
const
ShellFoldersCount = 10;
ShellFolders: array[0..9] of string
= ('Desktop', 'Favorites', 'Fonts',
'Personal', 'Programs', 'Recent',
'SendTo', 'Start Menu', 'Startup', 'Templates');
function GetShellFolder(ShellFolderID: Integer): string;
function ShellCopy(ha: THandle; f, t: string; fl: Byte):
Boolean;
function ShellMove(ha: THandle; f, t: string; fl: Byte):
Boolean;
function ShellDelete(ha: THandle; f: string; fl: Byte):
Boolean;
implementation
function GetShellFolder(ShellFolderID: Integer): string;
var Reg: TRegistry;
begin
Reg:=TRegistry.Create;
with Reg do
begin
RootKey:=HKEY_CURRENT_USER;
OpenKey('Software\MicroSoft\Windows\CurrentVersion\Explorer\Shell
Folders', False);
result:=ReadString(ShellFolders[ShellFolderID]);
Free;
end;
end;
//bei mehreren Dateien im Format: f:=File1+#0+File2+#0+#0;
//kann auch Ordner bearbeiten (kopieren, verschieben,
löschen)
function ShellCopy(ha: THandle; f, t: string; fl: Byte):
Boolean;
var shellinfo : TSHFILEOPSTRUCT;
begin
with shellinfo do
begin
wnd := ha;
wfunc := FO_COPY;
pFrom := PChar(f);
pTo := PChar(t);
fFlags := fl;
end;
result:=((SHFileOperation(shellInfo)=0) and not shellInfo.fAnyOperationsAborted);
end;
function ShellMove(ha: THandle; f, t: string; fl: Byte):
Boolean;
var shellinfo : TSHFILEOPSTRUCT;
begin
with shellinfo do
begin
wnd := ha;
wfunc := FO_MOVE;
pFrom := PChar(f);
pTo := PChar(t);
fFlags := fl;
end;
result:=((SHFileOperation(shellInfo)=0) and not shellInfo.fAnyOperationsAborted);
end;
function ShellDelete(ha: THandle; f: string; fl: Byte):
Boolean;
var shellinfo : TSHFILEOPSTRUCT ;
begin
with shellinfo do
begin
wnd := ha;
wfunc := FO_DELETE;
pFrom := PChar(f);
pTo := nil;
fFlags := fl;
end;
result:=((SHFileOperation(shellInfo)=0) and not shellInfo.fAnyOperationsAborted);
end;