Searching the Source Code of Adding my Program Shortcut into Start Menu
Now, I am searching the source code by C# of adding my program shortcut into Start Menu. I think its solution maybe is to modify the correct key in the registry. And I have acquired knowledge about the the class library “Microsoft.Win32” which includes some methods to handle the registry. I believe I can find the perfect sollution at last! :) Maybe.
Oops... now, I haven't get some information correlative with this issue. So, if somebody else will tell me the answer directly, even give me some source code, It is very nice! I will appreciate his or her help:)
/*Modified on October 03,2004*/
-------*******************************************************-------------------------------
ps: OK! I have found the answer already! It's great and very simple. But it make me embarrassed what I guessed before was definitely wrong. We need not handle the registry, in fact, there are some convenient methods in .Net.
There is solution as bellow:
using IWshRuntimeLibrary;
//folderType is special system folder type;
//linkName is shortcut's title which you want to add;
public bool AddShortCut(Environment.SpecialFolder folderType,string targetDir,string linkName)
{
try
{
string folder = Environment.GetFolderPath(folderType) + "\\" + linkName;
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshShortcut_Class shortcut = shell.CreateShortcut(folder + ".lnk") as IWshShortcut_Class;
shortcut.TargetPath = targetDir;
shortcut.Save();
return true;
}
catch (Exception ex)
{
return false;
}
}
If you want to add the shortcut to StartMenu's Program menu, you can invoke the AddShortCut() method like this:
AddShortCut(Environment.SpecialFolder.Programs);
分享到:
相关推荐
语言:English,日本語 在上下文菜单中添加“创建快捷方式”。 选择菜单时,此扩展名为当前网页创建Internet快捷键文件(.html)。 快捷文件将保存在下载文件夹中。
Control Panel - Create New Shortcut
How to create a shortcut to another file
7)、如果你想快速使用winmysqladmin(开机时自动运行),选择“Create ShortCut on Start Menu” 8)、测试: 进入DOS界面; 在d:\mysql\bin目录下运行mysql,进入mysql交互操作界面 输入show databases并回车,...
要创建桌面Send to -> Desktop (create shortcut) ,请右键单击exe,然后选择Send to -> Desktop (create shortcut) ,然后将桌面上的快捷方式重命名为所需的名称。Linux 从下载最新发行版,然后解压缩到您选择的...
做批处理脚本时,需要创建一些文件的快捷方式,发现没有现成好用的命令工具,编写了一个简单的工具。 Usage: createSC [-s sourcefile] [-n shortcutname] ... -o create shortcut Path. -m description. -k hotkey.
2) Right click on MC11.exe and MC11_64.exe in C:\MC11 and select "Create shortcut" 3) Place shortcuts on desktop or where you want it... 4) To install to other location, just run program and change ...
android-create-shortcut-with-params 通过代码使用参数创建快捷方式的示例。
utility that show how to create shortcut using code
命令行创建快捷方式的工具Shortcut及语法和范例 包含程序\语法说明\范例
增加了中文路径提示功能 Unity3D将程序运行日志、配置文件目录、EXE快捷方式实现一键到达。 **本帖主要解决的问题:** 1.exe同级目录一键打开log日志 2.exe同级目录一键打开streamingAssets配置目录 ...
钽服务器用于 Node.js Web 应用...发展见 $ cd tantalim-server# Register tantalim-server on your computer$ npm link$ cd ../sample-app# Create shortcut to tantalim-server$ npm link tantalim-server持续集成
CreateJS-Canvas-liqudlayout 由Toolkit for ... // shortcut to reference prototypes// library properties:lib . properties = {width : 640 ,height : 810 ,fps : 60 ,color : "#FFFFFF" ,manifest : [{ src :
private void CreateLink(string linkName, string ExeName,string Description) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(linkName); shortcut....
No need to touch the manifest, create XML files or use the shortcut manager. Just annotate the code that you want the shortcut to call. The four shortcuts above are produced by the following code: @...
vs2008 c++代码调试通过,可以通过代码创建快捷方式,可以选择并添加图标,封装成了一个函数,很好用。
能破解Prezi 1.从网上找个prezi试用版,下载后安装即可,但只有30天的试用期。...8. 在"Create Desktop Shortcut"旁键入"PreziDesktop", 点击“Create Desktop Shortcut”,桌面即有新的檔案,破解完成!
The Google Web Toolkit (GWT) is a nifty framework that Java programmers can use ... This shortcut explains how to get started with the GWT, and then demonstrates how to create a simple Ajax application.
建立一个快捷方式的代码,Create a shortcut to the code
经过系列学习,将资料找全,足以在企业中进行SVN管理。