Solved

Installation

Posted on 2000-03-11
3
181 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now