Удерживайте выполнение программы до завершения ShellExecute

 

I have the following code:

#import "shell32.dll"

int ShellExecuteW (int hwnd, string строки, string файл, string параметры, string каталог, int showCmd);
 
#Импортировать
void OnInit ()
{
string strParameters = "/ c terms.exe";

     int result = ShellExecuteW (0, "open", "cmd.exe", strParameters, NULL, 1);

     if (result <= 32) Print ("Ошибка выполнения оболочки: ", result);

// Прочитайте файл, генерируемый функцией ShellExecuteW (), а затем установите таймер

EventSetTimer (1);
}
void OnTimer ()
{

Print ( "Привет");
}

Код работает нормально. Но после команды ShellExecuteW () я получаю файл, который я должен загрузить в OnInit (). Но выполнение не ждет завершения ShellExecuteW () и продолжения.


Пожалуйста, дайте мне знать, как я могу держать программу для завершения командной строки ShellExecute, а затем прочитать файл, а затем установить Timer для дальнейшего выполнения.

 
Hi Jaffer, ShellExecute won't help here. You'll have to use the CreateProcess function and then call WaitForSingleObject to wait on the process handle. Here's an example: https://www.codeproject.com/Tips/333559/CreateProcess-and-wait-for-result
CreateProcess() and wait for result - CodeProject
CreateProcess() and wait for result - CodeProject
  • SuperFun21
  • www.codeproject.com
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Причина обращения: