Shell32.Folder.GetDetailsOf(..,..)有哪些选项?(注:此为一个提问标题,无需回答)

14

我看到一些使用GetDetailsOf()的答案来获取关于shell项目的详细信息,但数字总是神奇的数字。

我查看了FolderItemGetDetailsOf文档,但没有发现有用的信息。(后者中的列表并不是所有内容。他们没有涵盖“描述”、“作者”,也没有回收站删除日期...)

是否有一种方法可以返回一个项目的可能选项?它在哪里列出?


不确定这是否有帮助 http://archive.msdn.microsoft.com/WindowsAPICodePack 你看过这个吗?https://dev59.com/J3VC5IYBdhLWcg3wqzHV - paparazzo
@Blam 虽然我想避免使用 Windows API Codepack 这个额外的依赖项,但第二个链接似乎非常有帮助。我不知道为什么在搜索时没有看到它。谢谢。 - ispiro
1
@Blam IEnumerable - ?? 我没有提到过。关于你的另一点 - 我 不想要可以使用FolderInfo检索的简单属性 - 我想要那些不能检索的属性。 - ispiro
1
语言并不重要,因为我们所谈论的功能是 Windows Shell 的 COM 接口和类的一部分。从所有语言访问它都是相同的。无论如何,Shell 扩展可以添加具有自己列的新文件夹类型。实际上,打印机文件夹、回收站等都是“只是”另一个扩展。无论如何,Windows 属性系统在此处有详细描述,包括注册新属性或请求特定属性的 shell 项的方法。 - Panagiotis Kanavos
1
@PanagiotisKanavos - 访问Shell API有许多方法,语言在某种程度上起着作用,因为1)一些Shell接口针对脚本语言(如FolderItem),而其他接口则不是(IShellFolder),2)在.NET中,您无法访问帮助编程Shell的TLB(最好的选择是Blam提到的Windows API Code Pack)。在C++中,编写Shell程序要容易得多。 - Simon Mourier
显示剩余8条评论
4个回答

30

我是偶然间发现的。如果你将null传递给GetDetailsOf,它会响应列名。例如,使用cscript执行以下JScript:

var shellapp = WScript.CreateObject("Shell.Application");
var folder = shellapp.NameSpace("D:\\");
for (var j = 0; j < 0xFFFF; j++) {
    detail = folder.GetDetailsOf(null, j);
    if (!detail) {
        break;
    }
    WScript.Echo("[" + j + "] = " + detail);
}

在我的 Windows 10 系统上,这将输出:

[0] = Name
[1] = Size
[2] = Item type
[3] = Date modified
[4] = Date created
[5] = Date accessed
[6] = Attributes
[7] = Offline status
[8] = Availability
[9] = Perceived type
[10] = Owner
[11] = Kind
[12] = Date taken
[13] = Contributing artists
[14] = Album
[15] = Year
[16] = Genre
[17] = Conductors
[18] = Tags
[19] = Rating
[20] = Authors
[21] = Title
[22] = Subject
[23] = Categories
[24] = Comments
[25] = Copyright
[26] = #
[27] = Length
[28] = Bit rate
[29] = Protected
[30] = Camera model
[31] = Dimensions
[32] = Camera maker
[33] = Company
[34] = File description
[35] = Program name
[36] = Duration
[37] = Is online
[38] = Is recurring
[39] = Location
[40] = Optional attendee addresses
[41] = Optional attendees
[42] = Organizer address
[43] = Organizer name
[44] = Reminder time
[45] = Required attendee addresses
[46] = Required attendees
[47] = Resources
[48] = Meeting status
[49] = Free/busy status
[50] = Total size
[51] = Account name

这与Windows 2000截然不同,详见检索扩展文件属性。顺便说一下,如果您传递一个不同的NameSpace,您将获得不同的属性。在我的示例中,我正在查询驱动器D:上的文件可用属性,这可能因其格式而异。


11

我进行了Windows 10测试,收集了超过300个数据列。

PowerShell代码:

