C#创建一个文件的快捷方式 ------2002-11-6 14:44:04 您可以使用Interope,在您的项目中引入"Windows Script Host Object Model" COM library。然后运行下面的代码:using System; using System.Runtime.InteropServices; using IWshRuntimeLibrary;namespace CreateShortcutCOM { /// <summary> /// This class creates a shortcut with COM interoperability /// </summary> class ShortcutDemo { [STAThread] static void Main(string[] args) { // Get the app path and filename string app = Environment.CurrentDirectory + @"\CreateShortcutCOM.exe";try { // Create a Windows Script Host Shell class IWshShell_Class shell = new IWshShell_ClassClass(); // Define the shortcut file IWshShortcut_Class shortcut = shell.CreateShortcut(app + ".lnk") as IWshShortcut_Class; // Set all its properties shortcut.Description = "Smart sample of creating shell shortcut"; shortcut.TargetPath = app; shortcut.IconLocation = app + ",0"; // Save it shortcut.Save(); } catch(COMException ex) { Console.WriteLine(ex.Message); } } } }
Windows Script Host ? 被俺叉掉了, 呵呵 有没有别的方法?!
提供参考: Creating and Modifying Shortcutshttp://www.vbaccelerator.com/home/NET/Code/Libraries/Shell_Projects/Creating_and_Modifying_Shortcuts/article.asp
不是要制作安装程序,只是随便找个可以运行的dd,就给它在指定位置建个快捷方式。请教r3000: 是什么api函数??C#方便调用吗?
首先在工程里选择你的打包项目(如setup1)
在目标计算机上的文件系统中选择用户程序文件夹
在用户程序文件夹的右侧窗口中右键单击,选择创建新的快捷方式
在弹出的窗口中选择应用程序文件夹,点击选择‘主输出XXX‘
---->伪君子
------2002-11-6 14:44:04 您可以使用Interope,在您的项目中引入"Windows Script Host Object Model" COM library。然后运行下面的代码:using System;
using System.Runtime.InteropServices;
using IWshRuntimeLibrary;namespace CreateShortcutCOM {
/// <summary>
/// This class creates a shortcut with COM interoperability
/// </summary>
class ShortcutDemo {
[STAThread]
static void Main(string[] args) {
// Get the app path and filename
string app = Environment.CurrentDirectory + @"\CreateShortcutCOM.exe";try {
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshShortcut_Class shortcut = shell.CreateShortcut(app + ".lnk") as IWshShortcut_Class;
// Set all its properties
shortcut.Description = "Smart sample of creating shell shortcut";
shortcut.TargetPath = app;
shortcut.IconLocation = app + ",0";
// Save it
shortcut.Save();
}
catch(COMException ex) {
Console.WriteLine(ex.Message);
}
}
}
}
有没有别的方法?!
Creating and Modifying Shortcutshttp://www.vbaccelerator.com/home/NET/Code/Libraries/Shell_Projects/Creating_and_Modifying_Shortcuts/article.asp