I'm trying to retrieve an extended file attribute of a selected file in VB6.
The following fails:
=============
Dim objShell As Object
Dim objFolder As Object
Dim objFolderItem As Object
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("c:\MyFolder")
Set objFolderItem = objFolder.ParseName("c:\MyFolder\MyApp.exe")
strComment = objFolder.GetDetailsOf(objFolderItem, 14)
============
The above assigns "Comments" to the variable strComment, the name of the
attribute rather than the value. However, if I list all FolderItems in the
Folder, I can retrieve the value of this attribute for all items in the
folder as follows:
============
For Each objFolderItem In objFolder.Items
Call MsgBox("Item: " & objFolderItem.Name _
& vbCrLf & "Comment: " & objFolder.GetDetailsOf(objFolderItem, 14))
Next
==========
If I add a reference to "Microsoft Shell Controls and Automation"
(shell32.dll), I can try the following, but it yields the same result as the
first snippet:
===========
Dim objShell As Shell
Dim objFolder As Folder2
Dim objFolderItem As FolderItem
Set objShell = New Shell
Set objFolder = objShell.Namespace("c:\MyFolder")
Set objFolderItem = objFolder.ParseName("c:\MyFolder\MyApp.exe")
strComment = objFolder.GetDetailsOf(objFolderItem, 14)
================
Is there any way to retrieve the value of the extended attribute without
enumerating every file in the folder? What's odd is that it works in
VBScript.
A link to VBScript documentation:
http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_lunl.mspx?mfr=true
Other links:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/folder/parsename.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/objectmap.asp
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab -
http://www.rlmueller.net
Archived from group: microsoft>public>vb>syntax