--- trunk/RomCheater.PluginFramework/Core/ProcContainer.cs 2012/05/10 09:03:13 100 +++ trunk/RomCheater.PluginFramework/Core/ProcContainer.cs 2012/05/10 11:16:03 107 @@ -16,8 +16,17 @@ namespace RomCheater.PluginFramework.Cor : this() { this.ProcessInfo = process; - string fname = ThreadControl.GetProcessFilename(process); - FileInfo fi = new FileInfo(fname); + FileInfo fi = null; + string fname = ""; + try + { + fname = ProcessModeleInfoEx.GetMainModulePath(process); + fi = new FileInfo(fname); + } + catch (Exception) + { + throw; + } this.FileName = fi.FullName; this.Name = fi.Name; this.CreateProcessIcon(4); @@ -26,7 +35,7 @@ namespace RomCheater.PluginFramework.Cor : this() { this.ProcessInfo = process; this.ProcessIcon = icon.ToBitmap(); - string fname = ThreadControl.GetProcessFilename(process); + string fname = ProcessModeleInfoEx.GetMainModulePath(process); FileInfo fi = new FileInfo(fname); this.FileName = fi.FullName; this.Name = fi.Name; @@ -35,7 +44,7 @@ namespace RomCheater.PluginFramework.Cor : this() { this.ProcessInfo = process; this.ProcessIcon = icon; - string fname = ThreadControl.GetProcessFilename(process); + string fname = ProcessModeleInfoEx.GetMainModulePath(process); FileInfo fi = new FileInfo(fname); this.FileName = fi.FullName; this.Name = fi.Name; @@ -59,38 +68,76 @@ namespace RomCheater.PluginFramework.Cor public static Bitmap CreateIconFromProcess(ProcContainer proc) { if (proc == null) return null; - return Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); + Icon large = ProcessIconEx.ExtractIConFromFile(proc.FileName, true); + if (large == null) large = ProcessIconEx.ExtractIConFromFile(proc.FileName, false); + Bitmap ret = large.ToBitmap(); + if (ret == null) + { + int i = 0; + } + return ret; } public static Bitmap CreateIconFromProcess(ProcContainer proc, int Scale) { if (proc == null) return null; - Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); + Icon large = ProcessIconEx.ExtractIConFromFile(proc.FileName, true); + if (large == null) large = ProcessIconEx.ExtractIConFromFile(proc.FileName, false); + Bitmap ret = large.ToBitmap(); + if (ret == null) + { + int i = 0; + } ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); return ret; } public static Bitmap CreateIconFromProcess(ProcContainer proc, int Width, int Height) { if (proc == null) return null; - Bitmap ret = Icon.ExtractAssociatedIcon(proc.FileName).ToBitmap(); + Icon large = ProcessIconEx.ExtractIConFromFile(proc.FileName, true); + if (large == null) large = ProcessIconEx.ExtractIConFromFile(proc.FileName, false); + Bitmap ret = large.ToBitmap(); + if (ret == null) + { + int i = 0; + } ret = new Bitmap(ret, Width, Height); return ret; } private void CreateProcessIcon() { if (this.ProcessInfo == null) return; - this.ProcessIcon = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); + Icon large = ProcessIconEx.ExtractIConFromFile(this.FileName, true); + if (large == null) large = ProcessIconEx.ExtractIConFromFile(this.FileName, false); + Bitmap ret = large.ToBitmap(); + if (ret == null) + { + int i = 0; + } + this.ProcessIcon = ret; } private void CreateProcessIcon(int Scale) { - Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); - ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); + Icon large = ProcessIconEx.ExtractIConFromFile(this.FileName, true); + if (large == null) large = ProcessIconEx.ExtractIConFromFile(this.FileName, false); + Bitmap ret = large.ToBitmap(); + if (ret == null) + { + int i = 0; + } + ret = new Bitmap(ret, ret.Width * Scale, ret.Height * Scale); this.ProcessIcon = ret; } private void CreateProcessIcon(int Width, int Height) { if (this.ProcessInfo == null) return; - Bitmap ret = Icon.ExtractAssociatedIcon(this.FileName).ToBitmap(); - ret = new Bitmap(ret, Width, Height); + Icon large = ProcessIconEx.ExtractIConFromFile(this.FileName, true); + if (large == null) large = ProcessIconEx.ExtractIConFromFile(this.FileName, false); + Bitmap ret = large.ToBitmap(); + if (ret == null) + { + int i = 0; + } + ret = new Bitmap(ret, Width, Height); this.ProcessIcon = ret; } } |