为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

WinForm开机启动、禁用开启任务管理器图片压缩常用函数

2017-11-27 14页 doc 33KB 21阅读

用户头像

is_337177

暂无简介

举报
WinForm开机启动、禁用开启任务管理器图片压缩常用函数WinForm开机启动、禁用开启任务管理器图片压缩常用函数 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; using System.Diagnostics; using System.Runtime.InteropServices; usin...
WinForm开机启动、禁用开启任务管理器图片压缩常用函数
WinForm开机启动、禁用开启任务管理器图片压缩常用函数 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Drawing; namespace Ecan { public class EcanSystem { /// /// 设置程序开机运行 /// /// 是否开机运行 /// 要运行的EXE程序名称(不要拓展名) /// 要运行的EXE程序路径 /// 成功返回真,否则返回假 public bool runWhenStart(bool started, string exeName, string path) { Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//打 开注册子项 if (key == null)//如果该项不存在的话,则创建该子项 { key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); } if (started == true) { try { key.SetValue(exeName, path);//设置为开机启动 key.Close(); } catch { return false; } } else { try { Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 key.DeleteValue(exeName);//取消开机启动 key.Close(); } catch { return false; } } return true; } /// /// 解禁任务管理器 /// /// 成功返回真,否则返回假 public bool enableTaskmgr() { RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system", true);//打开注册表子项 if (key == null)//如果该项不存在的话,则创建该子项 { key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 } try { key.SetValue("disabletaskmgr", 0, RegistryValueKind.DWord); key.Close(); return true; } catch { return false; } } /// /// 禁用任务管理器 /// /// 成功返回真,否则返回假 public bool notEnableTaskmgr() { RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system", true);//打开注册表子项 if (key == null)//如果该项不存在的话,则创建该子项 { Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\syste m"); } try { key.SetValue("disabletaskmgr", 1, RegistryValueKind.DWord); key.Close(); return true; } catch { return false; } Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 } /// /// 解禁注册表 /// /// 成功返回真,否则返回假 public bool enableRegedit() { RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\polici es\\system", true);//打开注册表子项 if (key == null)//如果该项不存在的话,则创建该子项 { key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\syste m"); Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 } try { key.SetValue("disableregistrytools", 0, RegistryValueKind.DWord); key.Close(); return true; } catch { return false; } } /// Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 /// 禁用注册表 /// /// 成功返回真,否则返回假 public bool notEnableRegedit() { RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\polici es\\system", true);//打开注册表子项 if (key == null)//如果该项不存在的话,则创建该子项 { key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\syste m"); } try Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 { key.SetValue("disableregistrytools", 1, RegistryValueKind.DWord); key.Close(); return true; } catch { return false; } } /// /// 结束进程 /// Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 /// 进程名称 /// 成功返回真,否则返回假 public bool killProcess(string processName) { try { foreach (Process p in Process.GetProcesses()) { if (p.ProcessName == processName) { p.Kill(); } } Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 return true; } catch { return false; } } /// /// 注册控件 /// /// 控件 注册后对应的键值 /// 成功返回真,否则返回假 public bool regDll(string dllIdValue) { try Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 { RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"CLSTD\" + dllIdValue, true);//打开注册表子项 if (key == null)//如果该项不存在的话,则创建该子项 { key = Registry.ClassesRoot.CreateSubKey(@"CLSTD\" + dllIdValue); } return true; } catch { return false; } } /// /// 压缩图片(指定压缩比例值) /// Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 /// 源文件 /// 保存文件 /// 比例值(例如0.5) /// 成功返回真,否则返回假 public bool pressImage(string fromFile, string saveFile,double bili) { Image img; Bitmap bmp; Graphics grap; int width, height; try { img = Image.FromFile(fromFile); Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 width = Convert.ToInt32(img.Width * bili); height = Convert.ToInt32(img.Height * bili); bmp = new Bitmap(width, height); grap = Graphics.FromImage(bmp); grap.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; grap.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; grap.DrawImage(img, new Rectangle(0, 0, width, height)); bmp.Save(saveFile, System.Drawing.Imaging.ImageFormat.Jpeg); grap.Dispose(); bmp.Dispose(); img.Dispose(); return true; } Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 catch { return false; } } /// /// 压缩图片(指定高度和宽度) /// /// 源文件 /// 保存文件 /// 宽度值 /// 高度值 /// 成功返回真,否则返回假 public bool pressImage(string fromFile, string saveFile, int width,int height) { Image img; Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 Bitmap bmp; Graphics grap; try { img = Image.FromFile(fromFile); bmp = new Bitmap(width, height); grap = Graphics.FromImage(bmp); grap.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; grap.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; grap.DrawImage(img, new Rectangle(0, 0, width , height)); bmp.Save(saveFile, System.Drawing.Imaging.ImageFormat.Jpeg); Copyright ? 痴心长剑.W 2012.05.09 WinForm开机启动、图片压缩等常用函数--------------------------------------痴心长剑.W技术文档系列 grap.Dispose(); bmp.Dispose(); img.Dispose(); return true; } catch { return false; } } } } Copyright ? 痴心长剑.W 2012.05.09
/
本文档为【WinForm开机启动、禁用开启任务管理器图片压缩常用函数】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索