一个程序里运行多个实例(50分)

Z

zysing

Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手:
   我在主程序里用到shellexecute(handle, 'open', pchar('../A/B.exe'), nil, nil, sw_shownormal);语句调用一个可执行程序,同样的用这个语句调用另一个
shellexecute(handle, 'open', pchar('../C/D.exe'), nil, nil, sw_shownormal);可执行程序
且两者都是在主界面通过点两个子菜单调用的,但是,我打开了B.exe后就必须关闭了才可打开D.exe用什么方法可将B.exe最小化(置后台)再打开D.exe呢,多谢 
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1803804
 
关于ShellExecute函数:
在ShellAPI单元中,ShellExecute函数的定义为:
function ShellExecute(hWnd: HWND;
Operation, FileName, Parameters,
Directory: PChar;
ShowCmd: Integer): HINST;
stdcall;
作用:打开或打印一个指定的文件;
参数说明:
hWnd hwnd, //指向父窗口的句柄;
Operation: PChar, //指向一个null结尾的串以指明要执行的操作;
可以是"open","print","explore",NULL;
FileName: PChar, //指向文件名或文件夹名串;
Parameters: PChar, //指向一个null结尾的串以指明可执行文件的参数;
如果FileName参数为文档,此参数应为NULL;
Directory: PChar, //指向一个null结尾的串以指明默认目录;
ShowCmd: Integer //文件在打开时是否显示;
如果FileName参数为文档,此参数应为0;
 
楼上的,你抄我的答案也不看看我在不在啊?你以为我不会Copy么?我打一个链接已经很清楚了,你就不要再这样浪费大富翁的资源了。
 
楼上两位都莫生气,一切只为能解决问题,两位都很感谢[:)]
 
创建两个线程我想应该可以,当一个线程的打开文件操作之后,就让该线程挂起;然后执行第二个线程.不过我也没试过,你最好试试.
 
樓主說的是什麼問題啊??
我用D7,D5試了都正常,不管怎麼打開都很正常
 
对于此题可以用以后代码:
procedure MessageLoop;
var msg : TMsg;
begin
while GetMessage(msg, 0, 0, 0)do
case msg.message of
WM_USER+521 : then
begin
message1();
end;
WM_USER+522 :then
begin
message2();
end;
TranslateMessage(msg);
DispatchMessage(msg);
end;
end;
procedure TYourThread.Execute;
begin
MessageLoop;
end;

procedure message1():message WM_USER+521;
{
shellexecute(handle, 'open', pchar('../A/B.exe'), nil, nil,sw_shownormal);
}
procedure message2():message WM_USER+522;
{
shellexecute(handle, 'open', pchar('../C/D.exe'), nil, nil, sw_shownormal);
}
 
shellexecute(0, 'open', pchar('../A/B.exe'), nil, nil, sw_shownormal);
shellexecute(0, 'open', pchar('../C/D.exe'), nil, nil, sw_shownormal);
把Handel改成0;
 
多人接受答案了。
 
顶部