DRIVER控件,或用引用Microsoft scripting runtime Dim fsoTemp as new filesystemobject dim fsoDrive as drive for each fsodrive in fsotemp.drivers debug.print fsodrive.VolumeName next
用API获得桌面等的路径,然后自己添加上去。
用API获得桌面等的路径,然后自己添加上去。
不知你是不是需要这个: Option ExplicitPrivate Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End TypeConst BIF_RETURNONLYFSDIRS = &H1Private pidl As LongPrivate Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As LongPrivate Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long Private Sub command1_Click() Dim bi As BROWSEINFO Dim r As Long Dim pidl As Long Dim path As String Dim pos As Integerbi.hOwner = Me.hWndbi.pidlRoot = 0&bi.lpszTitle = "请选择软件安装路径:"bi.ulFlags = BIF_RETURNONLYFSDIRSpidl = SHBrowseForFolder(bi)path = Space$(512) r = SHGetPathFromIDList(ByVal pidl&, ByVal path) If r Then pos = InStr(path, Chr$(0)) Text1 = Left(path, pos - 1) Else: Text1 = "" End If End Sub
1.用API获得桌面路径? 哪个API?能否给个提示? 2.然后怎么添加?
是combox..资源管理器的那个combox.. 谢谢楼上代码..
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Declare Function GetProfilesDirectory Lib "userenv.dll" Alias "GetProfilesDirectoryA" (ByVal lpProfilesDir As String, lpcchSize As Long) As LongPrivate Sub Form_Load() Dim sName As String Dim sPath As String Dim sDesk As String sName = Space$(255) GetUserName sName, 255 sName = Left$(sName, InStr(1, sName, Chr(0)) - 1) sName = Trim(sName) sPath = Space$(255) GetProfilesDirectory sPath, 255 sPath = Left$(sPath, InStr(1, sPath, Chr(0)) - 1) sPath = Trim(sPath) sDesk = sPath & "\" & sName & "\桌面" Debug.Print sDesk Me.ImageCombo1.ComboItems.Clear Me.ImageCombo1.ComboItems.Add , sDesk, "桌面", "desk", "desk" Me.ImageCombo1.ComboItems(1).Selected = True Call ImageCombo1_Click End SubPrivate Sub ImageCombo1_Click() Me.File1.Path = ImageCombo1.SelectedItem.Key End Sub '窗体上放一个IMAGECOMBO,一个FILELISTBOX,一个IMAGELIST(一个图标,关键字为desk),并绑定到IMAGECOMBO。 '////////////WIN2000 + vb6 + sp5 调试通过
我知道有Image combox control控件
Dim fsoTemp as new filesystemobject
dim fsoDrive as drive
for each fsodrive in fsotemp.drivers
debug.print fsodrive.VolumeName
next
Option ExplicitPrivate Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End TypeConst BIF_RETURNONLYFSDIRS = &H1Private pidl As LongPrivate Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As LongPrivate Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Sub command1_Click()
Dim bi As BROWSEINFO
Dim r As Long
Dim pidl As Long
Dim path As String
Dim pos As Integerbi.hOwner = Me.hWndbi.pidlRoot = 0&bi.lpszTitle = "请选择软件安装路径:"bi.ulFlags = BIF_RETURNONLYFSDIRSpidl = SHBrowseForFolder(bi)path = Space$(512)
r = SHGetPathFromIDList(ByVal pidl&, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
Text1 = Left(path, pos - 1)
Else: Text1 = ""
End If
End Sub
哪个API?能否给个提示?
2.然后怎么添加?
谢谢楼上代码..
Private Declare Function GetProfilesDirectory Lib "userenv.dll" Alias "GetProfilesDirectoryA" (ByVal lpProfilesDir As String, lpcchSize As Long) As LongPrivate Sub Form_Load()
Dim sName As String
Dim sPath As String
Dim sDesk As String
sName = Space$(255)
GetUserName sName, 255
sName = Left$(sName, InStr(1, sName, Chr(0)) - 1)
sName = Trim(sName)
sPath = Space$(255)
GetProfilesDirectory sPath, 255
sPath = Left$(sPath, InStr(1, sPath, Chr(0)) - 1)
sPath = Trim(sPath)
sDesk = sPath & "\" & sName & "\桌面"
Debug.Print sDesk
Me.ImageCombo1.ComboItems.Clear
Me.ImageCombo1.ComboItems.Add , sDesk, "桌面", "desk", "desk"
Me.ImageCombo1.ComboItems(1).Selected = True
Call ImageCombo1_Click
End SubPrivate Sub ImageCombo1_Click()
Me.File1.Path = ImageCombo1.SelectedItem.Key
End Sub
'窗体上放一个IMAGECOMBO,一个FILELISTBOX,一个IMAGELIST(一个图标,关键字为desk),并绑定到IMAGECOMBO。
'////////////WIN2000 + vb6 + sp5 调试通过
另外.执行是说路径错误.
Me.File1.Path = ImageCombo1.SelectedItem.Key===
谢谢楼上参与
我看了一下.我的那个桌面文件夹没有什么东西啊..里面是空的.
同时.这样做也并没有得到象资源管理器的那个Combox那样的效果啊...
Amoon在成都啊..你找找他..
有时候他上QQ.他据说搬家了.
你在哪里?