[SHELL32]
[reactos.git] / dll / win32 / shell32 / wine / pidl.h
1 /*
2 * internal pidl functions
3 *
4 * Copyright 1998 Juergen Schmied
5 * Copyright 2004 Juan Lang
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * NOTES:
22 *
23 * DO NOT use these definitions outside the shell32.dll!
24 *
25 * The contents of a pidl should never be used directly from an application.
26 *
27 * Undocumented:
28 * MS says: the abID of SHITEMID should be treated as binary data and not
29 * be interpreted by applications. Applies to everyone but MS itself.
30 * Word95 interprets the contents of abID (Filesize/Date) so we have to go
31 * for binary compatibility here.
32 */
33
34 #ifndef __WINE_PIDL_H
35 #define __WINE_PIDL_H
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /*
42 * the pidl does cache fileattributes to speed up SHGetAttributes when
43 * displaying a big number of files.
44 *
45 * a pidl of NULL means the desktop
46 *
47 * The structure of the pidl seems to be a union. The first byte of the
48 * PIDLDATA describes the type of pidl.
49 *
50 * object ! first byte / ! format ! living space
51 * ! size
52 * ----------------------------------------------------------------
53 * my computer 0x1F/20 guid (2) (usual)
54 * network 0x1F guid
55 * bitbucket 0x1F guid
56 * drive 0x23/25 drive (usual)
57 * drive 0x25/25 drive (lnk/persistent)
58 * drive 0x29/25 drive
59 * shell extension 0x2E guid
60 * drive 0x2F drive (lnk/persistent)
61 * folder/file 0x30 folder/file (1) (lnk/persistent)
62 * folder 0x31 folder (usual)
63 * valueA 0x32 file (ANSI file name)
64 * valueW 0x34 file (Unicode file name)
65 * workgroup 0x41 network (3)
66 * computer 0x42 network (4)
67 * net provider 0x46 network
68 * whole network 0x47 network (5)
69 * MSITStore 0x61 htmlhlp (7)
70 * printers/ras connections 0x70 guid
71 * history/favorites 0xb1 file
72 * share 0xc3 network (6)
73 *
74 * guess: the persistent elements are non tracking
75 *
76 * (1) dummy byte is used, attributes are empty
77 * (2) IID_MyComputer = 20D04FE0L-3AEA-1069-A2D8-08002B30309D
78 * (3) two strings "workgroup" "Microsoft Network"
79 * (4) two strings "\\sirius" "Microsoft Network"
80 * (5) one string "Entire Network"
81 * (6) two strings "\\sirius\c" "Microsoft Network"
82 * (7) contains string "mk:@MSITStore:C:\path\file.chm::/path/filename.htm"
83 * GUID 871C5380-42A0-1069-A2EA-08002B30309D
84 */
85
86 #define PT_CPLAPPLET 0x00
87 #define PT_GUID 0x1F
88 #define PT_DRIVE 0x23
89 #define PT_DRIVE2 0x25
90 #define PT_DRIVE3 0x29
91 #define PT_SHELLEXT 0x2E
92 #define PT_DRIVE1 0x2F
93 #define PT_FOLDER1 0x30
94 #define PT_FOLDER 0x31
95 #define PT_VALUE 0x32
96 #define PT_VALUEW 0x34
97 #define PT_WORKGRP 0x41
98 #define PT_COMP 0x42
99 #define PT_NETPROVIDER 0x46
100 #define PT_NETWORK 0x47
101 #define PT_IESPECIAL1 0x61
102 #define PT_YAGUID 0x70 /* yet another guid.. */
103 #define PT_CPEXT 0x71
104 #define PT_IESPECIAL2 0xb1
105 #define PT_SHARE 0xc3
106
107 #include "pshpack1.h"
108 typedef BYTE PIDLTYPE;
109
110 typedef struct tagPIDLCPanelStruct
111 {
112 BYTE dummy; /*01 is 0x00 */
113 DWORD iconIdx; /*02 negative icon ID */
114 WORD offsDispName; /*06*/
115 WORD offsComment; /*08*/
116 CHAR szName[1]; /*10*/ /* terminated by 0x00, followed by display name and comment string */
117 } PIDLCPanelStruct;
118
119 typedef struct tagPIDLFontStruct
120 {
121 BYTE dummy;
122 WORD offsFile;
123 WCHAR szName[1];
124 } PIDLFontStruct;
125
126 typedef struct tagPIDLPrinterStruct
127 {
128 BYTE dummy;
129 DWORD Attributes;
130 WORD offsServer;
131 WCHAR szName[1];
132 } PIDLPrinterStruct;
133
134 typedef struct tagPIDLRecycleStruct
135 {
136 FILETIME LastModification;
137 FILETIME DeletionTime;
138 ULARGE_INTEGER FileSize;
139 ULARGE_INTEGER PhysicalFileSize;
140 DWORD Attributes;
141 WCHAR szName[1];
142 } PIDLRecycleStruct;
143
144 typedef struct tagGUIDStruct
145 {
146 BYTE dummy; /* offset 01 is unknown */
147 GUID guid; /* offset 02 */
148 } GUIDStruct;
149
150 typedef struct tagDriveStruct
151 {
152 CHAR szDriveName[20]; /*01*/
153 WORD unknown; /*21*/
154 } DriveStruct;
155
156 typedef struct tagFileStruct
157 {
158 BYTE dummy; /*01 is 0x00 for files or dirs */
159 DWORD dwFileSize; /*02*/
160 WORD uFileDate; /*06*/
161 WORD uFileTime; /*08*/
162 WORD uFileAttribs; /*10*/
163 CHAR szNames[1]; /*12*/
164 /* Here are coming two strings. The first is the long name.
165 The second the dos name when needed or just 0x00 */
166 } FileStruct;
167
168 /* At least on WinXP, this struct is appended with 2-byte-alignment to FileStruct. There follows
169 * a WORD member after the wszName string, which gives the offset from the beginning of the PIDL
170 * to the FileStructW member. */
171 typedef struct tagFileStructW {
172 WORD cbLen;
173 BYTE dummy1[6];
174 WORD uCreationDate;
175 WORD uCreationTime;
176 WORD uLastAccessDate;
177 WORD uLastAccessTime;
178 BYTE dummy2[4];
179 WCHAR wszName[1];
180 } FileStructW;
181
182 typedef struct tagValueW
183 {
184 WCHAR name[1];
185 } ValueWStruct;
186
187 typedef struct tagPIDLDATA
188 { PIDLTYPE type; /*00*/
189 union
190 {
191 struct tagGUIDStruct guid;
192 struct tagDriveStruct drive;
193 struct tagFileStruct file;
194 struct
195 { WORD dummy; /*01*/
196 CHAR szNames[1]; /*03*/
197 } network;
198 struct
199 { WORD dummy; /*01*/
200 DWORD dummy1; /*02*/
201 CHAR szName[1]; /*06*/ /* terminated by 0x00 0x00 */
202 } htmlhelp;
203 struct tagPIDLCPanelStruct cpanel;
204 struct tagValueW valueW;
205 struct tagPIDLFontStruct cfont;
206 struct tagPIDLPrinterStruct cprinter;
207 struct tagPIDLRecycleStruct crecycle;
208 }u;
209 } PIDLDATA, *LPPIDLDATA;
210 #include "poppack.h"
211
212 /*
213 * getting special values from simple pidls
214 */
215 DWORD _ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
216 DWORD _ILSimpleGetTextW (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize);
217 BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
218 DWORD _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
219 BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
220 void _ILGetFileType (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
221 DWORD _ILGetFileAttributes (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
222
223 BOOL _ILGetFileDateTime (LPCITEMIDLIST pidl, FILETIME *ft);
224 DWORD _ILGetDrive (LPCITEMIDLIST, LPSTR, UINT);
225
226 /*
227 * testing simple pidls
228 */
229 BOOL _ILIsUnicode (LPCITEMIDLIST pidl);
230 BOOL _ILIsDesktop (LPCITEMIDLIST pidl);
231 BOOL _ILIsMyComputer (LPCITEMIDLIST pidl);
232 BOOL _ILIsPrinter (LPCITEMIDLIST pidl);
233 BOOL _ILIsMyDocuments (LPCITEMIDLIST pidl);
234 BOOL _ILIsControlPanel (LPCITEMIDLIST pidl);
235 BOOL _ILIsBitBucket (LPCITEMIDLIST pidl);
236 BOOL _ILIsAdminTools (LPCITEMIDLIST pidl);
237 BOOL _ILIsNetHood (LPCITEMIDLIST pidl);
238 BOOL _ILIsDrive (LPCITEMIDLIST pidl);
239 BOOL _ILIsFolder (LPCITEMIDLIST pidl);
240 BOOL _ILIsValue (LPCITEMIDLIST pidl);
241 BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl);
242 BOOL _ILIsPidlSimple (LPCITEMIDLIST pidl);
243 BOOL _ILIsCPanelStruct (LPCITEMIDLIST pidl);
244 static __inline
245 BOOL _ILIsEqualSimple (LPCITEMIDLIST pidlA, LPCITEMIDLIST pidlB)
246 {
247 return (pidlA->mkid.cb > 0 && !memcmp(pidlA, pidlB, pidlA->mkid.cb)) ||
248 (!pidlA->mkid.cb && !pidlB->mkid.cb);
249 }
250 static __inline
251 BOOL _ILIsEmpty (LPCITEMIDLIST pidl) { return _ILIsDesktop(pidl); }
252
253 /*
254 * simple pidls
255 */
256
257 /* Creates a PIDL with guid format and type type, which must be one of PT_GUID,
258 * PT_SHELLEXT, or PT_YAGUID.
259 */
260 LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid);
261
262 /* Like _ILCreateGuid, but using the string szGUID. */
263 LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID);
264 LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID);
265
266 /* Commonly used PIDLs representing file system objects. */
267 LPITEMIDLIST _ILCreateDesktop (void);
268 LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *stffile);
269 HRESULT _ILCreateFromPathW (LPCWSTR szPath, LPITEMIDLIST* ppidl);
270
271 /* Other helpers */
272 LPITEMIDLIST _ILCreateMyComputer (void);
273 LPITEMIDLIST _ILCreateMyDocuments (void);
274 LPITEMIDLIST _ILCreateIExplore (void);
275 LPITEMIDLIST _ILCreateControlPanel (void);
276 LPITEMIDLIST _ILCreatePrinters (void);
277 LPITEMIDLIST _ILCreateNetwork (void);
278 LPITEMIDLIST _ILCreateNetHood (void);
279 LPITEMIDLIST _ILCreateAdminTools (void);
280 LPITEMIDLIST _ILCreateFont (void);
281 LPITEMIDLIST _ILCreateBitBucket (void);
282 LPITEMIDLIST _ILCreateDrive (LPCWSTR);
283
284 /*
285 * helper functions (getting struct-pointer)
286 */
287 LPPIDLDATA _ILGetDataPointer (LPCITEMIDLIST);
288 LPSTR _ILGetTextPointer (LPCITEMIDLIST);
289 IID *_ILGetGUIDPointer (LPCITEMIDLIST pidl);
290 FileStructW *_ILGetFileStructW (LPCITEMIDLIST pidl);
291
292 /*
293 * debug helper
294 */
295 void pdump (LPCITEMIDLIST pidl);
296 BOOL pcheck (LPCITEMIDLIST pidl);
297
298 /*
299 * aPidl helper
300 */
301 void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl);
302 LPITEMIDLIST * _ILCopyaPidl(const LPCITEMIDLIST * apidlsrc, UINT cidl);
303 LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, const CIDA * cida);
304
305 BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);
306
307 #ifdef __cplusplus
308 } /* extern "C" */
309 #endif
310
311 #endif /* __WINE_PIDL_H */