Какие параметры доступны для Shell32.Folder.GetDetailsOf(..,..)?
Я видел ответы, используя GetDetailsOf()
чтобы получить подробную информацию об элементах оболочки, но числа всегда являются магическими числами.
Я посмотрел документы для FolderItem и GetDetailsOf, но ничего не нашел. (Список в последнем не для всех. Они не охватывают "Описание", "Авторы", ни дату удаления корзины...)
Есть ли какой-нибудь метод, который вернет возможные варианты для элемента? Это где-то указано?
4 ответа
Я понял это случайно. Если вы пройдете null
в GetDetailsOf
затем он отвечает именами столбцов. Например, выполните следующий JScript с cscript
:
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:
который может быть различным в зависимости от его формата.
На win10 намного больше флагов. Код в основном скопирован из ответа Нилса (но в Powershell):
function Get-FileMetaDataFlags {
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.namespace("C:\Windows")
for ($j = 0; $j -le 0xFFFF; $j++) {
$detail = $objFolder.GetDetailsOf("explorer.exe", $j);
if (!$detail) {
continue;
}
Write-Host "[$j] = $detail";
}
}
приводит к: (названия переведены с немецкого, будьте осторожны)
[0] = name
[1] = size
[2] = element type
[3] = modification date
[4] = creation date
[5] = Last access
[6] = attributes
[7] = offline status
[8] = availability
[9] = recognized type
[10] = owner
[11] = Art
[12] = date of recording
[13] = Contributing artists
[14] = album
[15] = year
[16] = genre
[17] = conductors
[18] = markings
[19] = evaluation
[20] = authors
[21] = title
[22] = subject
[23] = categories
[24] = comments
[25] = Copyright
[26] = track number
[27] = length
[28] = bit rate
[29] = Protected
[30] = camera model
[31] = dimensions
[32] = camera manufacturer
[33] = company
[34] = file description
[35] = master keywords
[36] = master keywords
[42] = program name
[43] = duration
[44] = Is online
[45] = recurring
[46] = location
[47] = addresses of the optional participants
[48] = Optional participants
[49] = organizer address
[50] = organizer name
[51] = reminder time
[52] = addresses of the required participants
[53] = Required participants
[54] = resources
[55] = meeting status
[56] = Status free / occupied
[57] = total size
[58] = account name
[60] = task status
[61] = computer
[62] = anniversary
[63] = Name of the assistant
[64] = Telephone number of the assistant
[65] = birthday
[66] = business address
[67] = location (business)
[68] = country / region (business)
[69] = PO Box (business)
[70] = postcode (business)
[71] = state / canton (business)
[72] = street (business)
[73] = Fax (business)
[74] = Homepage (business)
[75] = phone number (business)
[76] = callback number
[77] = car phone
[78] = children
[79] = Central company number
[80] = department
[81] = email address
[82] = Email2
[83] = Email3
[84] = email list
[85] = Email display name
[86] = Save as
[87] = first name
[88] = Full name
[89] = gender
[90] = given name
[91] = Hobbies
[92] = home address
[93] = location (private)
[94] = country / region (private)
[95] = PO Box (private)
[96] = postcode (private)
[97] = state / canton (private)
[98] = street (private)
[99] = fax (private)
[100] = phone number (private)
[101] = addresses for chats
[102] = initials
[103] = position
[104] = designation
[105] = last name
[106] = address
[107] = middle name
[108] = mobile phone
[109] = nickname
[110] = office location
[111] = Additional address
[112] = Other city
[113] = Other country / region
[114] = Another mailbox
[115] = Other postcode
[116] = Other federal state or canton
[117] = Other street
[118] = pager
[119] = personal title
[120] = city
[121] = country / region
[122] = mailbox
[123] = post code
[124] = state / canton
[125] = street
[126] = Primary email
[127] = Primary phone number
[128] = occupation
[129] = spouse / partner
[130] = suffix
[131] = TTY / TTD phone
[132] = Telex
[133] = website
[134] = content status
[135] = content type
[136] = acquisition date
[137] = archiving date
[138] = completion date
[139] = device category
[140] = connection established
[141] = detection method
[142] = display name
[143] = Local computer
[144] = manufacturer
[145] = model
[146] = Coupled
[147] = classification
[148] = status
[149] = device status
[150] = client ID
[151] = contributors
[152] = Content created
[153] = Last printed
[154] = Last saved
[155] = main department
[156] = document ID
[157] = pages
[158] = foils
[159] = total processing time
[160] = number of words
[161] = Due on
[162] = end date
[163] = number of files
[164] = file extension
[165] = file name
[166] = file version
[167] = identification color
[168] = labeling status
[169] = Free space
[172] = group
[173] = release type
[174] = bit depth
[175] = Horizontal resolution
[176] = width
[177] = Vertical resolution
[178] = height
[179] = importance
[180] = plant?
[181] = Is deleted
[182] = encryption status
[183] = identification available
[184] = Has ended
[185] = Incomplete
[186] = reading status
[187] = Released
[188] = Creator
[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] = Last visit
[201] = description
[202] = link status
[203] = Link target
[204] = URL
[208] = Medium created
[209] = release date
[210] = Coded by
[211] = sequence number
[212] = producers
[213] = publisher
[214] = season number
[215] = subtitles
[216] = User web url
[217] = copywriter
[219] = attachments
[220] = BCC addresses
[221] = BCC
[222] = CC addresses
[223] = CC
[224] = Entertainment ID
[225] = date of receipt
[226] = date of dispatch
[227] = From addresses
[228] = From
[229] = Has attachments
[230] = sender address
[231] = sender name
[232] = memory
[233] = recipient addresses
[234] = working title
[235] = An
[236] = term
[237] = album artist
[238] = Sorting by album artist
[239] = album id
[240] = Sort by album
[241] = Sorting by contributing artists
[242] = beats per minute
[243] = composers
[244] = Sorted by composer
[245] = disc
[246] = Original key
[247] = Part of a compilation
[248] = mood
[249] = part of a sentence
[250] = period
[251] = color
[252] = protection of minors
[253] = Reason for protection of minors
[254] = Storage space used
[255] = EXIF version
[256] = event
[257] = light value
[258] = exposure program
[259] = exposure time
[260] = f-number
[261] = flash mode
[262] = focal length
[263] = 35mm focal length
[264] = ISO film speed
[265] = lens manufacturer
[266] = lens model
[267] = light source
[268] = maximum aperture
[269] = measurement mode
[270] = alignment
[271] = contacts
[272] = program mode
[273] = saturation
[274] = distance
[275] = white balance
[276] = priority
[277] = project
[278] = channel
[279] = sequence name
[280] = closed captions
[281] = repetition
[282] = two-channel sound
[283] = date of shipment
[284] = program description
[285] = recording time
[286] = transmitter call sign
[287] = TV station name
[288] = summary
[289] = snippet
[290] = Automatic summary
[291] = relevance
[292] = File ownership
[293] = sensitivity
[294] = Approved for
[295] = approval status
[297] = product name
[298] = product version
[299] = support link
[300] = source
[301] = start date
[302] = Is divided
[303] = availability status
[304] = status
[305] = billing information
[306] = Completed
[307] = task owner
[308] = Sort by title
[309] = total file size
[310] = brands
[311] = video compression
[312] = directors
[313] = data rate
[314] = image height
[315] = frame rate
[316] = image width
[317] = spherical
[318] = stereo
[319] = video alignment
[320] = total bit rate
Функция VBA делает работу. Необходима среда выполнения сценариев Microsoft, элементы управления и автоматизация Microsoft Shell
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
Отлично, этот Get-Metadataflags позволил мне получить индекс для версии файла и избежать проблем с локализацией, поскольку в PT-BR это было бы «Versão do Arquivo», которое ужасно извлекать программно. Это привело меня к тому, что я получил еще одну функцию от Technet Get-FileMetadata (https://gallery.technet.microsoft.com/scriptcenter/Get-FileMetaData-3a7ddea7) и, найдя ее индекс (166 для PT-BR), я придумал с этой функцией, которая возвращает версию файла в виде строки:
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://stackoverflow.com/questions/22382010/what-options-are-available-for-shell32-folder-getdetailsof/62279888#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
Ваше здоровье!