Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 7th, 2005, 6:57 PM   #1
killcity44
Newbie
 
Join Date: Feb 2005
Posts: 18
Rep Power: 0 killcity44 is on a distinguished road
i need an application to create a shortcut to itself

Hi, ive made an application and I want it to create a shortcut to itself in the start menu's startup folder so it will run on startup. he filename of the app will be the same as it will be compiled as an exe. e.g. if the file was in c:/downloads/app.exe, then a shortcut would be made pointing to c:/downloads/app.exe, but say it was in c:/program files/other folders/downloads/app.exe then the shortcut would point there. I have found a method of creating a shortcut to a defined location but as the app will be in different directories on different machines, this wont work. all i need is a way of entering in the apps own location. ive tried this so far

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

Dim lReturn As Long

obviously this part is under an event

lReturn = fCreateShellLink("\Startup", "title of app", _
"\appname.exe", "")

this just points the shortcut to the c:/appname.exe

thanks
killcity44 is offline   Reply With Quote
Old Jul 8th, 2005, 7:33 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Well, if you add this function somewhere:

' Ensures hString ends in hSuffix

Public Function eSuffix(ByVal hString As String, ByVal hSuffix As String) As String
    If StrComp(Right(hString, Len(hSuffix)), hSuffix, vbTextCompare) Then
        eSuffix = hString & hSuffix
    Else
        eSuffix = hString
    End If
End Function

Then the containing folder of the application is guaranteed to be:
eSuffix(App.Path, "\")
The filename:
eSuffix(App.EXEName, ".exe")
And so the full path is obviously:
eSuffix(App.Path, "\") & eSuffix(App.EXEName, ".exe")

How are you checking to see if the shortcut already exists?
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC