msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extended File Attributes

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Richard Mueller



Joined: 04 Oct 2007
Posts: 15

PostPosted: Mon Nov 06, 2006 4:38 am    Post subject: Extended File Attributes Reply with quote

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
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Mon Nov 06, 2006 1:32 pm    Post subject: Re: Extended File Attributes Reply with quote

"Richard Mueller" wrote

> I'm trying to retrieve an extended file attribute of a selected file in VB6.
> The following fails:

I used your code and made this:

Dim objShell As Object
Dim objFolder As Object
Dim objFolderItem As Object
Dim strComment As String, i As Long

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("D:\temp")
Set objFolderItem = objFolder.ParseName("data.txt")

For i = 0 To 20
strComment = objFolder.GetDetailsOf(objFolderItem, i)
Debug.Print i, strComment
Next


The output I got showed the comment was actually at index 5:

0 Data.txt
1 1 KB
2 Text Document
3 11/6/2006 8:25 AM
4 A
5 COMMENT_TEXT
6 9/19/2006 12:30 PM
7 11/6/2006 8:25 AM
8 Administrators
9
10 AUTHOR_TEXT
11 TITLE_TEXT
12 SUBJECT_TEXT
13 CATEGORY_TEXT
14
15
16
17
18
19
20


I'm running Win2K SP4....

LFS
Back to top
View user's profile Send private message
Richard Mueller



Joined: 04 Oct 2007
Posts: 15

PostPosted: Mon Nov 06, 2006 3:35 pm    Post subject: Re: Extended File Attributes Reply with quote

"Larry Serflaten" wrote:
> I used your code and made this:
>
> Dim objShell As Object
> Dim objFolder As Object
> Dim objFolderItem As Object
> Dim strComment As String, i As Long
>
> Set objShell = CreateObject("Shell.Application")
> Set objFolder = objShell.Namespace("D:\temp")
> Set objFolderItem = objFolder.ParseName("data.txt")
>
> For i = 0 To 20
> strComment = objFolder.GetDetailsOf(objFolderItem, i)
> Debug.Print i, strComment
> Next
>
>
> The output I got showed the comment was actually at index 5:
>
> 0 Data.txt
> 1 1 KB
> 2 Text Document
> 3 11/6/2006 8:25 AM
> 4 A
> 5 COMMENT_TEXT
> 6 9/19/2006 12:30 PM
> 7 11/6/2006 8:25 AM
> 8 Administrators
> 9
> 10 AUTHOR_TEXT
> 11 TITLE_TEXT
> 12 SUBJECT_TEXT
> 13 CATEGORY_TEXT
> 14
> 15
> 16
> 17
> 18
> 19
> 20
>
>
> I'm running Win2K SP4....
>
> LFS

Thanks for the reply. The good news is that you showed me I need to pass
just the filename to the ParseName method (not the full path and file name).
The bad news is that you also pointed out that the index values change
depending on the OS. On XP clients, the comment has index 14. Index 5 is
date accessed. I confirmed that on a W2k machine the comment is index 5.
This of course makes my code useless. The only fix I see is to enumerate all
extended attributes until I find the one with the name "Comments" (or
whichever I want). At least now I don't have to enumerate all items in the
folder.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Mon Nov 06, 2006 4:27 pm    Post subject: Re: Extended File Attributes Reply with quote

"Richard Mueller" wrote

> The only fix I see is to enumerate all
> extended attributes until I find the one with the name "Comments" (or
> whichever I want). At least now I don't have to enumerate all items in the
> folder.


Depending on what you want to get, you might be able to parse what
you want out of the file tip information:

msgbox GetFileTipInfo("D:\temp", "data.txt")



Private Function GetFileTipInfo(Path As Variant, File As Variant) As String
Dim shl As Object, fld As Object, itm As Object
Set shl = CreateObject("Shell.Application")
If Not shl Is Nothing Then
Set fld = shl.NameSpace(Path)
If Not fld Is Nothing Then
Set itm = fld.ParseName(File)
If Not itm Is Nothing Then
GetFileTipInfo = fld.GetDetailsOf(itm, -1)
End If
End If
End If
End Function


LFS
Back to top
View user's profile Send private message
Richard Mueller



Joined: 04 Oct 2007
Posts: 15

PostPosted: Tue Nov 07, 2006 2:07 am    Post subject: Re: Extended File Attributes Reply with quote

"Larry Serflaten" wrote in message @TK2MSFTNGP03.phx.gbl...
>
> "Richard Mueller" wrote
>
>> The only fix I see is to enumerate all
>> extended attributes until I find the one with the name "Comments" (or
>> whichever I want). At least now I don't have to enumerate all items in
>> the
>> folder.
>
>
> Depending on what you want to get, you might be able to parse what
> you want out of the file tip information:
>
> msgbox GetFileTipInfo("D:\temp", "data.txt")
>
>
>
> Private Function GetFileTipInfo(Path As Variant, File As Variant) As
> String
> Dim shl As Object, fld As Object, itm As Object
> Set shl = CreateObject("Shell.Application")
> If Not shl Is Nothing Then
> Set fld = shl.NameSpace(Path)
> If Not fld Is Nothing Then
> Set itm = fld.ParseName(File)
> If Not itm Is Nothing Then
> GetFileTipInfo = fld.GetDetailsOf(itm, -1)
> End If
> End If
> End If
> End Function
>

Thanks for the code. I have not seen that documented.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Tue Nov 07, 2006 4:32 pm    Post subject: Re: Extended File Attributes Reply with quote

"Richard Mueller" wrote


> Thanks for the code. I have not seen that documented.

Its the last item in the list of parameters (iColumn):
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/folder/getdetailsof.asp

LFS

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
VB attributes Hiya, Could you guys shed some light on VB declarations attributes? Here is the list of attributes I'd like to know the meaning of: VB_Name VB_Base VB_Control VB_Creatable VB_Exposed VB_Ext_KEY VB_HelpID V

How to set control attributes at runtime I need to set a form's properties and included controls' properties at runtime I have been unable to find out how to set properties at runtime. For example: Me.Font = New Font(Me.Font, I found this after much searching on the web. I

Howto make a Copy of File and retrieve the resulting file na Hi! I want to make copy of a file with the target destination the same as the original file and let Windows pick the filename, e.g. Copy of File.txt of Copy(2) of File.txt. This works fine, but my problem is that I am not able to get hold of the resultin

need vb help file i have the software without the help file, any Idea where I can get one Regards Medhat

.wav file in vb Hi what code do I need to run a ".wav" by vb
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group