|
-
Jun 26th, 2000, 02:44 AM
#1
Thread Starter
Junior Member
Ok, so I have this code to create a shortcut:
Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
'Usage:
fCreateShellLink "C:\windows\Desktop", "Link to my program", "C:\Path\Program.exe", ""
Now, I want the program to create the shortcut when I run the setup. How do I do that? Tell me NOW!!!!
-
Jun 26th, 2000, 03:02 AM
#2
Code:
Public Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String) As Long
Public Sub makeshortcut(strshortcutdir As String, strshortcutname As String, strshortcutpath As String)
On Error Resume Next
Dim strwinshortcutdir As String, strwinshortcutname As String, strwinshortcutexepath As String, lngretval As Long
Let strwinshortcutdir$ = strshortcutdir$
Let strwinshortcutname$ = strshortcutname$
Let strwinshortcutexepath$ = strshortcutpath$
Let lngretval& = fCreateShellLink("", strwinshortcutname$, strwinshortcutexepath$, "")
Name "c:\windows\start menu\programs\" & strwinshortcutname$ & ".lnk" As strwinshortcutdir$ & "\" & strwinshortcutname$ & ".lnk"
End Sub
Call makeshortcut("C:\Windows\Start Menu\Programs\Startup\","MyProgram","C:\apps\program.exe")
-
Jun 26th, 2000, 03:05 AM
#3
Thread Starter
Junior Member
But I'm saying though, where do I call the function? If I call it during a form load, won't it make the shortcut every time I run the program or load the form?
-
Jun 26th, 2000, 04:19 AM
#4
transcendental analytic
If dir(strshortcutdir)="" then makeshorcut...
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 26th, 2000, 06:13 AM
#5
Code:
Public Function fileexists(strfilepathandname As String) As Boolean
On Error Resume Next
Dim lngcheck As Long
If InStr(strfilepathandname$, ".") = 0& Then
Let fileexists = False
End If
Let lngcheck& = Len(Dir$(strfilepathandname$))
If lngcheck& = 0& Then
Let fileexists = False
Exit Function
Else
Let fileexists = True
End If
Exit Function
End Function
If not fileexists("C:\Windows\Start Menu\Programs\Startup\program.lnk") Then Call makeshortcut("C:\Windows\Start Menu\Programs\Startup\","MyProgram","C:\apps\program.exe")
-
Jun 26th, 2000, 06:46 AM
#6
transcendental analytic
Mathew, why do you use Let? also it's a lot code for checking a file existance, why do you need the "." to be in the filè?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 26th, 2000, 06:18 PM
#7
Thread Starter
Junior Member
Thanks for all your help. I'll have to mess around with this a little bit.
-
Jun 27th, 2000, 01:52 AM
#8
I dunno Kedaman..it's just a code I use. I feel comfortable with it. It works, doesn't it? As long as it works, its good. But I guess your way is a shorter way.
-
Jun 27th, 2000, 03:04 AM
#9
transcendental analytic
Well Let is a obsolete keyword, "." don't exist in all files, but you might return a file of you mention a dir.
Yeah it works but dir(path)<>"" is a much shorter and faster way
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 27th, 2000, 03:13 AM
#10
Thread Starter
Junior Member
BTW, I tried both today and neither works in my program.
I called the Function from a form load... I dunno' but I think I'm just gonna create a shortcut and distribute separately... thanks anywayz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|