procedure TForm1.Button1Click(Sender: TObject);var
sr: TSearchRec;
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then FileAttrs := FileAttrs + faAnyFile; if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then begin
with StringGrid1 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
Cells[1,RowCount-1] := sr.Name;
Cells[2,RowCount-1] := IntToStr(sr.Size);
end;
while FindNext(sr) = 0 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
RowCount := RowCount + 1;
Cells[1, RowCount-1] := sr.Name; Cells[2, RowCount-1] := IntToStr(sr.Size);
end;
end;
FindClose(sr);
end;
end;
end;
sr: TSearchRec;
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then FileAttrs := FileAttrs + faAnyFile; if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then begin
with StringGrid1 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
Cells[1,RowCount-1] := sr.Name;
Cells[2,RowCount-1] := IntToStr(sr.Size);
end;
while FindNext(sr) = 0 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
RowCount := RowCount + 1;
Cells[1, RowCount-1] := sr.Name; Cells[2, RowCount-1] := IntToStr(sr.Size);
end;
end;
FindClose(sr);
end;
end;
end;
解决方案 »
- 谁能给我我一段tcpserver向tcpsocket发送数据的代码!还有idtcpclient接受idtcpserver的代码呢。。
- 心情好哦,散散分,呵呵~~~~ 顺便请大家帮我抓抓虫子,谢谢啦!
- 问一个关于combobox的问题
- ★★TTS发简体中文语音的难题已经攻克★★
- 在delphi7中如何将菜单设置为xp风格的,谢谢!
- 请问各位公司都在从事些什么,是管理软件,还是什么?
- 50元 寻求简单加壳演示代码(急需要) 走支付宝
- 程序设置为开机自启动后配置文件读不到
- 怎么提供一些DELPHI源代码的网站这么少,请问谁知道有什么好网站吗?
- 救命:dbgrid的小问题?
- 价格分解输出问题
- 如何用delphi实现金山毒霸的那个跑来跑去的画面功能?
还不加解释!!!
够贱,韦小宝都没你贱
FileAttrs 是所要查找的文件的属性,你可以选择只读、隐藏、系统、目录等等属性
重要的在path 参数中,比如你要查找的是*.exe,则应在path中写上,如c:\test\*.exe
调用:if findfirst(path,fileattrs,sr)=0 then
.
.
.
最后,你所要的文件将在sr的属性name中取得
filename:=sr.nameOk!就这么简单
var
Fexe: TSearchRec;
........
while findfirst(path,fileattrs,Fexe)=0 do
...... 要获得每个exe程序的名字,到Fexe.name中去取就是!
findnext(...);