pidl.h 8.98 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
 * DO NOT use these definitions outside the shell32.dll!
Alexandre Julliard's avatar
Alexandre Julliard committed
24
 *
25
 * The contents of a pidl should never be used directly from an application.
Alexandre Julliard's avatar
Alexandre Julliard committed
26
 *
27 28 29 30 31
 * 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
32
 */
33

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

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

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

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

89
#define PT_CPLAPPLET	0x00
90
#define PT_GUID		0x1F
91
#define PT_DRIVE	0x23
Juergen Schmied's avatar
Juergen Schmied committed
92 93
#define PT_DRIVE2	0x25
#define PT_DRIVE3	0x29
94
#define PT_SHELLEXT	0x2E
95 96
#define PT_DRIVE1	0x2F
#define PT_FOLDER1	0x30
97
#define PT_FOLDER	0x31
98
#define PT_VALUE	0x32
99 100
#define PT_VALUEW	0x34
#define PT_FOLDERW	0x35
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 191 192 193 194 195 196
DWORD	_ILSimpleGetText	(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
DWORD	_ILSimpleGetTextW	(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
BOOL	_ILGetFileDate 		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
DWORD	_ILGetFileSize		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
BOOL	_ILGetExtension		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
void	_ILGetFileType		(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
DWORD	_ILGetFileAttributes	(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
197

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

/*
 * testing simple pidls
 */
204 205 206 207 208 209 210 211 212
BOOL	_ILIsUnicode		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsDesktop		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsMyComputer		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsDrive		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsFolder		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsValue		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsSpecialFolder	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsPidlSimple		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	_ILIsCPanelStruct	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
213 214 215 216 217 218 219 220
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
221

222
/*
223
 * simple pidls
224
 */
225

226 227
/* Creates a PIDL with guid format and type type, which must be one of PT_GUID,
 * PT_SHELLEXT, or PT_YAGUID.
228
 */
229
LPITEMIDLIST	_ILCreateGuid(PIDLTYPE type, REFIID guid) DECLSPEC_HIDDEN;
230 231

/* Like _ILCreateGuid, but using the string szGUID. */
232 233
LPITEMIDLIST	_ILCreateGuidFromStrA(LPCSTR szGUID) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateGuidFromStrW(LPCWSTR szGUID) DECLSPEC_HIDDEN;
234 235

/* Commonly used PIDLs representing file system objects. */
236 237 238
LPITEMIDLIST	_ILCreateDesktop	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateFromFindDataW(const WIN32_FIND_DATAW *stffile) DECLSPEC_HIDDEN;
HRESULT		_ILCreateFromPathW	(LPCWSTR szPath, LPITEMIDLIST* ppidl) DECLSPEC_HIDDEN;
239 240

/* Other helpers */
241 242 243 244 245 246 247 248 249 250
LPITEMIDLIST	_ILCreateMyComputer	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateMyDocuments	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateIExplore	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateControlPanel	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreatePrinters	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateNetwork	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateNetHood	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateBitBucket	(void) DECLSPEC_HIDDEN;
LPITEMIDLIST	_ILCreateDrive		(LPCWSTR) DECLSPEC_HIDDEN;
LPITEMIDLIST    _ILCreateEntireNetwork  (void) DECLSPEC_HIDDEN;
251 252 253 254

/*
 * helper functions (getting struct-pointer)
 */
255 256 257 258
LPPIDLDATA	_ILGetDataPointer	(LPCITEMIDLIST) DECLSPEC_HIDDEN;
LPSTR		_ILGetTextPointer	(LPCITEMIDLIST) DECLSPEC_HIDDEN;
IID		*_ILGetGUIDPointer	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
FileStructW     *_ILGetFileStructW      (LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
259

260 261
/*
 * debug helper
262
 */
263 264
void	pdump	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
BOOL	pcheck	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
265

266 267 268
/*
 * aPidl helper
 */
269 270 271
void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
LPITEMIDLIST * _ILCopyaPidl(const LPCITEMIDLIST * apidlsrc, UINT cidl) DECLSPEC_HIDDEN;
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, const CIDA * cida) DECLSPEC_HIDDEN;
272

273
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type) DECLSPEC_HIDDEN;
274

Alexandre Julliard's avatar
Alexandre Julliard committed
275
#endif