private void VTFlasher_Load(object sender, EventArgs e) { if (File.Exists(Path.Combine(Application.StartupPath, FilePathProvider.PasswordFilePath))) { savedPassword = FileHelper.ReadText(Path.Combine(Application.StartupPath, FilePathProvider.PasswordFilePath)); if (!string.IsNullOrEmpty(savedPassword)) { txtPassword.Text = (string)serializationHelper.DeserializeObject(savedPassword); checkBoxSavePassword.Checked = true; } } var info = new ProcessStartInfo { FileName = AppDomain.CurrentDomain.BaseDirectory + "\\PcmFlasher\\pcmflash.exe", UseShellExecute = true, //CreateNoWindow = true, RedirectStandardInput = false, RedirectStandardOutput = false, RedirectStandardError = false, // WindowStyle = ProcessWindowStyle.Hidden }; pcmProcess = Process.Start(info); pcmProcess.WaitForInputIdle(); pcmMainWindow = WinAPIHelper.FindWindowByCaption(IntPtr.Zero, "PCMflash"); WinAPIHelper.SetParent(pcmProcess.MainWindowHandle, this.Handle); pcmChildren = GetChildWindows(pcmMainWindow); pcmComboBoxModules = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[6], null, null); pcmComboBoxAdapters = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[0], null, null); pcmTextBoxFilePath = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[14], null, null); pcmButtonExit = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[22], null, null); pcmButtonSettings = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[4], null, null); pcmKeyNumber = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[3], null, null); pcmTextBoxStatus = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[20], null, null); pcmButtonInitialize = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[10], null, null); pcmButtonIdentify = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[7], null, null); pcmButtonReadErrors = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[8], null, null); pcmButtonRestart = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[9], null, null); pcmButtonEraseErrors = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[11], null, null); pcmButtonRestartAdaptation = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[12], null, null); pcmButtonRead = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[17], null, null); pcmButtonWrite = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[18], null, null); pcmButtonCheckCorrectCS = WinAPIHelper.FindWindowEx(pcmMainWindow, pcmChildren[16], null, null); InitializeComboBoxControl(pcmComboBoxAdapters, cbAdapter); //InitializeComboBoxControl(pcmComboBoxModules, cbModules); SetButtonStatus(); WinAPIHelper.SendMessage(pcmTextBoxStatus, WinAPIHelper.WM_GETTEXT, 10000, sb); if (sb.ToString().Contains("Электронный ключ недоступен")) { pcmProcess.Kill(); pcmMainWindow = IntPtr.Zero; panelKeyUnavailible.BringToFront(); panelKeyUnavailible.Visible = true; return; } else { panelKeyUnavailible.Visible = false; } txtStatusThread = new Thread(() => { string pcmTextData = ""; while (true) { WinAPIHelper.SendMessage(pcmTextBoxStatus, WinAPIHelper.WM_GETTEXT, 10000, sb); pcmTextData = sb.ToString(); var stringPcmText = pcmTextData.Replace("\n", "").Split('\r'); var denyStringsList = new List <string>(); denyStringsList.Add("Версия программы"); foreach (string denyStrings in denyStringsList) { stringPcmText = stringPcmText.Where(t => !t.StartsWith(denyStrings)).ToArray <string>(); } //this.Invoke(()=>txtStatus.Text = sb.ToString()); this.Invoke(() => tbReflashText.Text = String.Join("\r\n", stringPcmText)); Thread.Sleep(100); } }); txtStatusThread.Start(); }