如何在delphi里面调用其他的exe程序???

loshunter 2004-09-24 11:11:49
我要在一个delphi中调用另外的exe程序,请问如何实现,给程序语句,谢谢了
...全文
1113 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
benjiamen 2004-10-14
  • 打赏
  • 举报
回复
var ExeFile:String;
begin
ExeFile:='执行程序名' //含绝对路径
If FileExists(ExeFile) then
WinExec(Pchar(ExeFile),SW_SHOWNORMA)
Else ShowMessage(ExeFile+' 不存在!');
end;
victor_yang 2004-10-14
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3380/3380241.xml?temp=.2008783

先搜索下以前的帖子吧。
zdq801104 2004-09-28
  • 打赏
  • 举报
回复
WinExec('notepad.exe',1);
ShellExecute(GetDesktopWindow(), NIl, 'rundll32.exe','shell32.dll,Control_RunDLL timeDate.cpl', Nil, 0);
建议用后一种,它除了可以调用EXE外,还可以调用别的程序,比如说文本
老本 2004-09-28
  • 打赏
  • 举报
回复
WinExec肯定可以, ShellExecute有时不行, 也不知道为什么?
masterjames 2004-09-27
  • 打赏
  • 举报
回复
VAR AEXE : STRING
BEGIN
AEXE := 'C:\KK.EXE';
Winexec(Pchar(AEXE),SW_NORMAL)
END;
pengxuan 2004-09-27
  • 打赏
  • 举报
回复
加入shellapi单元,用下面两上函数
WinExec
ShellExecute
luke5678 2004-09-25
  • 打赏
  • 举报
回复
WinExec
ShellExecute
ljXie 2004-09-25
  • 打赏
  • 举报
回复
WinExec,但是用Pchar不太安全。
Tensionli 2004-09-25
  • 打赏
  • 举报
回复
ShellExecute看看帮助的用法
liufuyahong 2004-09-25
  • 打赏
  • 举报
回复
WinExec
getit911 2004-09-25
  • 打赏
  • 举报
回复
CreateProcess调用
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;
getit911 2004-09-25
  • 打赏
  • 举报
回复
function ExecFile(s:string): Integer;
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;
angelface 2004-09-25
  • 打赏
  • 举报
回复
WinExec
ShellExecute
microsoft建议用后一个!
Rex_love_Burger 2004-09-25
  • 打赏
  • 举报
回复
WinExec
ShellExecute
有分我就接!!:)
wg007 2004-09-24
  • 打赏
  • 举报
回复
建议楼主提问前先搜索一下有无已解答的贴子.
xuyfufeng 2004-09-24
  • 打赏
  • 举报
回复
Winexec(Pchar('c:\p.exe'),SW_NORMAL)
mscrack 2004-09-24
  • 打赏
  • 举报
回复
WinExec(...)
CreateProcess(...)

uses
ShellAPI;

ShellExecute(...)

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