[C#][VB.NET].NET捷徑(ShortCut)控制
Function GetLnkWorkingDirectory(ByVal shortCutFile As String) As String Return GetLnkObj(shortCutFile).WorkingDirectory End Function
Function GetLnkPath(ByVal shortCutFile As String) As String Return GetLnkObj(shortCutFile).Path End Function C# private String GetLnkArguments(string shortCutFile) { return GetLnkObj(shortCutFile).Arguments; }
private String GetLnkWorkingDirectory(string shortCutFile) { return GetLnkObj(shortCutFile).WorkingDirectory; }
private String GetLnkPath(string shortCutFile) { return GetLnkObj(shortCutFile).Path; } 這邊須注意的是,使用此方法建立捷徑時,若捷徑檔不存在於指定位置,則須先建立個空的捷徑檔案,才可取得ShellLinkObject物件。VB.NET If Not My.Computer.FileSystem.FileExists(shortCutFile) Then File.Create(shortCutFile).Close() End If C# if (!My.Computer.FileSystem.FileExists(shortCutFile)) { File.Create(shortCutFile).Close(); } 取得ShellLinkObject物件後,捷徑的建立與寫入也就只是設定對應的屬性值後呼叫Save方法。VB.NET lnkObj = GetLnkObj(shortCutFile) With lnkObj .Arguments = arguments .Description = description .Path = path .WorkingDirectory = workingDirectory .ShowCommand = showCommand .Save() End With C# lnkObj = GetLnkObj(shortCutFile); lnkObj.Arguments = arguments; lnkObj.Description = description; lnkObj.Path = path; lnkObj.WorkingDirectory = workingDirectory; lnkObj.ShowCommand = (int)showCommand; lnkObj.Save(null); Reference C# - Creating URL shortcut to desktop微軟技術社群討論區-請問如何建立桌面捷徑和網頁捷徑?強力鎯頭 の VB 部落-如何寫程式建立桌面捷徑 ( Shortcut )Code Project-Creating Shell Links (Shortcuts) in .NET Programs Using WSH[C#]用2种方法创建快捷方式.(Visual Studio .Net 2005) Download ShortCut.rar