Results 1 to 10 of 10

Thread: how do I use this....

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Angry

    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!!!!

  2. #2
    Guest
    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")

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Unhappy

    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?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  5. #5
    Guest
    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")

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Talking

    Thanks for all your help. I'll have to mess around with this a little bit.

  8. #8
    Guest
    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.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Smile

    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
  •  



Click Here to Expand Forum to Full Width