Option Explicit
Private Declare Function VB4CreateShellLink Lib "STKIT432.DLL" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
Private Declare Function VB5CreateShellLink Lib "VB5STKIT.DLL" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
Private Declare Function VB6CreateShellLink Lib "VB6STKIT.DLL" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String, ByVal fPrivate As Long, ByVal sParent As String) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Enum VersioneVB
VisualBasicUnknown = 0
VisualBasic4 = 4
VisualBasic5 = 5
VisualBasic6 = 6
End Enum
Private AppPath As String
Private Function CreateShellLink(ByVal intVersione As VersioneVB, ByVal strGruppo As String, ByVal strTitolo As String, ByVal strPath As String) As Boolean
Dim intConta As Integer
Dim lngRis As Long
On Error GoTo Err_Handler
If intVersione = VisualBasicUnknown Then
For intConta = 4 To 6
lngRis = LoadLibrary(Choose(intConta - 3, "STKIT432", "VB5STKIT", "VB6STKIT"))
Call FreeLibrary(lngRis)
If lngRis <> 0 Then intVersione = intConta
Next intConta
End If
lngRis = 0
If intVersione = VisualBasic6 Then
lngRis = VB6CreateShellLink(strGruppo, strTitolo, strPath, "", True, "$(Programs)")
ElseIf intVersione = VisualBasic5 Then
lngRis = VB5CreateShellLink(strGruppo, strTitolo, strPath, "")
ElseIf intVersione = VisualBasic4 Then
lngRis = VB4CreateShellLink(strGruppo, strTitolo, strPath, "")
End If
CreateShellLink = CBool(lngRis)
Exit Function
Err_Handler:
CreateShellLink = False
End Function