unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, CoolTrayIcon, WinSkinData, ComCtrls, StdCtrls, Menus,StrUtils,shellapi;
type
TForm1 = class(TForm)
ListView1: TListView;
SkinData1: TSkinData;
CoolTrayIcon1: TCoolTrayIcon;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
ListView2: TListView;
PopupMenu2: TPopupMenu;
N3: TMenuItem;
N4: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure ListView2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure CoolTrayIcon1Click(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure ListView1Click(Sender: TObject);
procedure ListView1DblClick(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
procedure wmsyscommend(var msg:twmsyscommand);message wm_syscommand;
public
{ Public declarations }
procedure DoSearchPathFile(qPath:string);
end;
var
Form1: TForm1;
kg:boolean;
implementation
{$R *.dfm}
procedure tform1.wmsyscommend(var msg:twmsyscommand);
begin
if(msg.cmdtype=sc_minimize) or (msg.cmdtype=sc_restore) then begin
form1.Hide;
msg.result:=0;
end else
inherited;
end;
function toaandb(str_s:string):string;
var
i,j,scount:integer;
strab:string;
begin
{for i:=1 to apos do
begin
j:=pos(',',str_s);
scount:=length(str_s);
if j=0 then
begin
strab:=str_s;
end else
begin
strab:=leftstr(str_s,j-1);
end;
str_s:=RightStr(str_s,scount-j);
end;
result:=strab; }
While pos('/',str_s)>0 do begin
j:=pos('/',str_s);
scount:=length(str_s);
str_s:= RightStr(str_s,scount-j);
//showmessage(str_s);
end;
strab:=str_s;
result:=strab;
end;
procedure TForm1.DoSearchPathFile(qPath: string);
var
SR: TSearchRec;
FileAttr: Integer;
item:tlistitem;
begin
FileAttr := faDirectory;
FindFirst(qPath + '/*.*', FileAttr, SR);
While FindNext(SR) = 0 do
begin
if (SR.Name <> '.') and (SR.Name <> '..') then begin
if DirectoryExists(qPath + '/' + SR.Name) then
begin
// ListBox1.Items.Add('路径'+ qPath + '/' + SR.Name);
DoSearchPathFile(qPath + '/' + SR.Name);
end;
//;else ListBox1.Items.Add(qPath + '/' + SR.Name);
end;
end;
FileAttr := faAnyFile;
FindFirst(qPath + '/*.*', FileAttr, SR);
while FindNext(SR) = 0 do
begin
if (SR.Name <> '.') and (Sr.Name <> '..') then
begin
if not(DirectoryExists(qPath + '/' + SR.Name)) then begin
if (pos('exe',SR.Name)>0) or (pos('rar',SR.Name)>0) or (pos('zip',SR.Name)>0) then begin
// ListBox1.Items.Add(SR.Name);
item:=listview1.Items.Add;
item.Caption:=toaandb(qpath);
item.SubItems.Add(SR.Name);
item.SubItems.Add(qpath);
end;
end;
end;
end;
end;
procedure DoSearchPathFilea(qPath: string);
var
SR: TSearchRec;
FileAttr: Integer;
item:tlistitem;
begin
FileAttr := faDirectory;
FindFirst(qPath + '/*.*', FileAttr, SR);
While FindNext(SR) = 0 do
begin
if (SR.Name <> '.') and (SR.Name <> '..') then begin
if DirectoryExists(qPath + '/' + SR.Name) then
begin
item:=form1.listview2.items.add;
item.Caption:=sr.Name;
item.SubItems.Add(qPath + '/' + SR.Name);
// form1.ListBox1.Items.Add(qPath + '/' + SR.Name);
// DoSearchPathFilea(qPath + '/' + SR.Name);
end;
//;else ListBox1.Items.Add(qPath + '/' + SR.Name);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(toaandb('C:/Documents and Settings/Administrator/桌面/新工具集'));
//ListBox1.Items.Add(inttostr(pos('r','Project1.exe')));
end;
procedure TForm1.FormCreate(Sender: TObject);
var
apath:string;
begin
apath:=extractfiledir(paramstr(0));
DoSearchPathFilea(apath);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
//listview1.Clear;
//DoSearchPathFile(listbox1.Items[listbox1.itemindex]);
end;
procedure TForm1.ListView2Click(Sender: TObject);
begin
listview1.Clear;
try
DoSearchPathFile(listview2.Items[listview2.itemindex].SubItems[0]);
except
end;
end;
procedure TForm1.N4Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.CoolTrayIcon1Click(Sender: TObject);
begin
if kg=true then
form1.Hide
else
form1.Show;
end;
procedure TForm1.FormHide(Sender: TObject);
begin
kg:=false;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
kg:=true;
end;
procedure TForm1.N3Click(Sender: TObject);
begin
form1.Show;
end;
procedure TForm1.ListView1Click(Sender: TObject);
var
str_filepath:string;
begin
//str_filepath:=listview1.Items[listview1.Itemindex].SubItems[1]+'/'+
//listview1.Items[listview1.Itemindex].SubItems[0];
// WinExec(pchar(str_filepath),SW_SHOW);
end;
procedure TForm1.ListView1DblClick(Sender: TObject);
var
str_filepath:string;
begin
try
str_filepath:=listview1.Items[listview1.Itemindex].SubItems[1]+'/'+
listview1.Items[listview1.Itemindex].SubItems[0];
WinExec(pchar(str_filepath),SW_SHOW);
except
end;
end;
procedure TForm1.N2Click(Sender: TObject);
var
str_filepath:string;
begin
try
str_filepath:=listview1.Items[listview1.Itemindex].SubItems[1];
//listview1.Items[listview1.Itemindex].SubItems[0];
ShellExecute(0,'open',pchar(str_filepath),0,0,SW_SHOW);
except
end;
end;
procedure TForm1.N1Click(Sender: TObject);
var
str_filepath:string;
begin
try
str_filepath:=listview1.Items[listview1.Itemindex].SubItems[1]+'/'+
listview1.Items[listview1.Itemindex].SubItems[0];
ShellExecute(0,'open',pchar(str_filepath),0,0,SW_SHOW);
except
end;
end;
end.