Snippets I'd like:
Add a desktop shortcut of a program.
[php] Public Function CreateShortcut(ByVal sLinkFile As String, _
ByVal sTargetFile As String, _
Optional ByVal sArguments As String = "", _
Optional ByVal sDescription As String = "", _
Optional ByVal sWorkingDir As String = "") As Boolean
Try
Dim oShell As New Shell32.Shell
Dim oFolder As Shell32.Folder
Dim oLink As Shell32.ShellLinkObject
Dim sPath As String = sLinkFile.Substring(0, sLinkFile.LastIndexOf("\"))
Dim sFile As String = sLinkFile.Substring(sLinkFile.LastIndexOf("\") + 1)
Dim F As Short = FreeFile()
FileOpen(F, sLinkFile, OpenMode.Output)
FileClose(F)
oFolder = oShell.NameSpace(sPath)
oLink = oFolder.Items.Item(sFile).GetLink
' Eigenschaften der Verknüpfung
With oLink
If sArguments.Length > 0 Then .Arguments = sArguments
If sDescription.Length > 0 Then .Description = sDescription
If sWorkingDir.Length > 0 Then .WorkingDirectory = sWorkingDir
.Path = sTargetFile
.Save()
End With
oLink = Nothing
oFolder = Nothing
oShell = Nothing
Return True
Catch ex As Exception
If System.IO.File.Exists(sLinkFile) Then Kill(sLinkFile)
Return False
End Try
End Function
[/php]
[php] Dim desk As String = Environment.GetFolderPath(Environment.SpecialFolde r.Desktop)
Try
CreateShortcut(IO.Path.Combine(desk, "NameOfShortcut.lnk"), Application.ExecutablePath)
Catch ex As Exception
End Try
End Sub[/php]