pidl.h 8.66 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2
/*
 * internal pidl functions
3 4
 *
 * Copyright 1998 Juergen Schmied
5
 * Copyright 2004 Juan Lang
6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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:
Alexandre Julliard's avatar
Alexandre Julliard committed
22 23 24 25
 *
 * DO NOT use this definitions outside the shell32.dll !
 *
 * The contents of a pidl should never used from a application
26
 * directly.
Alexandre Julliard's avatar
Alexandre Julliard committed
27
 *
28 29 30 31 32
 * Undocumented:
 * MS says: the abID of SHITEMID should be treated as binary data and not
 * be interpreted by applications. Applies to everyone but MS itself.
 * Word95 interprets the contents of abID (Filesize/Date) so we have to go
 * for binary compatibility here.
Alexandre Julliard's avatar
Alexandre Julliard committed
33
 */
34

Alexandre Julliard's avatar
Alexandre Julliard committed
35 36
#ifndef __WINE_PIDL_H
#define __WINE_PIDL_H
37

38 39 40 41 42
#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
43 44
#include "shlobj.h"

45
/*
Alexandre Julliard's avatar
Alexandre Julliard committed
46 47 48 49 50
* the pidl does cache fileattributes to speed up SHGetAttributes when
* displaying a big number of files.
*
* a pidl of NULL means the desktop
*
51
* The structure of the pidl seems to be a union. The first byte of the
Alexandre Julliard's avatar
Alexandre Julliard committed
52 53
* PIDLDATA desribes the type of pidl.
*
Juergen Schmied's avatar
Juergen Schmied committed
54 55
*	object        ! first byte /  ! format       ! living space
*	              ! size
56
*	----------------------------------------------------------------
57 58 59
*	my computer	0x1F/20		guid (2)	(usual)
*	network		0x1F		guid
*	bitbucket	0x1F		guid
Juergen Schmied's avatar
Juergen Schmied committed
60
*	drive		0x23/25		drive		(usual)
61
*	drive		0x25/25		drive		(lnk/persistent)
Juergen Schmied's avatar
Juergen Schmied committed
62
*	drive		0x29/25		drive
63
*	shell extension	0x2E		guid
64 65
*	drive		0x2F		drive		(lnk/persistent)
*	folder/file	0x30		folder/file (1)	(lnk/persistent)
66
*	folder		0x31		folder		(usual)
67 68
*	valueA		0x32		file		(ANSI file name) 
*	valueW		0x34		file		(Unicode file name)
69 70
*	workgroup	0x41		network (3)
*	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
Juergen Schmied's avatar
Juergen Schmied committed
75
*	history/favorites 0xb1		file
76
*	share		0xc3		network (6)
77
*
78
* guess: the persistent elements are non tracking
79 80 81
*
* (1) dummy byte is used, attributes are empty
* (2) IID_MyComputer = 20D04FE0L-3AEA-1069-A2D8-08002B30309D
Juan Lang's avatar
Juan Lang committed
82 83 84 85
* (3) two strings	"workgroup" "Microsoft Network"
* (4) two strings	"\\sirius" "Microsoft Network"
* (5) one string	"Entire Network"
* (6) two strings	"\\sirius\c" "Microsoft Network"
86 87
* (7) contains string   "mk:@MSITStore:C:\path\file.chm::/path/filename.htm"
*		GUID	871C5380-42A0-1069-A2EA-08002B30309D
Alexandre Julliard's avatar
Alexandre Julliard committed
88 89
*/

90
#define PT_CPLAPPLET	0x00
91
#define PT_GUID		0x1F
92
#define PT_DRIVE	0x23
Juergen Schmied's avatar
Juergen Schmied committed
93 94
#define PT_DRIVE2	0x25
#define PT_DRIVE3	0x29
95
#define PT_SHELLEXT	0x2E
96 97
#define PT_DRIVE1	0x2F
#define PT_FOLDER1	0x30
98
#define PT_FOLDER	0x31
99
#define PT_VALUE	0x32
Huw Davies's avatar
Huw Davies committed
100
#define PT_VALUEW       0x34
101 102
#define PT_WORKGRP	0x41
#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
Alexandre Julliard's avatar
Alexandre Julliard committed
109

