Раздел: [[ВзаимодействиеСОкружением]] ---- Как запустить внешнее приложение из Axapta: Варианты *Использовать [[Класс/WinApi/ShellExecute]] *Если надо подождать завершения запущенного приложения, то: *через ActiveX [[http://www.devguru.com/Technologies/wsh/quickref/wshshell_Run.html]] *воспользоваться советом из [[AxForum:5193]] : Параметры: 1. командная строка 2. сколько миллисекунд ждать завершения (-1 ждать вечно) 3. режим отображения окна (нормальное, максимизированое, свернутое). static void shellExecuteWait(str commandLine, int _waitTime = -1, int cmdShow = 4) { #WinAPI #DEFINE.STATUS_TIMEOUT(0x00000102) Dll kernel32 = new Dll("kernel32.dll"); DllFunction createProcess = new DllFunction(kernel32, "CreateProcessA"); DllFunction waitForSingleObject = new DllFunction(kernel32, "WaitForSingleObject"); DllFunction closeHandle = new DllFunction(kernel32, "CloseHandle"); DllFunction terminateProcess = new DllFunction(kernel32, "TerminateProcess"); Binary strartupInformation = new binary(68); Binary processInformation = new binary(16); int hProcess; createProcess.returns(ExtTypes:: DWORD); createProcess.arg(ExtTypes:: DWORD, ExtTypes:: STRING, ExtTypes:: DWORD, ExtTypes:: DWORD, ExtTypes:: DWORD, ExtTypes:: DWORD, ExtTypes:: DWORD, ExtTypes:: DWORD, ExtTypes:: POINTER, ExtTypes:: POINTER); waitForSingleObject.returns(ExtTypes:: DWORD); waitForSingleObject.arg(ExtTypes:: DWORD, ExtTypes:: DWORD); closeHandle.returns(ExtTypes:: DWORD); closeHandle.arg(ExtTypes:: DWORD); terminateProcess.returns(ExtTypes:: DWord); terminateProcess.arg(ExtTypes:: DWord, ExtTypes:: DWord); strartupInformation.dWord(44, cmdShow); if (!createProcess.call(0, commandLine, 0, 0, 0, 0, 0, 0, strartupInformation, processInformation)) { throw error(strfmt("Ошибка при запуске приложения \"%1\"", commandLine)); } hProcess = processInformation.dWord(0); if (waitForSingleObject.call(hProcess, _waitTime) == #STATUS_TIMEOUT) { terminateProcess.call(hProcess, 1); throw error(strfmt("Приложение \"%1\" закрыто, так как не завершилось за отведенное ему время", commandLine)); } closeHandle.call(hProcess); }