현재 많은 명령 줄 및 기타 외부 프로세스를 하나의 응용 프로그램으로 통합하는 간단한 프로그램을 작성하고 있습니다.외부 프로세스의 진행률 표시 줄
현재 시스템 정보 프로세스를 사용하여 시스템 정보를 가져 오는 문제에 직면하고 있습니다.
시스템 정보 프로세스를 호출하는 버튼을 성공적으로 코딩했으며 출력을 텍스트 필드로 리디렉션했습니다.
지금 시도하고있는 것은 시스템 정보를로드하는 데 잠시 시간이 걸리기 때문에 내 WPF 창의 아래쪽에 진행률 표시 줄이있는 것입니다.
외부 프로세스에서 정확한 지속 시간을 얻는 방법을 모르므로 마키 스타일을 사용하려고합니다.
다른 사이트와 마찬가지로 stackoverflow (Windows Forms ProgressBar: Easiest way to start/stop marquee?)에서 예제를 수행했지만 systeminfo가 실행되는 동안 진행률 막대가 스크롤되도록 코드를 넣을 위치를 결정할 수 없었습니다. 은 끝났어.
현재 코드 (progressbar1.Style = ProgressBarStyle.Marquee;
제외)는 다음과 같습니다.
코드를 넣을 위치 나 사용할 구문에 대한 제안은 크게 감사하겠습니다. 미리 감사드립니다. 당신이해야 할 일은
private void btnSystemInfo_Click(object sender, RoutedEventArgs e)
{
// Get system info
Process info = new Process();
info.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
info.StartInfo.FileName = "C:\\Windows\\system32\\systeminfo.exe";
info.StartInfo.Arguments = "-S " + context;
info.StartInfo.UseShellExecute = false;
info.StartInfo.CreateNoWindow = true;
info.StartInfo.RedirectStandardOutput = true;
info.Start();
string infoOutput = info.StandardOutput.ReadToEnd();
info.WaitForExit();
// Write to the txtInfo text box
txtInfo.Text = "System Info: " + infoOutput;
txtInfo.Foreground = Brushes.Black;
txtInfo.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
// Switch to the info tab
tabControl.SelectedIndex = 3;
}
하리스 하산 감사합니다! 이것은 내가 찾고 있었던 것이다! – PsiLentRain