Startup Shortcut

Hey Guys, I am trying to create and delete a startup shortcut within my VB6 program.  I have these functions:

Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long

Declare Function OSfRemoveShellLink Lib "vb6stkit.dll" Alias "fRemoveShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String) As Long

but I can't figure out what to pass them in order to get them to work.  I tried to use the same parameters I used for my VB5 project but that dosn't work.  Also, do these functions work under Windows NT 4.0? Win 2K?

Thanks for any help.
RaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AnswerTheManCommented:
do you mean during installation ?
0
RaAuthor Commented:
No.  This is an option the user will be able to change during operation of the program.
0
InteqamCommented:
try to change the properties of the shortcut


it is a file too
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
Check out this microsoft article:

HOWTO: Create Shortcuts (Shell Links) within Windows
http://support.microsoft.com/support/kb/articles/Q155/3/03.asp 
 

Cheers!
0
RaAuthor Commented:
morider, that works for 4 and 5, but I was wanting to know how to use it in VB 6.  If you look at the functions above, you will see that the parameters are different and passing the same stuff you would in VB 5 does not work.
0
mcriderCommented:
OK, Try this:

Private Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long
Private Sub Command1_Click()
Dim strGroupName As String
Dim strLinkName As String
Dim strLinkPath As String
Dim strLinkArguments As String
Dim fPrivate As Long
Dim sParent As String
Dim Retcode As Long

strGroupName = "C:\WINDOWS\DESKTOP" 'DIRECTORY TO USE AS GROUP NAME
strLinkName = "Shortut to WordTime" 'TITLE OF SHORTCUT
strLinkPath = "D:\UTILITIES\WORDTIME.COM" + Chr$(0) 'PATH OF REAL FILE
strLinkArguments = Chr$(0) 'KEEP THIS AS IS
fPrivate = -1 'KEEP THIS AS IS
sParent = "C:\WINDOWS\DESKTOP" 'DIRECTORY WHERE SHORTCUT IS CREATED

Retcode = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, fPrivate, sParent)
MsgBox Retcode
End Sub


Cheers!

0
RaAuthor Commented:
I hate to tell you this, but no matter what I do it returns a code of 0.  I copied it into my project and modified the group, title, and directories to fit my project.  I also copied the code exactly into a new porject and it dosn't work there either.

I also want to put the shortcut in the current users startup folder in his start menu.  How do I do that?

Since I didn't make that part clear in my original question, thereby making the question harder, I'm increasing the points to 100.
0
RaAuthor Commented:
BTW, I forgot to mention that I already have code to find the Windows or WinNT directory that works great.  (The GetWindowsDirectory function)  I just need to kwon the person's usernam.

Thanks.
0
mcriderCommented:
Don't know what to tell you... I was able to use the code above to create a shortcut on my desktop using the vb6stkit.dll

I guess you'll have to wait for someone else...

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dtomynCommented:
I personally have been using code similar to what is found at: http://www.mvps.org/vbnet/code/shell/shshortcutcheat.htm 
Alternatively, you can try:
http://www.mvps.org/vbnet/code/shell/desktoplink.htm
0
RaAuthor Commented:
Nevermind guys, I just decied to go back and use the vb5.0 version.  It works fine.  Since mcrider gave me the best help, even though it didn't work on my system (I think I have something screwy preventing it from working), I am gonna give him the points (but he only gets a 'C').


*****
If you are looking for the details, scroll down to you see a lot of code with his name at the top.  It's under a rejected answer bar, but I couldn't find a way to unreject it or delete the quesiton.  My only option was to accept one of his comments as the answer.
*****

Thanks for trying guys.
0
mcriderCommented:
Thanks for the points...

By the way, I have VB5, but I installed the vb6stkit.dll on my system and that code worked fine...


Cheers!
0
RaAuthor Commented:
I probably just need to reinstall 6.0.  I download a lot of shareware programs and who knows what dlls have been replaced.
0
csameer1Commented:
Here is how you would add this to your setup script.You will need to edit the setup project (C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Setup1) and add the code below after appropriate user responses.Make sure you make a copy of the setup project supplied by microsoft.
________________________________________


Private Declare Function fCreateShellLink Lib "vb6stkit.dll" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long
Private Sub Command1_Click()

    Dim strGroupName As String
    Dim strLinkName As String
    Dim strLinkPath As String
    Dim strLinkArguments As String
    Dim fPrivate As Long
    Dim sParent As String

    strLinkPath = App.Path + "\" + App.EXEName + Chr(0)
    strLinkName = "Shortcut to " + App.EXEName
    strLinkArguments = "" + Chr(0)
    fPrivate = -1
    strGroupName = "..\..\start menu\programs\startup" 'for a desktop scut use "..\..\desktop"
    sParent = "$(Programs)"

    fCreateShellLink strGroupName, strLinkName, strLinkPath, strLinkArguments, fPrivate, sParent

End Sub

0
RaAuthor Commented:
Kewl!!! It works!  Thanks, casameer1.  I wish there was a way I could give you the points, but there is no way to un-accept the accepted answer, sorry.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.