這句的意思是說從文件夾路徑里讀取到程" />
來源:北大青鳥飛迅校區(qū)|發(fā)布時間:2013-05-03 08:30:10
問題:C#創(chuàng)建桌面快捷方式的問題
問題補充:
string Path = System.Environment.GetFolderPath(Environment.SpecialFolder.Programs);
這句的意思是說從文件夾路徑里讀取到程序
然后判斷這個文件夾的目錄存不存在
若存在,那么就把這個路徑存入到桌面圖標里,如下:
if (System.IO.Directory.Exists(Path))
{
string Desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
}
我想知道我這樣理解是不是正確的??
如果是對的話,那么是不是對于桌面的快捷圖標還要有個定義?
那對于桌面的快捷圖標,在C#中是怎么定義的????
解答:
C# 創(chuàng)建桌面快捷方式 添加引用 (com->Windows Script Host Object Model) /* 說明:快捷方式創(chuàng)建時如果存在同名的快捷方式則會覆蓋之前的快捷方式 */ using IWshRuntimeLibrary; private static void CreateDesktopLnk() { string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); //得到桌面文件夾 IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(DesktopPath + "ERP系統(tǒng).lnk"); shortcut.TargetPath = @"D:softwarecmpczy.exe"; shortcut.Arguments = ""; // 參數(shù) shortcut.Description = "ERP系統(tǒng)"; shortcut.WorkingDirectory = @"D:softwarecmpc"; //程序所在文件夾,在快捷方式圖標點擊右鍵可以看到此屬性 shortcut.IconLocation = @"D:softwarecmpczy.exe,0"; //圖標 shortcut.Hotkey = "CTRL+SHIFT+Z"; //熱鍵 shortcut.WindowStyle = 1; shortcut.Save();
招生熱線: 4008-0731-86 / 0731-82186801
學校地址: 長沙市天心區(qū)團結(jié)路6號
Copyright © 2006 | 湖南大計信息科技有限公司 版權(quán)所有
湘ICP備14017520號-3