Private Declare Function fCreateShellLink Lib "VB5STKIT.DLL" (ByVal
lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath
As String, ByVal lpstrLinkArgs As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
' -> code by Raist Lin
'Create a shell link on your desktop
lngresult = fCreateShellLink("..\..\Desktop", "LINK", "C:\myfile.exe", "")
End Sub
'Source: MSDN column 'Ask Dr. GUI'
Private Declare Function fCreateShellLink Lib "vb6stkit.dll" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long
Private Sub Form_Load()
Dim strGroupName As String, strLinkName As String
Dim strLinkPath As String, strLinkArguments As String
Dim fPrivate As Boolean, sParent As String
Dim fSuccess As Boolean
strLinkName = "Shortcut to Calculator"
strLinkPath = "c:\Windows\calc.exe"
strLinkArguments = ""
fPrivate = True ' Add shortcut to desktop.
strGroupName = "..\..\Desktop"
sParent = "$(Programs)"
fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
'the path should never be enclosed in double quotes
If fSuccess Then
MsgBox "Created desktop shortcut"
Else
MsgBox "Unable to create desktop shortcut"
End If
' Add shortcut to Programs menu.
strGroupName = "$(Programs)"
sParent = "$(Programs)"
fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
'the path should never be enclosed in double quotes
If fSuccess Then
MsgBox "Created shortcut on Programs menu"
Else
MsgBox "Unable to create shortcut on Programs menu"
End If
' Add shortcut to Startup folder of Programs menu.
strGroupName = "Startup"
sParent = "$(Programs)"
fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
'the path should never be enclosed in double quotes
If fSuccess Then
MsgBox "Created shortcut in Startup folder"
Else
MsgBox "Unable to create shortcut in Startup folder"
End If
End Sub
cashman писал(а):tyomitch, а у меня напротив какие-то глюки...
из первого кода придирается к "lngresult", вероятно ее нужно изначально как-то прописать?..
Dim lngresult As Long
cashman писал(а):а во втором... создает только в "Пуск->Программы" (там появляется ярлык... а на Рабочем столе и в автозапуске НЕТ...
В чем дело не знаешь?..
jetcom писал(а):А у меня просит VB5STKIT.DLL...
И где ее брать?
Dim ws As Object
Set ws=CreateObject("WScript.Shell")
Set ws=ws.CreateShortCut(ws.SpecialFolders("Desktop"))
ws.TargetPath=app.path & "\" & app.exename & ".exe"
ws.Save
Set ws=Nothing
SpecialFolders("desktop")
SpecialFolders("desktop") & ".lnk"
И никаких всяких vb5stkit
Ой! Я ошибся!
Desktop - это объект или папка
У меня не работает, может проблема в русской винде?
Keyword Not Found - это все что мне MSDN нашла
Public Function CreateLnk(sLnkFile As String, sStartFile As String, g_sPrgFolder)
Dim sExeFile As String
Dim WshShell As Object, sDesktop As String, oShellLink As Object
Set WshShell = CreateObject("WScript.Shell")
sDesktop = WshShell.SpecialFolders("Desktop")
sExeFile = g_sPrgFolder & sStartFile
Set oShellLink = WshShell.CreateShortcut(sDesktop & "\" & sLnkFile)
oShellLink.TargetPath = g_sSrvFolder & App.EXEName & ".exe"
oShellLink.WindowStyle = 1
' oShellLink.Hotkey = ""
oShellLink.IconLocation = sExeFile & ", 0"
oShellLink.Description = Left$(sLnkFile, Len(sLnkFile) - 4)
oShellLink.WorkingDirectory = g_sSrvFolder
oShellLink.Save
End Function
Сейчас этот форум просматривают: AhrefsBot, Google-бот, Yandex-бот и гости: 148