|
-
Apr 4th, 2001, 11:43 PM
#1
Thread Starter
Frenzied Member
Is there a way to make a shortcut that
will work on win95 and win98 and winME?
-
Apr 5th, 2001, 03:18 AM
#2
-
Apr 5th, 2001, 03:39 AM
#3
Well ...
I got the following code from vbcode.com. I have not tried it myself. You can try it out.
Code:
'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following
'statement to Vb5stkit.dll. Stkit432.dll is for Visual Basic 4.0
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
'Add to Desktop
lReturn = fCreateShellLink("..\..\Desktop", _
"Shortcut to Calculator", "c:\windows\calc.exe", "")
'Add to Program Menu Group
lReturn = fCreateShellLink("", "Shortcut to Calculator", _
"c:\windows\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:\windows\calc.exe", "")
Also if you are using VB6, I think you may have to change the VB5STKIT.dll to the VB6 version VB6STKIT.dll.
.
-
Apr 5th, 2001, 03:43 AM
#4
-
Apr 5th, 2001, 04:23 AM
#5
Well ...
alex_read, I had copied various code snippets into a text file for my reference, and I posted the above code off that file, without applying my own formatting. I personally don't break lines of code unless they are way too long, and I use my IDE without any toolbox window or property window, so I can take a full view of the code.
That was an oversight or you can call it negligence. And I think you should keep up 'moaning'
As for the code, do you mean you could not get it to work even by changing the name of the STKIT file, as suggested in the code??
As I said earlier, I have not yet tested the code I posted, and intend to use it seriously in our project. So if it is not going to work, I should better start hunting for something better!
.
-
Apr 5th, 2001, 04:56 AM
#6
It's probably something I was doing I am 99% sure
that with vb5 it works, and I think I remember getting this to work once.
But, I also read that changing the file name (and a few other lines) allowed you to use it with vb6.
I spent around 2-3 hours looking into this, changing the file version & testing, but to no luck.
After ages of looking at examples, I found the above and have used this ever since to create shortcuts.
-
Apr 5th, 2001, 10:14 AM
#7
Thread Starter
Frenzied Member
Hi...
Yeah.
I got it to work. But I dont want to ship
my program with that DLL (it doesnt come
with the VB6 Runtime)
Code:
Option Explicit
Option Base 1
' Urbano DaGama ([email protected])
' Drop me a line in case you need any help on this program or
' if you liked the code. That will encourage me to create more such
' programs.
Public 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
Public Const gstrQUOTE$ = """"
'-----------------------------------------------------------
' SUB: CreateShellLink
'
' Creates (or replaces) a link in either Start>Programs or
' any of its immediate subfolders in the Windows 95 shell.
'
' IN: [strLinkPath] - full path to the target of the link
' Ex: 'c:\Program Files\My Application\MyApp.exe"
' [strLinkArguments] - command-line arguments for the link
' Ex: '-f -c "c:\Program Files\My Application\MyApp.dat" -q'
' [strLinkName] - text caption for the link
' [fLog] - Whether or not to write to the logfile (default
' is true if missing)
'
' OUT:
' The link will be created in the folder strGroupName
'-----------------------------------------------------------
'
Public Sub CreateShellLink(ByVal strLinkPath As String, _
ByVal strGroupName As String, _
ByVal strLinkArguments As String, _
ByVal strLinkName As String, _
ByVal fPrivate As Boolean, _
sParent As String, _
Optional ByVal fLog As Boolean = True)
Dim fSuccess As Boolean
Dim intMsgRet As Integer
Dim lREt As Boolean
strLinkName = strUnQuoteString(strLinkName)
strLinkPath = strUnQuoteString(strLinkPath)
If StrPtr(strLinkArguments) = 0 Then strLinkArguments = ""
lREt = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, _
fPrivate, sParent) 'the path should never be enclosed in double quotes
End Sub
Public Function strUnQuoteString(ByVal strQuotedString As String)
'
' This routine tests to see if strQuotedString is wrapped in quotation
' marks, and, if so, remove them.
'
strQuotedString = Trim$(strQuotedString)
If Mid$(strQuotedString, 1, 1) = gstrQUOTE Then
If Right$(strQuotedString, 1) = gstrQUOTE Then
'
' It's quoted. Get rid of the quotes.
'
strQuotedString = Mid$(strQuotedString, 2, Len(strQuotedString) - 2)
End If
End If
strUnQuoteString = strQuotedString
End Function
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
|