VB编程-读取收藏夹的文件

来源:百度知道 编辑:UC知道 时间:2024/05/13 06:59:53
哪位朋友帮个忙,如何读取收藏夹中的文件,到菜单上去。就像IE中的收藏菜单一样。收藏夹位置在注册表中的位置,我已经找到。HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders下的Favorites键值。
使用以下方法即可读取该键值中的内容,
Dim w As Object
Set w = CreateObject("wscript.shell")
MsgBox w.regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Favorites")
现在的问题是,我不会读取文件到动态菜单中,以及读取文件夹中的文件。哪位朋友会的,请帮帮忙!!!
这位朋友murphylau,你的代码测试过吗?帮我调一下吧,有一些错误,读不到收藏夹中的内容,有一些变量也没定义。

你要先在窗体上加一个菜单,下面的程序才能正确运行

窗体上先添加一个Index 为0 ,name = mnFile 的菜单

Option Explicit

Private Sub Command1_Click()
Dim regpath As String
Dim w As Object
Set w = CreateObject("wscript.shell")
regpath = w.regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Favorites")

Dim fso As Object 'FileSystemObject '

Set fso = CreateObject("scripting.filesystemobject")

If fso Is Nothing Then
MsgBox "fuck"
End If

Dim oFolder As Object ' Folder
Set oFolder = fso.GetFolder(regpath)

Dim oFile As File

'动态添加菜单
'窗体上先添加一个Index 为0 ,name = mnFile 的菜单
Dim i As Long
For i = 1 To 10
Load mnFile(i)
mnFile(i).Caption = "test" & i
Next i

'读文件并且取得url
Dim oText As Object 'TextStream
Dim sLi