Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Installation

Posted on 2000-03-11
3
Medium Priority
?
198 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 150 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

971 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