'引用Microsoft Shell Controls And Automation
Private Sub Command1_Click()
MsgBox getfilePTY("C:\WINDOWS\notepad.exe")
End SubFunction getfilePTY(strFl As String) As String
Dim fso 'As FileSystemObject
Dim fl 'As Scripting.File
Dim pth As String
Dim flname As StringDim shl As Shell32.Shell
Dim shfd As Shell32.Folder
Dim s As String
Dim i'Set fso = New FileSystemObject
Set fso = CreateObject("scripting.filesystemobject")
Set fl = fso.GetFile(strFl)
pth = fl.ParentFolder.Path
flname = fl.NameSet shl = New Shell
Set shfd = shl.NameSpace(pth)For i = 0 To 33
If shfd.GetDetailsOf(0, i) <> "" Or shfd.GetDetailsOf(shfd.Items.Item(flname), i) <> "" Then
s = s & shfd.GetDetailsOf(0, i) & ": " & shfd.GetDetailsOf(shfd.Items.Item(flname), i) & Chr(10)
End If
Next igetfilePTY = s
End Function但是对于OFFICE文件还是有部分无法得到,不知有更好方法?
解决方案 »
- 求助解决,图片里提示错误,具体在工程包里。。。。。。。。。。。。。。。。。。。。。。。。。
- vba做的form窗体打开后,总在最前面,其他excel无法使用
- VB6用ADO连接ACCESS数据库后,在有些机器上好用有些机器上不好用,是什么原因??
- SOS怎样把form上面text控件的内容打印出来而不打form出来呢?
- 一个关于SQL的怪问题啊
- etang邮件系统支持什么认证?
- 请大家试试,google是不是不能用了??郁闷ing....
- 50分求解~~
- 谁有微软译本??给我一份好吗??千恩万谢??
- Recordset.AddNew
- 根据文本框中的条件将查询的内容显示在DataGrid控件里,数据库连接老是有问题,我是新手,请各位高手帮帮我!急(在线)
- 请问用VB6.0自带的打包程序,如果才可以在安装程序中设置自动在桌面创建快捷方式?
以下是被我改了一下的版本,好像也行。Function getfilePTY(strFl As String) As String
Dim shl As Shell, shfd As Folder, shitem As FolderItem
Dim i As Long, s As String, ts As String Set shl = New Shell
Set shfd = shl.NameSpace(strFl)
Set shitem = shfd.ParentFolder.Items.Item(shfd.Title)
Set shfd = shfd.ParentFolder
i = 0&
Do
ts = shfd.GetDetailsOf(Null, i)
If ts <> vbNullString Then _
s = s & ts & vbTab & shfd.GetDetailsOf(shitem, i) & vbNewLine _
Else Exit Do
i = i + 1&
Loop
Set shitem = Nothing
Set shfd = Nothing
Set shl = Nothing
getfilePTY = s
End Function
GetDetailsOf(Null, i)是不连续的,就是说出现“空”后,后面还有。所以你的少了好几条信息。