Solved

Installation

Posted on 2000-03-11
3
186 Views
Last Modified: 2010-05-02
How to place a shortcut for my .exe in the desktop automatically ,when user runs the setup program ?. ( The setup program created by using application setup wizard vb 5.0 is not creating the shortcut in the desktop.)
0
Comment
Question by:iqubal
  • 2
3 Comments
 
LVL 2

Expert Comment

by:johnny6
ID: 2607748
iqubal:
     Determine which one suits you best:
http://www.thescarms.com/VBasic/ShellLnk.htm 
or Start a new project in Visual Basic. Form1 is created by default.
Add a Command button (Command1) to Form1.
Add the following code to the General Declarations section of Form1:

Option Explicit
'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following
'statement to Vb5stkit.dll.

Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal _
lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal _
lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long

Sub Command1_Click()
Dim lReturn As Long
'Add to Desktop
lReturn = fCreateShellLink("..\..\Desktop", _
"Shortcut to Calculator", "c:\Winnt\system32\calc.exe", "")
'Add to Program Menu Group
lReturn = fCreateShellLink("", "Shortcut to Calculator", _
"c:\Winnt\system32\calc.exe", "")
'Add to Startup Group
'Note that on Windows NT, the shortcut will not actually appear
'in the Startup group until your next reboot.
lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", _
"c:\Winnt\system32\calc.exe", "")
End Sub

Press the F5 key to run the project, and then click the Command button.

Or
http://www.thescarms.com/VBasic/Shortcuts.htm 

John
0
 
LVL 2

Accepted Solution

by:
johnny6 earned 50 total points
ID: 2607754
iqubal:
      Here is another way to do it:

'create a shortcut to a file and place it on desktop
'
Option Explicit
'
Private Declare Function SHGetSpecialFolderLocation Lib _
"Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, _
ppidl As Long) As Long

Private Declare Function SHGetPathFromIDList Lib "Shell32" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath _
As String) As Long

Private Const MAX_PATH = 260

Public Function GetDesktopFolderPath(ByVal pHwnd As Long) _
As String

Dim lReturn&
Dim lPidl&
Dim strPath$
strPath$ = Space(MAX_PATH)
lReturn& = SHGetSpecialFolderLocation(pHwnd, 0, lPidl)

' Get lPidl& for this Id...
If lReturn = 0 Then
lReturn = SHGetPathFromIDList(lPidl, strPath)
' Get Path from Item Id List
If lReturn = 1 Then 'If successeful
GetDesktopFolderPath = Left(strPath$, _
InStr(strPath$, vbNullChar) - 1)

End If
End If
End Function
'
'====================put this in form load =======================
'
Dim strDesktop$
strDesktop = GetDesktopFolderPath(Me.hWnd)
Dim strMyfile$
strMyfile = InputBox("Enter the path and name of file, & vbcrlf" _
& "you want to create a shortcut for.")
Dim strShortCutName$
strShortCutName$ = InputBox _
("Enter the name for the shortcut icon")

FileCopy strMyfile$, strDesktop$ & "\" & strShortCutName$

John
0
 

Author Comment

by:iqubal
ID: 2609508
Thank you for the answer Mr. John.
But I was thinking that there must a provision in the setup.lst file which is generated by the Seup Wizard. If there is any way like that Please intimate me.
Thanks again

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question