哈哈,刚编完!
procedure TForm1.Button1Click(Sender: TObject);
var P:PChar;
var FileOP:TSHFILEOPSTRUCT;
begin
GetMem(P,200);
SHGetSpecialFolderPath(0,p,CSIDL_COMMON_FAVORITES,False);
ShowMessage(Strpas(P));
FileOp.wnd:=Handle;
FileOp.wFunc:=FO_Delete;
FileOp.pFrom:=p;
FileOp.fFlags:=FOF_ALLOWUNDO;
//这个参数参考MSDN
FileOp.hNameMappings:=nil;
FileOp.lpszProgressTitle:=nil;
SHFileOperation(FileOp);
end;
procedure TForm1.Button1Click(Sender: TObject);
var P:PChar;
var FileOP:TSHFILEOPSTRUCT;
begin
GetMem(P,200);
SHGetSpecialFolderPath(0,p,CSIDL_COMMON_FAVORITES,False);
ShowMessage(Strpas(P));
FileOp.wnd:=Handle;
FileOp.wFunc:=FO_Delete;
FileOp.pFrom:=p;
FileOp.fFlags:=FOF_ALLOWUNDO;
//这个参数参考MSDN
FileOp.hNameMappings:=nil;
FileOp.lpszProgressTitle:=nil;
SHFileOperation(FileOp);
end;
解决方案 »
- 很棘手的问题,请高手指教
- 简单问题
- 由于我不小心忘了,日期-日期=天数,我需要天数为整型,请问如何解决
- 毕业设计上的一个函数,急,help
- @@@@@@@@@@在DELPHI中如何调用拨号,本地数据如何通过拨号向远端服务库中更新数据@@@@@@@@@
- 应收帐冲销问题,请进。当天结贴
- 如何才能用DElhpi编程调用另外一个程序中,并且控制被调用的程序完成某个功能??
- Word中文件菜单下在退出Exit上方列出了您设置的数量的最近的打开的文件的名称,我想问问这些信息在系统的什么地方?
- 控件DBNavigator的问题?
- 请教高手:如何关闭一个窗口或隐藏一个窗口,另外谁能给我一个关于数据库开发的小程序,不胜感激!
- WinAPI问题:如何修改一个已有的HBITMAP的Width和Height?
- 在DELPHI程序中如何下载指定的图片?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Wininet, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
function FindNextEntrys(Handle:Integer):Boolean;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
function TForm1.FindNextEntrys(Handle:Integer):Boolean;
var
T: PInternetCacheEntryInfo;
D: DWORD;
begin
D := 0;
FindnextUrlCacheEntryEx(Handle, nil, @D, nil, nil, nil);
GetMem(T, D);
try
if FindNextUrlCacheEntryEx(Handle, T, @D, nil, nil, nil) then begin
ListBox1.Items.Add(T.lpszSourceUrlName);
ListBox2.Items.Add(T.lpszLocalFileName);
Result := True;
end
else
Result := False;
finally
FreeMem(T, D)
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
H:Integer;
T: PInternetCacheEntryInfo;
D: DWORD;
begin
D := 0;
FindFirstUrlCacheEntryEx(nil, 0, NORMAL_CACHE_ENTRY, 0,nil,@D, nil, nil, nil);
GetMem(T, D);
try
H := FindFirstUrlCacheEntryEx(nil,0, NORMAL_CACHE_ENTRY, 0, T, @D, nil, nil, nil);
if (H = 0) then
else begin
repeat
until not FindNextEntrys(H);
FindCloseUrlCache(H);
end
finally
FreeMem(T, D)
end;
end;procedure TForm1.Button2Click(Sender: TObject);
var
URL:String;
begin
If ListBox1.ItemIndex >=0 then begin
URL:=ListBox1.Items.Strings[ListBox1.ItemIndex];
Self.Caption := URL;
if DeleteUrlCacheEntry(PChar(URL))then
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
end;end. 运行程序,点击Button1,就可以分别在ListBox1中列出所有在Cache中的文件所对应的URL以及在ListBox2中列出相应的文件名。在ListBox1中选择一个列表,然后点击 Button2 就可以将该项从Cache中删除。
SHFileOperation(FileOp);不信你自己试试哟!?高手你自己没有调试过嘛?!!
就丢上来,还不如在注册表中找到需要的目录,在进行处理起来比较简单哟……
下面刚调试过。
uses Shlobj,Shellapi;
procedure TForm1.Button1Click(Sender: TObject);
var P:PChar;
var Str:String;
var P1:Pchar;
var FileOP:TSHFILEOPSTRUCT;
begin
GetMem(P,200);
SHGetSpecialFolderPath(0,p,CSIDL_COMMON_FAVORITES,False);
Str:=StrPas(p)+'\*.*';
ShowMessage(Str);
GetMem(p1,200);
StrpCopy(p1,str);
ShowMessage(StrPas(p1));
// ShowMessage(Strpas(P));
FileOp.wnd:=0;
FileOp.wFunc:=FO_Delete;
FileOp.pFrom:=p1;
FileOp.pTo:=nil;
FileOp.fFlags:=FOF_ALLOWUNDO;
//这个参数参考MSDN
FileOp.hNameMappings:=nil;
FileOp.lpszProgressTitle:=nil;
FileOp.fAnyOperationsAborted:=True;
FileOp.lpszProgressTitle:=nil;
SHFileOperation(FileOp);end;