2 * internal pidl functions
4 * Copyright 1998 Juergen Schmied
5 * Copyright 2004 Juan Lang
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.
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.
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
23 * DO NOT use this definitions outside the shell32.dll !
25 * The contents of a pidl should never used from a application
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.
46 * the pidl does cache fileattributes to speed up SHGetAttributes when
47 * displaying a big number of files.
49 * a pidl of NULL means the desktop
51 * The structure of the pidl seems to be a union. The first byte of the
52 * PIDLDATA describes the type of pidl.
54 * object ! first byte / ! format ! living space
56 * ----------------------------------------------------------------
57 * my computer 0x1F/20 guid (2) (usual)
60 * drive 0x23/25 drive (usual)
61 * drive 0x25/25 drive (lnk/persistent)
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)
78 * guess: the persistent elements are non tracking
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
90 #define PT_CPLAPPLET 0x00
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
100 #define PT_VALUEW 0x34
101 #define PT_FOLDERW 0x35
102 #define PT_WORKGRP 0x41
104 #define PT_NETPROVIDER 0x46
105 #define PT_NETWORK 0x47
106 #define PT_IESPECIAL1 0x61
107 #define PT_YAGUID 0x70 /* yet another guid.. */
108 #define PT_IESPECIAL2 0xb1
109 #define PT_SHARE 0xc3
111 #include "pshpack1.h"
112 typedef BYTE PIDLTYPE;
114 typedef struct tagPIDLCPanelStruct
116 BYTE dummy; /*01 is 0x00 */
117 DWORD iconIdx; /*02 negative icon ID */
118 WORD offsDispName; /*06*/
119 WORD offsComment; /*08*/
120 CHAR szName[1]; /*10*/ /* terminated by 0x00, followed by display name and comment string */
123 typedef struct tagGUIDStruct
125 BYTE dummy; /* offset 01 is unknown */
126 GUID guid; /* offset 02 */
129 typedef struct tagDriveStruct
131 CHAR szDriveName[20]; /*01*/
135 typedef struct tagFileStruct
137 BYTE dummy; /*01 is 0x00 for files or dirs */
138 DWORD dwFileSize; /*02*/
139 WORD uFileDate; /*06*/
140 WORD uFileTime; /*08*/
141 WORD uFileAttribs; /*10*/
142 CHAR szNames[1]; /*12*/
143 /* Here are coming two strings. The first is the long name.
144 The second the dos name when needed or just 0x00 */
147 /* At least on WinXP, this struct is appended with 2-byte-alignment to FileStruct. There follows
148 * a WORD member after the wszName string, which gives the offset from the beginning of the PIDL
149 * to the FileStructW member. */
150 typedef struct tagFileStructW {
155 WORD uLastAccessDate;
156 WORD uLastAccessTime;
161 typedef struct tagValueW
166 typedef struct tagPIDLDATA
167 { PIDLTYPE type; /*00*/
170 struct tagGUIDStruct guid;
171 struct tagDriveStruct drive;
172 struct tagFileStruct file;
175 CHAR szNames[1]; /*03*/
180 CHAR szName[1]; /*06*/ /* terminated by 0x00 0x00 */
182 struct tagPIDLCPanelStruct cpanel;
183 struct tagValueW valueW;
185 } PIDLDATA, *LPPIDLDATA;
189 * getting special values from simple pidls
191 DWORD _ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
192 DWORD _ILSimpleGetTextW (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize);
193 BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
194 DWORD _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
195 BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
196 void _ILGetFileType (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
197 DWORD _ILGetFileAttributes (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
199 BOOL _ILGetFileDateTime (LPCITEMIDLIST pidl, FILETIME *ft);
200 DWORD _ILGetDrive (LPCITEMIDLIST, LPSTR, UINT);
203 * testing simple pidls
205 BOOL _ILIsUnicode (LPCITEMIDLIST pidl);
206 BOOL _ILIsDesktop (LPCITEMIDLIST pidl);
207 BOOL _ILIsMyComputer (LPCITEMIDLIST pidl);
208 BOOL _ILIsDrive (LPCITEMIDLIST pidl);
209 BOOL _ILIsFolder (LPCITEMIDLIST pidl);
210 BOOL _ILIsValue (LPCITEMIDLIST pidl);
211 BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl);
212 BOOL _ILIsPidlSimple (LPCITEMIDLIST pidl);
213 BOOL _ILIsCPanelStruct (LPCITEMIDLIST pidl);
215 BOOL _ILIsEqualSimple (LPCITEMIDLIST pidlA, LPCITEMIDLIST pidlB)
217 return (pidlA->mkid.cb > 0 && !memcmp(pidlA, pidlB, pidlA->mkid.cb)) ||
218 (!pidlA->mkid.cb && !pidlB->mkid.cb);
221 BOOL _ILIsEmpty (LPCITEMIDLIST pidl) { return _ILIsDesktop(pidl); }
227 /* Creates a PIDL with guid format and type type, which must be one of PT_GUID,
228 * PT_SHELLEXT, or PT_YAGUID.
230 LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid);
232 /* Like _ILCreateGuid, but using the string szGUID. */
233 LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID);
234 LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID);
236 /* Commonly used PIDLs representing file system objects. */
237 LPITEMIDLIST _ILCreateDesktop (void);
238 LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *stffile);
239 HRESULT _ILCreateFromPathW (LPCWSTR szPath, LPITEMIDLIST* ppidl);
242 LPITEMIDLIST _ILCreateMyComputer (void);
243 LPITEMIDLIST _ILCreateMyDocuments (void);
244 LPITEMIDLIST _ILCreateIExplore (void);
245 LPITEMIDLIST _ILCreateControlPanel (void);
246 LPITEMIDLIST _ILCreatePrinters (void);
247 LPITEMIDLIST _ILCreateNetwork (void);
248 LPITEMIDLIST _ILCreateNetHood (void);
249 LPITEMIDLIST _ILCreateBitBucket (void);
250 LPITEMIDLIST _ILCreateDrive (LPCWSTR);
251 LPITEMIDLIST _ILCreateEntireNetwork (void);
254 * helper functions (getting struct-pointer)
256 LPPIDLDATA _ILGetDataPointer (LPCITEMIDLIST);
257 LPSTR _ILGetTextPointer (LPCITEMIDLIST);
258 IID *_ILGetGUIDPointer (LPCITEMIDLIST pidl);
259 FileStructW *_ILGetFileStructW (LPCITEMIDLIST pidl);
264 void pdump (LPCITEMIDLIST pidl);
265 BOOL pcheck (LPCITEMIDLIST pidl);
270 void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl);
271 LPITEMIDLIST * _ILCopyaPidl(const LPCITEMIDLIST * apidlsrc, UINT cidl);
272 LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, const CIDA * cida);
274 BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);