public bool MountImage() { if (Thread.CurrentPrincipal == null || !Thread.CurrentPrincipal.IsInRole("Administrators")) { MessageBox.Show("Request for Administrator privilages failed.\n VDK may not function.", "Info"); } bool success = this.StartVdkService(); bool flag = success; if (flag) { this.p.StartInfo.FileName = this.data.Paths.VDK + "\\vdk.exe"; this.p.StartInfo.WorkingDirectory = this.data.Paths.VDK; this.p.StartInfo.Arguments = "open 0 \"" + this.data.Tools.vdk.Image + "\" /RW /L:" + this.data.Tools.vdk.DriveLetter; try { this.p.Start(); } catch (Exception e) { this.ErrBuffer = e.Message; success = false; } } else { ErrorForm error = new ErrorForm(); error.txtError.Text = this.ErrBuffer; TextBox txtError = error.txtError; txtError.Text += this.p.StandardOutput.ReadToEnd(); error.ShowDialog(); } return(success); }
private void PipeErrorHandler(object sender, PipeErrorEventArgs args) { ErrorForm err = new ErrorForm(); TextBox txtError = err.txtError; txtError.Text = txtError.Text + "PipeErrorHandler:" + Environment.NewLine; TextBox txtError2 = err.txtError; txtError2.Text += args.ErrorDesc; err.Show(); }
public bool CreateImage(string FileName, long Size, string Format) { string argv = string.Concat(new string[] { " create -f ", Format, " \"", FileName, "\" ", (Size * 1024L).ToString() }); this.p.StartInfo.FileName = this.data.Paths.Qemu + "\\qemu-img.exe"; bool flag = !File.Exists(this.p.StartInfo.FileName); bool result; if (flag) { MessageBox.Show("qemu-img.exe does not existin path", "Error - Qemu path"); result = false; } else { this.p.StartInfo.WorkingDirectory = this.data.Paths.Qemu; this.p.StartInfo.Arguments = argv; try { this.p.Start(); } catch (Exception e) { this.ErrBuffer = this.ErrBuffer + Environment.NewLine + "Error: " + e.Message; ErrorForm error = new ErrorForm(); error.txtError.Text = this.ErrBuffer; TextBox txtError = error.txtError; txtError.Text += this.p.StandardError.ReadToEnd(); error.ShowDialog(); return(false); } result = true; } return(result); }
public bool UnmountImage() { this.p.StartInfo.FileName = this.data.Paths.VDK + "\\vdk.exe"; this.p.StartInfo.WorkingDirectory = this.data.Paths.VDK; this.p.StartInfo.Arguments = "CLOSE * /F"; try { this.p.Start(); } catch (Exception e) { this.ErrBuffer = this.ErrBuffer + Environment.NewLine + "Error: " + e.Message; ErrorForm error = new ErrorForm(); error.txtError.Text = this.ErrBuffer; TextBox txtError = error.txtError; txtError.Text += this.p.StandardError.ReadToEnd(); error.ShowDialog(); return(false); } this.StopVdkService(); return(true); }