来自:刘麻子, 时间:2004-6-6 17:24:57, ID:2648462<br>这个问题我也遇到过,最后还好,解决了。看我代码。<br> TOpenFile = Class(TThread) //打开硬盘上的一个文件<br> fileName:string; //完整路径+文件名 <br> Constructor Create(fName:string);<br> Procedure Execute ; Override; //线程体<br> end;<br>Constructor TOpenFile.Create(fName);<br>begin<br> inherited create(true);<br> fileName := fName;<br> FreeOnTerminate:=True; //自动释放<br> Resume; //恢复运行<br>end;<br><br>Procedure TOpenFile.Execute;<br>var<br> ShellExInfo : ShellExecuteInfo;<br>begin <br> FillChar(ShellExInfo, SizeOf(ShellExInfo), 0);<br> with ShellExInfo do begin<br> cbSize := SizeOf(ShellExInfo);<br> fMask := see_Mask_NoCloseProcess;<br> Wnd := 0;<br> lpFile := PChar(fileName);<br> nShow := sw_ShowNormal;<br> end;<br> ShellExecuteEx(@ShellExInfo);<br> WaitForSingleObject(ShellExInfo.hProcess, INFINITE);//阻塞等待进程结束<br>//这里写入要做的事情。。。。。。<br> end;<br>end;<br>//============<br>要用的时候直接这样写: TOpenFile.Create('文件名');