我要在一个delphi中调用另外的exe程序,请问如何实现,给程序语句,谢谢了
解决方案 »
- 如何将运行期包里声明的Form或Frame实例化后内嵌到主程序的Panel上
- COM 挂接IE事件
- 急,comboBox控件下拉框的内容如何动态从数据库中调啊?不用Items这个属性啊,谢谢
- 好久没来了,关于Delphi Midas开发三层架构系统的方案讨论,比较头痛,高手大哥们给个建议!
- 急~!!!分数全给了~
- 把一个Edit控件里的内容转换成带小数的数据,我应该用什么函数转换,用什么类型的数据去接收合适呢
- 请问象VB里面的工程资源管理器那样的窗口怎么做啊(能相互连接又能分开的)/
- 非高手莫要进来
- 请教 reportbuilder 终端调用方法
- 关于SQL?急!
- 提示midas.ddl装载出错,急用....谢谢
- 如何实现模板的问题!帮我解决了给100分 200409
CreateProcess(...)uses
ShellAPI;ShellExecute(...)
ShellExecute
有分我就接!!:)
ShellExecute
microsoft建议用后一个!
var
ShellExecInfo: TShellExecuteInfo;
begin
if s<> '' then
begin
ZeroMemory(@ShellExecInfo, SizeOf(TShellExecuteInfo)); with ShellExecInfo do
begin
cbSize := SizeOf(TShellExecuteInfo);
Wnd := Application.Handle;
lpFile := PChar(s);
ShellExecInfo.lpDirectory:=pchar(ExtractFilePath(s));
nShow:=SW_SHOW;
end;
ShellExecuteEx(@ShellExecInfo);
end;
result:=0;
end;
function runprocbycmd(cmd:string):integer;
var
sInfo : TStartupInfo;
pInfo : TProcessInformation;
exitCode : Cardinal;
begin
SetCurrentDir(getworkpath);
try
FillChar(sInfo,sizeof(sInfo),#0);
sInfo.cb := SizeOf(sInfo);
sInfo.dwFlags := STARTF_USESHOWWINDOW;
sInfo.wShowWindow := SW_NORMAL;if not CreateProcess(nil,pchar(cmd),nil,nil,false,CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, sInfo, pInfo) then
MessageBox(Application.handle,pchar(srunprocfalse),pchar(serror),MB_OK or MB_ICONSTOP)
else
begin
WaitForSingleObject(pInfo.hProcess,INFINITE);
GetExitCodeProcess(pInfo.hProcess,exitCode);
end;
finally
result:=exitCode;
end;
end;
BEGIN
AEXE := 'C:\KK.EXE';
Winexec(Pchar(AEXE),SW_NORMAL)
END;
WinExec
ShellExecute
ShellExecute(GetDesktopWindow(), NIl, 'rundll32.exe','shell32.dll,Control_RunDLL timeDate.cpl', Nil, 0);
建议用后一种,它除了可以调用EXE外,还可以调用别的程序,比如说文本
begin
ExeFile:='执行程序名' //含绝对路径
If FileExists(ExeFile) then
WinExec(Pchar(ExeFile),SW_SHOWNORMA)
Else ShowMessage(ExeFile+' 不存在!');
end;