private void ShowForegroundWindow(object sender, EventArgs e) { var FW = GetForegroundWindow(); /* * StringBuilder SB = new StringBuilder(); * //char[] filepath = new char[10000]; * //uint maxfilepathlength = 1000; * try * { * GetWindowText(FW, SB, 1000); * } * catch (Exception ex) * { * Debug.Write(ex.Message); * } */ //Debug.Write(SB); //QueryFullProcessImageName(new IntPtr(GetCurrentProcessID(FW)), 0, filepath, ref maxfilepathlength); var P = Process.GetProcessById(GetCurrentProcessID(FW)); var PP = FindHostedProcess.Find(); if (PP == null) { return; } TB.Text = PP.ProcessName + "|" + PP.MainModule.FileName + "|" + PP.MainWindowTitle; //Bitmap img = Consts.Base64String2Icon(Consts.Icon2Base64String(System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName))).ToBitmap(); Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName); Icon icon2 = Consts.Base64String2Icon(Consts.Icon2Base64String(icon)); IMG.Source = Consts.ChangeBitmapToImageSource(icon2.ToBitmap()); }
public ListStackPanelItem(Data.ShowData SD) { InitializeComponent(); IconImage.Source = Consts.ChangeBitmapToImageSource(SD.I.ToBitmap()); StartTimeTextBlock.Text = "开始时间:" + SD.Start.ToString(Consts.DateTimeFormatString); EndTimeTextBlock.Text = "结束时间:" + SD.End.ToString(Consts.DateTimeFormatString); ActionTextBlock.Text = Consts.GetFileName(SD.Action); FullFileName = SD.Action; TitleTextBlock.Text = SD.Title; }