| 新建智能设备CAB项目,就可以直接创建特殊的目录下创建快捷方式,但是并没有象桌面安装包程序一样可以,在桌面上创建一个快捷方式。怎样用代码在Windows Mobile桌面上创建一个快捷方式呢?我开始也尝试用像创建Windows应用程序一样在桌面上创建一个快捷方式,但是在Windows Mobile上根本不行。经过研究和Windows快捷方式创建,发现快捷方式其实就是创建一个特定的lnk文件,在这个文件中写入一定的代码,在点击时就能自动运行。
而Windows Mobile 中怎么样创建快捷方式的呢?复制一个Windows Mobile中的一个快捷方式,然后把它拖到记事本中你就会发现它的结构组成了。
如:37#"\Windows\桌面\PDA.exe.lnk"这是我拖拽一个快捷方式到记事本中出现的
看到里这个就很简单,比创建Windows 快捷方式简单多了。
Code参考:
///<summary>
///创建快捷方式
///</summary>
///<param name="ExePath">exe程序所在路径</param>
///<param name="where">快捷方式的路径</param>
public static void CreateShortcut(string ExePath,string where)
{ try
{
if (!System.IO.File.Exists(where))
{
System.IO.StreamWriter objWriter = System.IO.File.CreateText(where);
objWriter.WriteLine(string.Format("37#""{0}""", ExePath));
objWriter.Close();
}
}
finally
{
where = null;
ExePath = null;
} }
string where = @"\Windows\桌面\PDA.exe.lnk";
string ExePath=Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
CreateShortcut(ExePath,where); |