'This quick routine will create a shortcut to the Desktop, The StartMenu and
the Startup folder without the use of the Windows API. The example also
shows a method of deleting the shortcuts.
Public Sub CreateShortcut()
Dim DT As Integer 'Desktop reference integer
Dim ST As Integer 'StartMenu reference integer
Dim WshShell As Object
Dim oShellLink As Object
Dim sStartMenu As String 'Container for Start Menu location
Dim sStartup As String 'Container for Startup Menu
location
Dim sDesktop As String 'Container for Desktop location
Dim sWindows As String 'Container/Identifier for OS folder
location
Set WshShell = CreateObject("WScript.Shell")
'Define the folder as StartMenu
sStartMenu = WshShell.SpecialFolders("StartMenu")
'Define the folder as Startup
sStartup = WshShell.SpecialFolders("Startup")
'Define the folder as Desktop
sDesktop = WshShell.SpecialFolders("Desktop")
'Define the location of the application
sWindows = App.Path
'Create Desktop shortcut:
' DT represents a True/False value of a checkbox to Add or Delete the
shortcut
If DT = 1 Then
Set oShellLink = WshShell.CreateShortcut(sDesktop &
"\Stickems.exe.lnk")
oShellLink.TargetPath = sWindows & "\Stickems.exe"
oShellLink.IconLocation = sWindows & "\Stickems.exe, 0"
oShellLink.Description = "Stickems shortcut"
oShellLink.WorkingDirectory = sWindows
oShellLink.Save
End If
'Create ShortCut in Start Menu.
' ST represents a True/False value of a checkbox to Add or Delete the
shortcut
If ST = 1 Then
Set oShellLink = WshShell.CreateShortcut(sStartMenu &
"\Stickems.exe.lnk")
oShellLink.TargetPath = sWindows & "\Stickems.exe"
oShellLink.IconLocation = sWindows & "\Stickems.exe, 0"
oShellLink.Description = "Stickems shortcut"
oShellLink.WorkingDirectory = sWindows
oShellLink.Save
'Create ShortCut in Startup Menu.
Set oShellLink = WshShell.CreateShortcut(sStartup &
"\Stickems.exe.lnk")
oShellLink.TargetPath = sWindows & "\Stickems.exe"
oShellLink.IconLocation = sWindows & "\Stickems.exe, 0"
oShellLink.Description = "Stickems shortcut"
oShellLink.WorkingDirectory = sWindows
oShellLink.Save
End If
Set oShellLink = Nothing
Set WshShell = Nothing
End Sub
'This Procedure will Remove the icon from your Desktop.
Public Sub Check2_Click()
On Error GoTo ErrorHandler
If Check2.Value = vbUnchecked Then
ST = 0
Kill sStartMenu & "\Stickems.exe.lnk"
Kill sStartup & "\Stickems.exe.lnk"
ShortCut = "False"
Exit Sub
End If
If Check2.Value = vbChecked Then
ST = 1
CreateShortcut
ShortCut = "True"
End If
Exit Sub
ErrorHandler:
End Sub
"Eskimo Joe" <jo*@joe.com> wrote in message
news:nEenb.42869$B_2.28773@okepread02...
I am trying to create a desktop icon using VB6. is this possible?
-p