Prev: Problem installing COM+ application proxy on widows 7
Next: VB6's MSComm doesn't work well with Vista
From: Shell on 14 May 2010 22:26 In VB6 I can walk through a directory using the Dir function and get the names of the files in the directory. How do I get any comments associated with each file. Thanks -- Shell
From: GS on 14 May 2010 23:18 Shell used his keyboard to write : > In VB6 I can walk through a directory using the Dir function and get the > names of the files in the directory. How do I get any comments associated > with each file. > > Thanks You need to check NTFS file SummaryProperties. These may not exist if the file format doesn't support them OR if the file system doesn't support them. These are only supported on NTFS volumes and <AFAIK> Winx64 does not support NTFS file SummaryProperties. If the CustomDocumentProperties have been given a 'Comments' field then you can access that on the file. I suggest using a wrapper designed for this but someone else may know a way using FSO or some API function. Garry
From: Mayayana on 14 May 2010 23:41 Here's a rough sample that shows how to access Shell methods. Set a reference to Microsoft Shell Controls and Automation. Then: Private Sub Command1_Click() Dim i As Variant Dim i2 As Long, i3 As Long Dim SH As Shell Dim oFol As Folder Dim FolItems As FolderItems Dim FolItem As FolderItem Set SH = New Shell Set oFol = SH.NameSpace("C:\windows\desktop") Set FolItems = oFol.Items For i2 = 1 To FolItems.Count If FolItems.Item(i2).IsFolder = False Then For i = 0 To 34 Debug.Print oFol.GetDetailsOf(FolItems.Item(i2), i) Next i3 = i3 + 1 If i3 = 5 Then Exit For End If Next Set FolItems = Nothing Set oFol = Nothing Set SH = Nothing End Sub The code above returns info. for the first five files found in a folder. If you do GetDetailsOf(0, i) it should return the name of each file property. Comments is probably 14. You should try running it on a few systems, though. Microsoft has changed the "extended properties" at different times. Only the basic properties exist on Win9x. Some are irrelevant except on NTFS. Others are relevant only for some types of files. I'm not certain that Comments is #14 on all systems. The approach is somewhat awkward and hokey because Shell is designed for the Explorer GUI. So the methods are not file system methods. They're folder view methods. But you can use them to get what you want. | In VB6 I can walk through a directory using the Dir function and get the | names of the files in the directory. How do I get any comments associated | with each file. | | Thanks | -- | Shell
From: Mayayana on 15 May 2010 17:30
Here's another sample that might be more helpful. It lacks error trapping, etc., but is designed to return info. about a specific file. Set the Shell reference, put a textbox and button on a form, then add the code below. When running the program, enter the full path of any file into the textbox and click the button. Private Sub Command1_Click() GetComments Text1.Text End Sub Private Sub GetComments(FilePath As String) Dim i As Variant Dim i2 As Long, i3 As Long, Pt1 As Long Dim sFol As String, sFil As String, sProps As String Dim SH As Shell Dim oFol As Folder Dim FolItem As FolderItem Pt1 = InStrRev(FilePath, "\") sFol = Left$(FilePath, (Pt1 - 1)) sFil = Right$(FilePath, Len(FilePath) - Pt1) Set SH = New Shell Set oFol = SH.NameSpace(sFol) Set FolItem = oFol.ParseName(sFil) For i = 0 To 34 '-- this gets the number and name of the property: sProps = sProps & vbCrLf & CStr(i) & " - " & oFol.GetDetailsOf(0, i) '-- this gets the value of the property: sProps = sProps & ": " & oFol.GetDetailsOf(FolItem, i) '-- example line return: "1 - size: 3 KB" Next Set FolItem = Nothing Set oFol = Nothing Set SH = Nothing MsgBox sProps End Sub You can see from these samples how the methods work, but the sample code is also very inefficient. It's instantiating new objects for every file. In actual usage you'd probably want to process an entire folder at once. | In VB6 I can walk through a directory using the Dir function and get the | names of the files in the directory. How do I get any comments associated | with each file. | | Thanks | -- | Shell |