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