110
#include "pshpack1.h"
111 112
typedef BYTE PIDLTYPE;

113 114 115 116 117 118 119 120 121
typedef struct tagPIDLCPanelStruct
{ 
    BYTE dummy;			/*01 is 0x00 */
    DWORD iconIdx;		/*02 negative icon ID */
    WORD offsDispName;		/*06*/
    WORD offsComment;		/*08*/
    CHAR szName[1];		/*10*/ /* terminated by 0x00, followed by display name and comment string */
} PIDLCPanelStruct;

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
typedef struct tagGUIDStruct
{
    BYTE dummy; /* offset 01 is unknown */
    GUID guid;  /* offset 02 */
} GUIDStruct;

typedef struct tagDriveStruct
{
    CHAR szDriveName[20];	/*01*/
    WORD unknown;		/*21*/
} DriveStruct;

typedef struct tagFileStruct
{
    BYTE dummy;			/*01 is 0x00 for files or dirs */
    DWORD dwFileSize;		/*02*/
    WORD uFileDate;		/*06*/
    WORD uFileTime;		/*08*/
    WORD uFileAttribs;		/*10*/
    CHAR szNames[1];		/*12*/
    /* Here are coming two strings. The first is the long name.
    The second the dos name when needed or just 0x00 */
} FileStruct;

146 147 148 149 150 151 152 153 154 155 156 157 158 159
/* At least on WinXP, this struct is appended with 2-byte-alignment to FileStruct. There follows 
 * a WORD member after the wszName string, which gives the offset from the beginning of the PIDL 
 * to the FileStructW member. */
typedef struct tagFileStructW {
    WORD cbLen;
    BYTE dummy1[6];
    WORD uCreationDate;
    WORD uCreationTime;
    WORD uLastAccessDate;
    WORD uLastAccessTime;
    BYTE dummy2[4];
    WCHAR wszName[1];
} FileStructW;

Huw Davies's avatar
Huw Davies committed
160 161 162 163 164
typedef struct tagValueW
{
    WCHAR name[1];
} ValueWStruct;

165
typedef struct tagPIDLDATA
166
{	PIDLTYPE type;			/*00*/
Alexandre Julliard's avatar
Alexandre Julliard committed
167
	union
168 169 170 171
	{
	  struct tagGUIDStruct guid;
	  struct tagDriveStruct drive;
	  struct tagFileStruct file;
172 173 174 175
	  struct
	  { WORD dummy;		/*01*/
	    CHAR szNames[1];	/*03*/
	  } network;
176 177 178
	  struct
	  { WORD dummy;		/*01*/
	    DWORD dummy1;	/*02*/
179
	    CHAR szName[1];	/*06*/ /* terminated by 0x00 0x00 */
180
	  } htmlhelp;
181
	  struct tagPIDLCPanelStruct cpanel;
Huw Davies's avatar
Huw Davies committed
182
          struct tagValueW valueW;
Alexandre Julliard's avatar
Alexandre Julliard committed
183
	}u;
184
} PIDLDATA, *LPPIDLDATA;
185
#include "poppack.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
186

187 188 189
/*
 * getting special values from simple pidls
 */
