Как получить максимальный индекс (max iColumn) метода Shell32.Folder.GetDetailsOf(vItem, iColumn)?

В настоящее время я получаю список свойств с помощью GetDetailsOf так:

using Shell32;//Add reference > .COM > Type Libraries > Microsoft Shell Controls and Automation

//....
var shell = new Shell();
var objFolder = shell.NameSpace(SS.ExeFolder);//SS.ExeFolder = this exe folder path

var arrExistCols = new List<string>();
var existCol = string.Empty;
for (var i = 0; i < short.MaxValue; ++i)
{
    existCol = objFolder.GetDetailsOf(null, i);
    if (string.IsNullOrEmpty(existCol))
        break;
    arrExistCols.Add(existCol.ToUpper());
}

Но в этот случай: индекс 163 пуст, поэтому мой код выше будет пропущен со 163 и далее.

C:\Users\lesha\Desktop\TestFolder\sample.wmv

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

Так что, может быть, я просто использую магическое число 310 для максимального индекса, но это ненадежно, что, если на другом компьютере максимальный индекс равен 320? Так есть ли способ получить максимальный индекс для GetDetailsOf?


person 123iamking    schedule 29.10.2020    source источник
comment
Конечно, я могу добавить целочисленный счетчик для обнаружения двух последовательных пустых выходов вместо одного, как я делаю сейчас, но мне все еще любопытно, есть ли API для правильного получения максимального индекса.   -  person 123iamking    schedule 29.10.2020
comment
Этот API очень ограничен и, по-видимому, не обрабатывает основную ошибку, указывающую на то, что столбец для индекса не существует. Единственное решение — использовать другой Shell API с помощью p/invoke (обычно это IColumnManager: getcolumns" rel="nofollow noreferrer">docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/) Вам нужен пример? В связи с элементами управления и автоматизации Microsoft Shell (Папка поддерживает IPersistFolder2, поэтому мы можем получить PIDL отсюда) или независимо?   -  person Simon Mourier    schedule 30.10.2020
comment
stackoverflow.com/ вопросы/22382010/   -  person Hans Passant    schedule 30.10.2020