怎么给WINFORM应用程序的快捷方式定义快捷键,是否能在程序上实现?想达到的效果就是输入快捷键,能启动这个应用程序。就像安装后在桌面上的快捷方式上设置快捷键那样。希望在程序安装以后就自带这个快捷启动键,怎么实现?
解决方案 »
- 用http post访问webserver,怎么才能获取webserver返回的指定格式的数据?
- 如何添加事件?
- 冒泡排序的疑问
- 急急急!按照微软的标准,我的三层结构系统中,每个数据库表都需要一个数据实体?
- 问一下如何使用C#,来清空剪切板?
- 我在在winform里内嵌了webbrowser控件,调用excel,出了好几个问题,帮忙搞下好,谢谢高手了
- 关于WCF异常
- 怎么象数据库中的View一样从DataTable中提取几行做成DataView?
- .net里面怎么访问客户端的打印机
- 用了一天Framework SDK的心得(请高手指正)。
- c# 杏和接口service调试出现问号????????+????乱码如何解决
- WPF ListView 滚动问题
string description = null, string iconLocation = null)
{
if (!System.IO.Directory.Exists(directory))
{
System.IO.Directory.CreateDirectory(directory);
} string shortcutPath = Path.Combine(directory, string.Format("{0}.lnk", shortcutName));
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);//创建快捷方式对象
shortcut.TargetPath = targetPath;//指定目标路径
shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath);//设置起始位置
shortcut.WindowStyle = 1;//设置运行方式,默认为常规窗口
shortcut.Description = description;//设置备注
shortcut.Hotkey = "Ctrl+Alt+S";//热键
shortcut.IconLocation = string.IsNullOrWhiteSpace(iconLocation) ? targetPath : iconLocation;//设置图标路径
shortcut.Save();//保存快捷方式
} /// <summary>
/// 创建桌面快捷方式
/// </summary>
/// <param name="shortcutName">快捷方式名称</param>
/// <param name="targetPath">目标路径</param>
/// <param name="description">描述</param>
/// <param name="iconLocation">图标路径,格式为"可执行文件或DLL路径, 图标编号"</param>
/// <res></res>
public static void CreateShortcutOnDesktop(string shortcutName, string targetPath,
string description = null, string iconLocation = null)
{
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//获取桌面文件夹路径
CreateShortcut(desktop, shortcutName, targetPath, description, iconLocation);
}
添加com引用Windows Script Host Object Model
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(你的快捷方式路径);//创建快捷方式对象
shortcut.Hotkey = "Ctrl+Alt+T";//热键
shortcut.Save();//保存快捷方式
就.NET自带的那个。里面没有对HOTKEY的设置
就.NET自带的那个。里面没有对HOTKEY的设置这段放在哪里?自带的那个是没法写入程序的。