190
DWORD	_ILSimpleGetText	(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
191
DWORD	_ILSimpleGetTextW	(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize);
192 193 194 195
BOOL	_ILGetFileDate 		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
DWORD	_ILGetFileSize		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
BOOL	_ILGetExtension		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
void	_ILGetFileType		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
196
DWORD	_ILGetFileAttributes	(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize);
197

198
BOOL	_ILGetFileDateTime	(LPCITEMIDLIST pidl, FILETIME *ft);
199
DWORD	_ILGetDrive		(LPCITEMIDLIST, LPSTR, UINT);
200 201 202 203

/*
 * testing simple pidls
 */
204 205 206 207 208 209 210
BOOL	_ILIsDesktop		(LPCITEMIDLIST pidl);
BOOL	_ILIsMyComputer		(LPCITEMIDLIST pidl);
BOOL	_ILIsDrive		(LPCITEMIDLIST pidl);
BOOL	_ILIsFolder		(LPCITEMIDLIST pidl);
BOOL	_ILIsValue		(LPCITEMIDLIST pidl);
BOOL	_ILIsSpecialFolder	(LPCITEMIDLIST pidl);
BOOL	_ILIsPidlSimple		(LPCITEMIDLIST pidl);
211
BOOL	_ILIsCPanelStruct	(LPCITEMIDLIST pidl);
212 213 214 215 216 217 218 219
static inline 
BOOL    _ILIsEqualSimple        (LPCITEMIDLIST pidlA, LPCITEMIDLIST pidlB)
{
    return (pidlA->mkid.cb > 0 && !memcmp(pidlA, pidlB, pidlA->mkid.cb)) ||
            (!pidlA->mkid.cb && !pidlB->mkid.cb);
}
static inline
BOOL    _ILIsEmpty              (LPCITEMIDLIST pidl) { return _ILIsDesktop(pidl); }
Alexandre Julliard's avatar
Alexandre Julliard committed
220

221
/*
222
 * simple pidls
223
 */
224

225 226 227 228 229
/* Basic PIDL constructor.  Allocates size + 5 bytes, where:
 * - two bytes are SHITEMID.cb
 * - one byte is PIDLDATA.type
 * - two bytes are the NULL PIDL terminator
 * Sets type of the returned PIDL to type.
230
 */
Mike McCormack's avatar
Mike McCormack committed
231
LPITEMIDLIST	_ILAlloc(PIDLTYPE type, unsigned int size);
232

233 234
/* Creates a PIDL with guid format and type type, which must be one of PT_GUID,
 * PT_SHELLEXT, or PT_YAGUID.
235 236 237 238 239
 */
LPITEMIDLIST	_ILCreateGuid(PIDLTYPE type, REFIID guid);

/* Like _ILCreateGuid, but using the string szGUID. */
LPITEMIDLIST	_ILCreateGuidFromStrA(LPCSTR szGUID);
240
LPITEMIDLIST	_ILCreateGuidFromStrW(LPCWSTR szGUID);
241 242

/* Commonly used PIDLs representing file system objects. */
243
LPITEMIDLIST	_ILCreateDesktop	(void);
244
LPITEMIDLIST	_ILCreateFromFindDataA(WIN32_FIND_DATAA *stffile);
245
LPITEMIDLIST	_ILCreateFromFindDataW(WIN32_FIND_DATAW *stffile);
246
HRESULT		_ILCreateFromPathA	(LPCSTR szPath, LPITEMIDLIST* ppidl);
247
HRESULT		_ILCreateFromPathW	(LPCWSTR szPath, LPITEMIDLIST* ppidl);
248 249

/* Other helpers */
250
LPITEMIDLIST	_ILCreateMyComputer	(void);
251
LPITEMIDLIST	_ILCreateMyDocuments	(void);
252
LPITEMIDLIST	_ILCreateIExplore	(void);
Juan Lang's avatar
Juan Lang committed
253 254
LPITEMIDLIST	_ILCreateControlPanel	(void);
LPITEMIDLIST	_ILCreatePrinters	(void);
255 256
LPITEMIDLIST	_ILCreateNetwork	(void);
LPITEMIDLIST	_ILCreateBitBucket	(void);
257
LPITEMIDLIST	_ILCreateDrive		(LPCWSTR);
258 259 260 261

/*
 * helper functions (getting struct-pointer)
 */
262
LPPIDLDATA	_ILGetDataPointer	(LPCITEMIDLIST);
263 264
LPSTR		_ILGetTextPointer	(LPCITEMIDLIST);
LPSTR		_ILGetSTextPointer	(LPCITEMIDLIST);
265
IID		*_ILGetGUIDPointer	(LPCITEMIDLIST pidl);
266
FileStructW     *_ILGetFileStructW      (LPCITEMIDLIST pidl);
267

268 269
/*
 * debug helper
270
 */
271 272
void	pdump	(LPCITEMIDLIST pidl);
BOOL	pcheck	(LPCITEMIDLIST pidl);
273

274 275 276 277
/*
 * aPidl helper
 */
void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl);
278
LPITEMIDLIST * _ILCopyaPidl(LPCITEMIDLIST * apidlsrc, UINT cidl);
279
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPIDA cida);
280

281 282 283
BOOL WINAPI ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type);
BOOL WINAPI ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type);

Alexandre Julliard's avatar
Alexandre Julliard committed
284
#endif