小弟在写程序时突然想到的一个问题!!!
就是如何在运行一个程序时能通过该程序调用其它应用程序!
就是如何在运行一个程序时能通过该程序调用其它应用程序!
解决方案 »
- 求高手开阔下思路:两个数组不一样长,取出不一样的元素
- 一个关于时间很菜的问题
- 高手来啊,WEBSERVICE问题
- adoquery生成标准XML问题
- 新手急求多线程解决方案。送上50分!
- 一个关于ActiveX控件的问,急,请大家帮帮忙
- Ado操作?
- ole控件中有个execl文件,有若干个sheer,怎样对这个ole中execl的sheet进行循环
- 怎样将4位Byte型数组转存到中一个浮点数?如a[0]=?,a[1]=?,a[2]=?,a[3]=? -> 87925. a:array[0..3] of byte.
- 急需:win2000 pro序列号
- 怎样判断数据库中一个日期的后30天的日期是多少呢?
- 誰知道那有介紹sql語句的書籍
winexec(pchar('command.com /c ipconfig /all >c:\aa.txt'),sw_hide);其它类似
ShellExecute(...)
后者比较简单,比如
ShellExecute(Handle,'open',‘c:\windows\notepad.exe',PChar'c:\a.txt',nil,SW_SHOWNORMAL);
ShellExecute(Handle,'open',‘c:\windows\notepad.exe','c:\a.txt',nil,SW_SHOWNORMAL);
var
StartInfo:STARTUPINFO;
ProcessInfo:PROCESS_INFORMATION;
begin
//执行外部程序,失败返回0,成功返回进程句柄
Result:=0;
if ProgramName='' then exit;
GetStartupInfo(StartInfo);
StartInfo.dwFlags:=StartInfo.dwFlags or STARTF_FORCEONFEEDBACK;
if not CreateProcess(nil,PChar(ProgramName),nil,nil,false,0,
nil,nil,StartInfo,ProcessInfo) then exit;
Result:=ProcessInfo.hProcess;
//建立进程成功
//如果异步执行则退出
if not wait then exit;
while IsProgram_Runing(Result) do Application.ProcessMessages;
end;
function IsProgram_Runing(hProcess:Cardinal):Boolean;
var
ExitCode:Cardinal;
begin
//查看进程是否正在运行
GetExitCodeProcess(hProcess,ExitCode);
if ExitCode=STILL_ACTIVE then
Result:=True
else
Result:=False;
end;
如果Wait参数设为假的话,和ShellExecute,winexec效果一样。
Winexec(pchar('Ping 127.0.0.1 -t'), SW_SHOW); // WinExec in unit Windows
Winexec(pchar('Ping 127.0.0.1 -t'), SW_SHOW); // WinExec in unit Windows
Winexec(pchar('Ping 127.0.0.1 -t'), SW_SHOW); // WinExec in unit Windows