function EnumProc(h:HWND;i:integer):boolean;stdcall;
var
buf:array[0..255] of char;
begin
 GetWindowText(h,buf,sizeof(buf)-1);
 if IsWindowVisible(h) then
 Form1.ListBox1.Items.Add(strpas(buf)+intToStr(h))
 else
 Form1.ListBox1.Items.Add(strpas(buf)+inttostr(h));
 result:=false;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
FileListBox1.Directory:='D:\WINDOWS\system32';
end;procedure TForm1.Freshl;
begin
listbox1.Clear;
enumChildWindows(Panel1.Handle,TFNWndEnumProc(@EnumProc),0);end;
procedure TForm1.FileListBox1DblClick(Sender: TObject);
var
str:string;
begin
str:= FileListBox1.FileName+ inttostr(Panel1.Handle);//有问题
Edit1.Text:=str;
WinExec(pchar(str),SW_SHOW);
Freshl;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
h:integer;
s:string;
begin
if listBox1.ItemIndex=-1 then exit;
s:=listbox1.Items[listbox1.itemIndex];
h:=strToInt(copy(s,pos(':',s)+1,length(s)));
showWindow(h,SW_SHOW);
freshl;end;end.

解决方案 »

  1.   

    str:= FileListBox1.FileName+ inttostr(Panel1.Handle);
    Edit1.Text:=str;
    WinExec(pchar(str),SW_SHOW);
    这是什么意思?winexec要文件的路径和文件名,不用inttostr(Panel1.Handle)这个。
    另外启动屏保可以直接用SendMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_SCREENSAVE,0);
      

  2.   

    呵呵
    启动屏保方法很多
    uses shellapi;shellexecute(handle,nil,pchar(filename),nil,nil,sw_show);
    filename为屏保文件名(绝对路径)