public ProcessView(int id) { this.id = id; Process process = null; try { process = Process.GetProcessById(id); } catch (Exception) { } if (process != null) { successGetInfo = true; try { name = process.ProcessName; } catch (Exception) { } try { filePath = process.MainModule.FileName; image = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.Icon.ExtractAssociatedIcon(filePath).Handle, Int32Rect.Empty, BitmapSizeOptions.FromRotation(Rotation.Rotate0)); } catch (Exception) { } } }
private void Sw_TransferTempImage(object sender, TransferImageEventArgs e) { try { Dispatcher.Invoke(() => { IntPtr hbitmap = new Bitmap(e.Image).GetHbitmap(); MainImage.Source = Imaging.CreateBitmapSourceFromHBitmap( hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromRotation(Rotation.Rotate270)); Gdi32Native.DeleteObject(hbitmap); }); } catch (Exception ex) { Console.WriteLine(ex); } }
private void Sw_TransferCompleteImage(object sender, TransferImageEventArgs e) { try { Dispatcher.Invoke(() => { IntPtr hbitmap = new Bitmap(e.Image).GetHbitmap(); MainImage.Source = Imaging.CreateBitmapSourceFromHBitmap( hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromRotation(Rotation.Rotate270)); Gdi32Native.DeleteObject(hbitmap); fileName.Content = "complete!"; progressBar.Visibility = Visibility.Hidden; }); } catch (Exception ex) { Console.WriteLine(ex); } }
public ProcessDetailWindow(ProcessView tempP) { this.process = tempP; InitializeComponent(); ProcessID.Text = process.ID + ""; if (process.SuccessGetInfo) { ProcessName.Text = process.Name ?? Tool.GetStringResource("Unknown"); ProcessIcon.Source = process.Image; if (process.FilePath == null && !Tool.IsAdministrator()) { OpenButtonImage.Source = Imaging.CreateBitmapSourceFromHIcon(SystemIcons.Shield.Handle, Int32Rect.Empty, BitmapSizeOptions.FromRotation(Rotation.Rotate0)); OpenButtonText.Text = Tool.GetStringResource("RunAsAdministratorToGetMoreInformation"); OpenButton.Click += OpenButton_RunAsAdmin_Click; KillButton.IsEnabled = false; } else { if (process.FilePath == null) { OpenButton.IsEnabled = false; } else { ProcessPath.Text = process.FilePath; OpenButton.Click += OpenButton_OpenPath_Click; } KillButton.IsEnabled = true; KillButton.Click += KillButton_KillProcess_Click; } } else { ContentGrid.IsEnabled = false; } }