Показать сообщение отдельно
  #3  
Старый 25.05.2015, 11:51
Аватар для Alloc
Alloc Alloc вне форума
Начинающий
 
Регистрация: 17.09.2014
Сообщения: 104
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию

Спасибо за подсказку. А как быть если я запускаю игру через командную строку, вот так:

Код:
 function StartFileAndWait(CommandString: string): boolean;      //âõîä - êîìàíäà çàïóñêà
var
	si: TStartupInfo;
	pi: TProcessInformation;
begin
	Result := False;
	ZeroMemory( @si, sizeof( si ) );
	si.cb := SizeOf( si );
	if not CreateProcess( nil, // No module name (use command line).
		PChar( CommandString ), // Command line.
		nil, // Process handle not inheritable.
		nil, // Thread handle not inheritable.
		False, // Set handle inheritance to FALSE.
		0, // No creation flags.
		nil, // Use parent's environment block.
		nil, // Use parent's starting directory.
		si, // Pointer to STARTUPINFO structure.
		pi ) // Pointer to PROCESS_INFORMATION structure.
	then
	begin
    result:=false;
		Exit;
	end;
	WaitForSingleObject( pi.hProcess, INFINITE );
	CloseHandle( pi.hThread );
	CloseHandle( pi.hProcess );
  Application.BringToFront;
  Result := True;
end;

Код:
if StartFileAndWait(DTLiteDir+' -mount dt, "'+ExtractFilePath(Application.ExeName)+'img\mygame.cue"') then
   if StartFileAndWait('cmd.exe /c start /affinity 1 /d '+'"'+ExtractFileDir(Application.ExeName)+'MyGame.exe "'+'"'+Keys+"') then
      ShowMessage('Программа закрыта');

если я сделаю так то программа будет ждать завершения не "MyGame.exe" а "cmd.exe"... как решить задачу?
Заранее спасибо.
Ответить с цитированием