//Excute File
sCopyBatFile := gsExeWorkPath + '\' + 'CallTestChild.exe';
ls_appname := pchar(sCopybatFile);
ls_commandline := pchar(sCopyBatFile );
lb_inherit := FALSE;
//ll_flags := 134217728; // ²»ÏÔʾ´°¿Ú
ll_flags := CREATE_NEW_CONSOLE; FillChar(lstr_StartupInfo, Sizeof(lstr_StartupInfo), #0);
lstr_StartupInfo.cb := Sizeof(lstr_StartupInfo);
lstr_StartupInfo.dwFlags := STARTF_USESHOWWINDOW; lstr_StartupInfo.wShowWindow := 1; if not fileexists( sCopyBatFile) then
begin
showmessage('¼ÇÕʽø³ÌÖ´ÐÐÎļþ²»´æÔÚ£¡ Çë֪ͨϵͳ¹ÜÀíÔ±');
exit;
end; lb_success := CreateProcess(ls_appname,ls_commandline,nil,nil,lb_inherit,ll_flags,nil,nil,lstr_startupinfo,lstr_processinformation); IF lb_success THEN
begin
ll_hprocess := lstr_processinformation.hprocess;
end;
iretcd := GetLastError(); if lb_success = FALSE then
begin
ShowMessage('ͨѶ½ø³ÌÆô¶¯Ê§°Ü£¬Çë֪ͨ¹ÜÀíÔ±£¡');
showmessage(inttostr(iretcd)); showmessage('Error Copying File: '+string(PChar(ErrorMessage)));
screen.Cursor := crDefault;
exit;
end;
sCopyBatFile := gsExeWorkPath + '\' + 'CallTestChild.exe';
ls_appname := pchar(sCopybatFile);
ls_commandline := pchar(sCopyBatFile );
lb_inherit := FALSE;
//ll_flags := 134217728; // ²»ÏÔʾ´°¿Ú
ll_flags := CREATE_NEW_CONSOLE; FillChar(lstr_StartupInfo, Sizeof(lstr_StartupInfo), #0);
lstr_StartupInfo.cb := Sizeof(lstr_StartupInfo);
lstr_StartupInfo.dwFlags := STARTF_USESHOWWINDOW; lstr_StartupInfo.wShowWindow := 1; if not fileexists( sCopyBatFile) then
begin
showmessage('¼ÇÕʽø³ÌÖ´ÐÐÎļþ²»´æÔÚ£¡ Çë֪ͨϵͳ¹ÜÀíÔ±');
exit;
end; lb_success := CreateProcess(ls_appname,ls_commandline,nil,nil,lb_inherit,ll_flags,nil,nil,lstr_startupinfo,lstr_processinformation); IF lb_success THEN
begin
ll_hprocess := lstr_processinformation.hprocess;
end;
iretcd := GetLastError(); if lb_success = FALSE then
begin
ShowMessage('ͨѶ½ø³ÌÆô¶¯Ê§°Ü£¬Çë֪ͨ¹ÜÀíÔ±£¡');
showmessage(inttostr(iretcd)); showmessage('Error Copying File: '+string(PChar(ErrorMessage)));
screen.Cursor := crDefault;
exit;
end;
或者你用VB写的东西有没有和Delphi里所调用的资源冲突的
一般, 你可以自己定義對應的消息號來處理比較簡單,
用GetMessage, PeekMessage之類的, 實現麻煩點
IF lb_success THEN
begin
ll_hprocess := lstr_processinformation.hprocess;
repeat
begin
sleep(100);
ll_success := GetExitCodeProcess(ll_hprocess,ll_exitcode);
end;
until ((ll_exitcode <> 259) or (ll_success = FALSE)); end;如果等待 执行文件结果 启动的VB执行文件就会死在SENDMESSAGE语句上,无法返回。 repeat
begin
sleep(100);
ll_success := GetExitCodeProcess(ll_hprocess,ll_exitcode);
end;
until ((ll_exitcode <> 259) or (ll_success = FALSE));如果不等待结果,我的编辑框控件就可以接收到SENDMESSAGE 的消息,子程序就能成功返回。各位看看为什么? 对VB的消息传递不熟悉