http://tips.9hao.com/liulang/article/readnews.asp-id=4593.htm这个链连打不开 我的系统是windows2000+vb6.0 "STKIT432.DLL",这个好像在vb4.0中有,我这里没有, 但我是vb6.0,vb6.0好像用"vb6stkit.dll"这个,有没有这个的用法。 我的代码如下,但是出现“内存不能为Read,然后就强制退出了。”该如何解决。Private Declare Function fCreateShellLink Lib _ "vb6stkit.dll" (ByVal Forder As String, _ ByVal ShortCutName As String, _ ByVal ExePath As String, _ ByVal Params As String) As Long
Private Sub Command1_Click()注:参数1是你要创建快捷方式的路径;参数2是你要创建的快捷方式名;参数3是 你要创建的快捷方式所指向的程序路径及程序名;参数4可设置为空串(vbNULLS tring) Dim lngRel As Long Dim strAppStart As String
尽管vb6在vb6stkit.dll提供了fCreateShellLink函数 但是其声明和fCreateShellLink不尽相同,比fCreateShellLink多了两个参数,其声明为: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用法和上面的例子相似:(相关的api函数声明自己添上)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 If fLog Then NewAction gstrKEY_SHELLLINK, gstrQUOTE & strUnQuoteString(strGroupName) & gstrQUOTE & ", " & gstrQUOTE & strUnQuoteString(strLinkName) & gstrQUOTE End If strLinkName = strUnQuoteString(strLinkName) strLinkPath = strUnQuoteString(strLinkPath)Retry: fSuccess = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, fPrivate, sParent) 'the path should never be enclosed in double quotes If fSuccess Then If fLog Then CommitAction End If Else intMsgRet = MsgError(ResolveResString(resCANTCREATEPROGRAMICON, gstrPIPE1, strLinkName), vbAbortRetryIgnore Or vbExclamation, gstrTitle) If gfNoUserInput Then intMsgRet = vbAbort End If Select Case intMsgRet Case vbAbort ExitSetup frmSetup1, gintRET_ABORT GoTo Retry Case vbRetry GoTo Retry Case vbIgnore If fLog Then AbortAction End If End Select End If End Sub
If fLog Then '请这位大侠帮帮忙,本人是位初学者,笨呀!这个看不懂,尽可能的详细点,加些注释,本人十分感激。 NewAction gstrKEY_SHELLLINK, gstrQUOTE & strUnQuoteString(strGroupName) & gstrQUOTE & ", " & gstrQUOTE & strUnQuoteString(strLinkName) & gstrQUOTE End If '这个看不懂 strLinkName = strUnQuoteString(strLinkName) strLinkPath = strUnQuoteString(strLinkPath)Retry: fSuccess = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, fPrivate, sParent) 'the path should never be enclosed in double quotes If fSuccess Then If fLog Then CommitAction '看不懂 End If Else '看不懂 intMsgRet = MsgError(ResolveResString(resCANTCREATEPROGRAMICON, gstrPIPE1, strLinkName), vbAbortRetryIgnore Or vbExclamation, gstrTitle) If gfNoUserInput Then intMsgRet = vbAbort End If Select Case intMsgRet Case vbAbort ExitSetup frmSetup1, gintRET_ABORT GoTo Retry Case vbRetry GoTo Retry Case vbIgnore If fLog Then AbortAction End If End Select End If End Sub
谢谢 programfish(努力成为程序员) 提供的例子.
参数意义: lpstrFolderName is the name of the folder you want to create the shortcut in.lpstrLinkName is the name of the shortcut you want displayed.lpstrLinkPath is the full path to the executable you want the shortcut to point to.lpstrLinkArguments is any additional command-line switches you want the shortcut to pass to the executable.fPrivate declares whether this is a private or public shortcut, for use when you have user profiles.sParent is the parent folder where the function starts looking for the folder from.
我的系统是windows2000+vb6.0
"STKIT432.DLL",这个好像在vb4.0中有,我这里没有,
但我是vb6.0,vb6.0好像用"vb6stkit.dll"这个,有没有这个的用法。
我的代码如下,但是出现“内存不能为Read,然后就强制退出了。”该如何解决。Private Declare Function fCreateShellLink Lib _
"vb6stkit.dll" (ByVal Forder As String, _
ByVal ShortCutName As String, _
ByVal ExePath As String, _
ByVal Params As String) As Long
Private Sub Command1_Click()注:参数1是你要创建快捷方式的路径;参数2是你要创建的快捷方式名;参数3是
你要创建的快捷方式所指向的程序路径及程序名;参数4可设置为空串(vbNULLS
tring) Dim lngRel As Long
Dim strAppStart As String
strAppStart = "D:\Program Files\EditPlus 2"
lngRel = fCreateShellLink(strAppStart, _
"SmxSoftWare", strAppStart & "\MySoftWare.exe", "")
End Sub下面是别人说的:
一、怎样在VB中创建一个快捷方式?
回答:这里介绍另外一种方法!只要你拥有例如“vb5stkit.dll"或者"vb6stki
t.dll"在你的系统目录下就可以了(一般来说,VB将程序打包后会自动将这个文
件包含其中,解压时也会自动解压到系统目录)
如果你有的话。即可在模块中进行如下申明:
PublicDeclareFunctionfCreateShellLinkLib"vb6stkit.dll"(ByValFor
derAsString,ByValShortCutNameAsString,ByValExePathAsString,
ByValParamsAsString)AsLong
加了之后,下面我们就来进行一个实例讲解!比如我们要在启动组中添加一个快
捷方式:
SubMain()
DimretAsLong
DimAppStartAsString
AppStart="c:\windows\StartMenu\Programs\启动"
ret=fCreateShellLink(AppStart,"电脑卫士",App.path&"\"&App.EXEN
ame,"")
Msgbox"Ihavecreatedtheshelllink!!"
EndSub
注:参数1是你要创建快捷方式的路径;参数2是你要创建的快捷方式名;参数3是
你要创建的快捷方式所指向的程序路径及程序名;参数4可设置为空串(vbNULLS
tring)
以上方法在WINDOWS98,vb5与vb6下都可以通过!但在WINDOWS95下可能没有作
用!thank you
1、在 "我的电脑\HKEY_CLASSES_ROOT\*" 下新建项 shell;
2、在 shell 下新建项 "用我的程序打开这个文件";"用我的程序打开这个文件“为要在右键菜单中添加的选项
3、在往下新建项 command,并修改其默认键值为 "Notepad.exe %1"。"Notepad.exe %1"。为用来打开的程序。
但是其声明和fCreateShellLink不尽相同,比fCreateShellLink多了两个参数,其声明为: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用法和上面的例子相似:(相关的api函数声明自己添上)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 If fLog Then
NewAction gstrKEY_SHELLLINK, gstrQUOTE & strUnQuoteString(strGroupName) & gstrQUOTE & ", " & gstrQUOTE & strUnQuoteString(strLinkName) & gstrQUOTE
End If strLinkName = strUnQuoteString(strLinkName)
strLinkPath = strUnQuoteString(strLinkPath)Retry:
fSuccess = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, fPrivate, sParent) 'the path should never be enclosed in double quotes
If fSuccess Then
If fLog Then
CommitAction
End If
Else
intMsgRet = MsgError(ResolveResString(resCANTCREATEPROGRAMICON, gstrPIPE1, strLinkName), vbAbortRetryIgnore Or vbExclamation, gstrTitle)
If gfNoUserInput Then
intMsgRet = vbAbort
End If
Select Case intMsgRet
Case vbAbort
ExitSetup frmSetup1, gintRET_ABORT
GoTo Retry
Case vbRetry
GoTo Retry
Case vbIgnore
If fLog Then
AbortAction
End If
End Select
End If
End Sub
'请这位大侠帮帮忙,本人是位初学者,笨呀!这个看不懂,尽可能的详细点,加些注释,本人十分感激。
NewAction gstrKEY_SHELLLINK, gstrQUOTE & strUnQuoteString(strGroupName) & gstrQUOTE & ", " & gstrQUOTE & strUnQuoteString(strLinkName) & gstrQUOTE
End If '这个看不懂
strLinkName = strUnQuoteString(strLinkName)
strLinkPath = strUnQuoteString(strLinkPath)Retry:
fSuccess = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, fPrivate, sParent) 'the path should never be enclosed in double quotes
If fSuccess Then
If fLog Then
CommitAction '看不懂
End If
Else
'看不懂
intMsgRet = MsgError(ResolveResString(resCANTCREATEPROGRAMICON, gstrPIPE1, strLinkName), vbAbortRetryIgnore Or vbExclamation, gstrTitle)
If gfNoUserInput Then
intMsgRet = vbAbort
End If
Select Case intMsgRet
Case vbAbort
ExitSetup frmSetup1, gintRET_ABORT
GoTo Retry
Case vbRetry
GoTo Retry
Case vbIgnore
If fLog Then
AbortAction
End If
End Select
End If
End Sub
lpstrFolderName is the name of the folder you want to create the shortcut in.lpstrLinkName is the name of the shortcut you want displayed.lpstrLinkPath is the full path to the executable you want the shortcut to point to.lpstrLinkArguments is any additional command-line switches you want the shortcut to pass to the executable.fPrivate declares whether this is a private or public shortcut, for use when you have user profiles.sParent is the parent folder where the function starts looking for the folder from.