Option ExplicitConst CSIDL_DESKTOP = &H0Const CSIDL_PROGRAMS = &H2
Private Type SHITEMIDcb As LongabID As ByteEnd TypePrivate Type ITEMIDLISTmkid As SHITEMIDEnd TypePrivate Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As LongPrivate Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As LongPrivate Function GetSpecialfolder(CSIDL As Long) As String
Dim lRet As Long
Dim IDL As ITEMIDLIST
Dim sPath As String
lRet = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If lRet = 0 Then
sPath = Space$(512)
lRet = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
GetSpecialfolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End FunctionPrivate Sub cmdMakeLnk_Click()Dim sProgramsPath As StringDim sDesktopPath As StringsProgramsPath = GetSpecialfolder(CSIDL_PROGRAMS)sDesktopPath = GetSpecialfolder(CSIDL_DESKTOP)txtLnk.LinkTopic = "Progman|Progman"txtLnk.LinkMode = 2
txtLnk.LinkExecute "[AddItem(""ie.exe"",""ie"" )]"前面都能正常运行   后面是将  开始\程序\ie.exe 文件剪切到桌面   可是老出错 说是找不到
文件   请高手解决sProgramsPath = sProgramsPath & "\ie.lnk"
sDesktopPath = sDesktopPath & "\ie.lnk"
FileCopy sProgramsPath, sDesktopPath
Kill sProgramsPathEnd Sub

解决方案 »

  1.   

    呵呵,还是使用 VB 自带的 COMMON\TOOLS\VB\UNSUPPRT\SHELLLNK\SHELLLNK.VBP 中的方法把,这个最好了!
      

  2.   

    我想如果你在window98中运行这段程序就不会有错,如果在win2000/xp中就会出错了。在win2000/xp中需要使用 CSIDL_COMMON_PROGRAMS 来获取开始菜单中程序组的位置才能与DDE中"Progman|Progman"的位置相对应,否则复制时找不到源文件。Private Const CSIDL_COMMON_PROGRAMS As Long = &H17