$objFolder = (New-Object -ComObject Shell.Application).Namespace('c:\')
for ($columnNumber = 0; $columnNumber -lt 500; ++$columnNumber) 
{ 
    $columnName = $objFolder.GetDetailsOf($objFolder.Items, $columnNumber) 
    if ($columnName)
    {
        Write-Output "$(([string]$columnNumber).PadLeft(3)) $columnName"
    }
}

英文列名:

  0 Name
  1 Size
  2 Item type
  3 Date modified
  4 Date created
  5 Date accessed
  6 Attributes
  7 Offline status
  8 Availability
  9 Perceived type
 10 Owner
 11 Kind
 12 Date taken
 13 Contributing artists
 14 Album
 15 Year
 16 Genre
 17 Conductors
 18 Tags
 19 Rating
 20 Authors
 21 Title
 22 Subject
 23 Categories
 24 Comments
 25 Copyright
 26 #
 27 Length
 28 Bit rate
 29 Protected
 30 Camera model
 31 Dimensions
 32 Camera maker
 33 Company
 34 File description
 35 Masters keywords
 36 Masters keywords
 42 Program name
 43 Duration
 44 Is online
 45 Is recurring
 46 Location
 47 Optional attendee addresses
 48 Optional attendees
 49 Organizer address
 50 Organizer name
 51 Reminder time
 52 Required attendee addresses
 53 Required attendees
 54 Resources
 55 Meeting status
 56 Free/busy status
 57 Total size
 58 Account name
 60 Task status
 61 Computer
 62 Anniversary
 63 Assistant's name
 64 Assistant's phone
 65 Birthday
 66 Business address
 67 Business city
 68 Business country/region
 69 Business P.O. box
 70 Business postal code
 71 Business state or province
 72 Business street
 73 Business fax
 74 Business home page
 75 Business phone
 76 Callback number
 77 Car phone
 78 Children
 79 Company main phone
 80 Department
 81 E-mail address
 82 E-mail2
 83 E-mail3
 84 E-mail list
 85 E-mail display name
 86 File as
 87 First name
 88 Full name
 89 Gender
 90 Given name
 91 Hobbies
 92 Home address
 93 Home city
 94 Home country/region
 95 Home P.O. box
 96 Home postal code
 97 Home state or province
 98 Home street
 99 Home fax
100 Home phone
101 IM addresses
102 Initials
103 Job title
104 Label
105 Last name
106 Mailing address
107 Middle name
108 Cell phone
109 Nickname
110 Office location
111 Other address
112 Other city
113 Other country/region
114 Other P.O. box
115 Other postal code
116 Other state or province
117 Other street
118 Pager
119 Personal title
120 City
121 Country/region
122 P.O. box
123 Postal code
124 State or province
125 Street
126 Primary e-mail
127 Primary phone
128 Profession
129 Spouse/Partner
130 Suffix
131 TTY/TTD phone
132 Telex
133 Webpage
134 Content status
135 Content type
136 Date acquired
137 Date archived
138 Date completed
139 Device category
140 Connected
141 Discovery method
142 Friendly name
143 Local computer
144 Manufacturer
145 Model
146 Paired
147 Classification
148 Status
149 Status
150 Client ID
151 Contributors
152 Content created
153 Last printed
154 Date last saved
155 Division
156 Document ID
157 Pages
158 Slides
159 Total editing time
160 Word count
161 Due date
162 End date
163 File count
164 File extension
165 Filename
166 File version
167 Flag color
168 Flag status
169 Space free
172 Group
173 Sharing type
174 Bit depth
175 Horizontal resolution
176 Width
177 Vertical resolution
178 Height
179 Importance
180 Is attachment
181 Is deleted
182 Encryption status
183 Has flag
184 Is completed
185 Incomplete
186 Read status
187 Shared
188 Creators
189 Date
190 Folder name
191 Folder path
192 Folder
193 Participants
194 Path
195 By location
196 Type
197 Contact names
198 Entry type
199 Language
200 Date visited
201 Description
202 Link status
203 Link target
204 URL
208 Media created
209 Date released
210 Encoded by
211 Episode number
212 Producers
213 Publisher
214 Season number
215 Subtitle
216 User web URL
217 Writers
219 Attachments
220 Bcc addresses
221 Bcc
222 Cc addresses
223 Cc
224 Conversation ID
225 Date received
226 Date sent
227 From addresses
228 From
229 Has attachments
230 Sender address
231 Sender name
232 Store
233 To addresses
234 To do title
235 To
236 Mileage
237 Album artist
238 Sort album artist
239 Album ID
240 Sort album
241 Sort contributing artists
242 Beats-per-minute
243 Composers
244 Sort composer
245 Disc
246 Initial key
247 Part of a compilation
248 Mood
249 Part of set
250 Period
251 Color
252 Parental rating
253 Parental rating reason
254 Space used
255 EXIF version
256 Event
257 Exposure bias
258 Exposure program
259 Exposure time
260 F-stop
261 Flash mode
262 Focal length
263 35mm focal length
264 ISO speed
265 Lens maker
266 Lens model
267 Light source
268 Max aperture
269 Metering mode
270 Orientation
271 People
272 Program mode
273 Saturation
274 Subject distance
275 White balance
276 Priority
277 Project
278 Channel number
279 Episode name
280 Closed captioning
281 Rerun
282 SAP
283 Broadcast date
284 Program description
285 Recording time
286 Station call sign
287 Station name
288 Summary
289 Snippets
290 Auto summary
291 Relevance
292 File ownership
293 Sensitivity
294 Shared with
295 Sharing status
297 Product name
298 Product version
299 Support link
300 Source
301 Start date
302 Sharing
303 Availability status
304 Status
305 Billing information
306 Complete
307 Task owner
308 Sort title
309 Total file size
310 Legal trademarks
311 Video compression
312 Directors
313 Data rate
314 Frame height
315 Frame rate
316 Frame width
317 Spherical
318 Stereo
319 Video orientation
320 Total bitrate

2
一个VBA函数可以完成这项工作。 需要使用Microsoft Scripting Runtime和Microsoft Shell Controls And Automation。
Function Propriétés(Chemin As String, Fichier As String)
    'Chemin représente le chemin du dossier où se trouve le fichier MP3
    'Fichier représente le nom du fichier mp3 avec l'extension
    Dim Shl As New Shell32.Shell
    Dim Rep As Shell32.Folder
    Dim fich As Shell32.FolderItem

    Dim aPropName() As String, i As Integer
    Set Shl = CreateObject("Shell.Application")
    Set Rep = Shl.Namespace(Chemin)
    Set fich = Rep.Items.Item(Fichier)
    For i = 0 To 1000
        ReDim Preserve aPropName(i)
        aPropName(i) = Format(i, "000 : ") & Rep.GetDetailsOf(Null, i)
        If Len(Rep.GetDetailsOf(Null, i)) = 0 Then
            ReDim Preserve aPropName(i - 1)
            Exit For
        End If
    Next
    ' Create ouput file
    Dim Fso, MyFile
    Set Fso = CreateObject("Scripting.FileSystemObject")
    Set MyFile = Fso.CreateTextFile(Chemin & "\Prop Liste - " & Fichier & ".txt", True)
    MyFile.Write Join(aPropName, Chr(13))
    MyFile.Close
    Set Fso = Nothing
    Set MyFile = Nothing
    Propriétés = aPropName

    Set Shl = Nothing
    Set Rep = Nothing
    Set fich = Nothing
End Function

欢迎来到 Stack Overflow!通常情况下,如果答案包括代码预期执行的功能以及解决问题的原因并且不会引入其他问题,那么它们就更有帮助。 - Tim Diekmann

0

太好了,这个Get-Metadataflags让我得到了文件版本的索引,并避免了本地化问题,因为在PT-BR中它将是“Versão do Arquivo”,这很难以编程方式检索。这使我从Technet Get-FileMetadata(https://gallery.technet.microsoft.com/scriptcenter/Get-FileMetaData-3a7ddea7)派生出另一个函数,并通过找到它的索引(对于PT-BR为166),我想出了这个返回文件版本字符串的函数:

Function Get-FileVersion
{ 
    <# 
    .SYNOPSIS 
        Get-FileVersion returns metadata version information about a single file. 

    .DESCRIPTION 
        This function will return file version (or another specific attribute based on index) information about a specific file.
        It can be used to access the information stored in the filesystem. 
        Based on: Get-FileMetadata https://gallery.technet.microsoft.com/scriptcenter/Get-FileMetaData-3a7ddea7
        and Get-FileMetadataFlags https://dev59.com/vWEh5IYBdhLWcg3wdjTt#62279888
                
    .EXAMPLE 
        Get-FileVersion -File "c:\temp\image.jpg" 
        Get information about an image file. 
    #> 

    param([Parameter(Mandatory=$True)][string]$File = $(throw "Parameter -File is required.")) 

    $index = 166 #File version index (PT-BR) from Get-FileMetadataFlags (see description)

    if(!(Test-Path -Path $File)) 
    { 
        throw "File does not exist: $File" 
        Exit 1 
    } 

    $tmp = Get-ChildItem $File 
    $pathname = $tmp.DirectoryName 
    $filename = $tmp.Name 

    $shellobj = New-Object -ComObject Shell.Application 
    $folderobj = $shellobj.namespace($pathname) 
    $fileobj = $folderobj.parsename($filename) 
    
    if($folderobj.getDetailsOf($folderobj, $index) -and $folderobj.getDetailsOf($fileobj, $index))  
    { 
        $results = $($folderobj.getDetailsOf($fileobj, $index))
    } 
     
    $results 
} #function Get-FileVersion

干杯!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接