给你搞定了,使用FindExecutable [
]
uses
shellapi;
procedure TForm1.Button1Click(Sender: TObject);
var
lExeName: pChar;
SUInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CmdLine: string;
begin
GetMem(lExeName, 255);
if FindExecutable('E:/1.xls', 'E:/', lExeName) > 32 then
begin
ShowMessage(lExeName);
FillChar(SUInfo, SizeOf(SUInfo), #0);
with SUInfodo
begin
cb := SizeOf(SUInfo);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := 0;
end;
if CreateProcess(lExeName, pChar('1.xls'), NIL, NIL,
FALSE, NORMAL_PRIORITY_CLASS, NIL,
'E:/', SUInfo, ProcInfo) then
{等待结束 }
begin
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
CloseHandle(ProcInfo.hProcess);
{清理句柄 }
CloseHandle(ProcInfo.hThread);
end;
end;
FreeMem(lExeName);
end;