通过编程创建快捷方式 [英] create shortcut through programatically

查看:97
本文介绍了通过编程创建快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在下面写了创建快捷方式的代码。它在我运行程序时正在工作。但在创建setup.i安装后。之后,当我打开应用程序时,它给了我例外。我该怎么办请帮帮我。为什么我得到那个例外。



Hello,
I wrote below code for creating shortcut. it is working when I run the program. but after creating setup.i installed setup. after that when I open the application it is giving me exception. what should I do please help me.why I am getting that exception.

try
   {
       string s5 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
       WshShellClass shell = new WshShellClass();
       IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(s5 + "\\cater.lnk");
       shortcut.TargetPath = Application.ExecutablePath;
        shortcut.Description = "Any Description here ";

       shortcut.Save();
   }
   catch (Exception ex)
   {
       MessageBox.Show(ex.Message);
   }

推荐答案

你好,

这是因为你还没有添加设置文件中的
Hello ,
this happens because you have not added
IWshShortcut dll 

。每次创建设置时都必须添加此dll。并确保这些DLL必须保留在bin文件夹中。



谢谢

in your set up file .you have to add this dll whenever you create the set up . and ensure that these dll must remain in your bin folder .

thanks


这篇关于通过编程创建快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