| 1 | /* $Id: shell32_main.c,v 1.8 2002-06-09 12:41:22 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Shell basics
|
|---|
| 4 | *
|
|---|
| 5 | * 1998 Marcus Meissner
|
|---|
| 6 | * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
|
|---|
| 7 | */
|
|---|
| 8 | #ifdef __WIN32OS2__
|
|---|
| 9 | #define ICOM_CINTERFACE 1
|
|---|
| 10 | #include <odin.h>
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 | #include <stdlib.h>
|
|---|
| 14 | #include <string.h>
|
|---|
| 15 | #include <stdio.h>
|
|---|
| 16 |
|
|---|
| 17 | #include "windef.h"
|
|---|
| 18 | #include "wingdi.h"
|
|---|
| 19 | #include "wine/winuser16.h"
|
|---|
| 20 | #include "winerror.h"
|
|---|
| 21 | #include "heap.h"
|
|---|
| 22 | #include "dlgs.h"
|
|---|
| 23 | #include "ldt.h"
|
|---|
| 24 | #include "debugtools.h"
|
|---|
| 25 | #include "winreg.h"
|
|---|
| 26 | #include "authors.h"
|
|---|
| 27 |
|
|---|
| 28 | #include "shellapi.h"
|
|---|
| 29 | #include "pidl.h"
|
|---|
| 30 |
|
|---|
| 31 | #include "shell32_main.h"
|
|---|
| 32 | #include "undocshell.h"
|
|---|
| 33 | #include "shlobj.h"
|
|---|
| 34 | #include "shlguid.h"
|
|---|
| 35 | #include "shlwapi.h"
|
|---|
| 36 |
|
|---|
| 37 | #ifdef __WIN32OS2__
|
|---|
| 38 | #include <heapstring.h>
|
|---|
| 39 | #include <misc.h>
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | DEFAULT_DEBUG_CHANNEL(shell);
|
|---|
| 43 |
|
|---|
| 44 | #define MORE_DEBUG 1
|
|---|
| 45 | /*************************************************************************
|
|---|
| 46 | * CommandLineToArgvW [SHELL32.7]
|
|---|
| 47 | */
|
|---|
| 48 | /*************************************************************************
|
|---|
| 49 | * CommandLineToArgvW[SHELL32.@]
|
|---|
| 50 | *
|
|---|
| 51 | * We must interpret the quotes in the command line to rebuild the argv
|
|---|
| 52 | * array correctly:
|
|---|
| 53 | * - arguments are separated by spaces or tabs
|
|---|
| 54 | * - quotes serve as optional argument delimiters
|
|---|
| 55 | * '"a b"' -> 'a b'
|
|---|
| 56 | * - escaped quotes must be converted back to '"'
|
|---|
| 57 | * '\"' -> '"'
|
|---|
| 58 | * - an odd number of '\'s followed by '"' correspond to half that number
|
|---|
| 59 | * of '\' followed by a '"' (extension of the above)
|
|---|
| 60 | * '\\\"' -> '\"'
|
|---|
| 61 | * '\\\\\"' -> '\\"'
|
|---|
| 62 | * - an even number of '\'s followed by a '"' correspond to half that number
|
|---|
| 63 | * of '\', plus a regular quote serving as an argument delimiter (which
|
|---|
| 64 | * means it does not appear in the result)
|
|---|
| 65 | * 'a\\"b c"' -> 'a\b c'
|
|---|
| 66 | * 'a\\\\"b c"' -> 'a\\b c'
|
|---|
| 67 | * - '\' that are not followed by a '"' are copied literally
|
|---|
| 68 | * 'a\b' -> 'a\b'
|
|---|
| 69 | * 'a\\b' -> 'a\\b'
|
|---|
| 70 | *
|
|---|
| 71 | * Note:
|
|---|
| 72 | * '\t' == 0x0009
|
|---|
| 73 | * ' ' == 0x0020
|
|---|
| 74 | * '"' == 0x0022
|
|---|
| 75 | * '\\' == 0x005c
|
|---|
| 76 | */
|
|---|
| 77 | LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
|
|---|
| 78 | {
|
|---|
| 79 | DWORD argc;
|
|---|
| 80 | HGLOBAL hargv;
|
|---|
| 81 | LPWSTR *argv;
|
|---|
| 82 | LPCWSTR cs;
|
|---|
| 83 | LPWSTR arg,s,d;
|
|---|
| 84 | LPWSTR cmdline;
|
|---|
| 85 | int in_quotes,bcount;
|
|---|
| 86 |
|
|---|
| 87 | if (*lpCmdline==0) {
|
|---|
| 88 | /* Return the path to the executable */
|
|---|
| 89 | DWORD size;
|
|---|
| 90 |
|
|---|
| 91 | hargv=0;
|
|---|
| 92 | size=16;
|
|---|
| 93 | do {
|
|---|
| 94 | size*=2;
|
|---|
| 95 | hargv=GlobalReAlloc(hargv, size, 0);
|
|---|
| 96 | argv=GlobalLock(hargv);
|
|---|
| 97 | } while (GetModuleFileNameW((HMODULE)0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)) == 0);
|
|---|
| 98 | argv[0]=(LPWSTR)(argv+1);
|
|---|
| 99 | if (numargs)
|
|---|
| 100 | *numargs=2;
|
|---|
| 101 |
|
|---|
| 102 | return argv;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | /* to get a writeable copy */
|
|---|
| 106 | argc=0;
|
|---|
| 107 | bcount=0;
|
|---|
| 108 | in_quotes=0;
|
|---|
| 109 | cs=lpCmdline;
|
|---|
| 110 | while (1) {
|
|---|
| 111 | if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) {
|
|---|
| 112 | /* space */
|
|---|
| 113 | argc++;
|
|---|
| 114 | /* skip the remaining spaces */
|
|---|
| 115 | while (*cs==0x0009 || *cs==0x0020) {
|
|---|
| 116 | cs++;
|
|---|
| 117 | }
|
|---|
| 118 | if (*cs==0)
|
|---|
| 119 | break;
|
|---|
| 120 | bcount=0;
|
|---|
| 121 | continue;
|
|---|
| 122 | } else if (*cs==0x005c) {
|
|---|
| 123 | /* '\', count them */
|
|---|
| 124 | bcount++;
|
|---|
| 125 | } else if ((*cs==0x0022) && ((bcount & 1)==0)) {
|
|---|
| 126 | /* unescaped '"' */
|
|---|
| 127 | in_quotes=!in_quotes;
|
|---|
| 128 | bcount=0;
|
|---|
| 129 | } else {
|
|---|
| 130 | /* a regular character */
|
|---|
| 131 | bcount=0;
|
|---|
| 132 | }
|
|---|
| 133 | cs++;
|
|---|
| 134 | }
|
|---|
| 135 | /* Allocate in a single lump, the string array, and the strings that go with it.
|
|---|
| 136 | * This way the caller can make a single GlobalFree call to free both, as per MSDN.
|
|---|
| 137 | */
|
|---|
| 138 | hargv=GlobalAlloc(0, argc*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
|
|---|
| 139 | argv=GlobalLock(hargv);
|
|---|
| 140 | if (!argv)
|
|---|
| 141 | return NULL;
|
|---|
| 142 | cmdline=(LPWSTR)(argv+argc);
|
|---|
| 143 | strcpyW(cmdline, lpCmdline);
|
|---|
| 144 |
|
|---|
| 145 | argc=0;
|
|---|
| 146 | bcount=0;
|
|---|
| 147 | in_quotes=0;
|
|---|
| 148 | arg=d=s=cmdline;
|
|---|
| 149 | while (*s) {
|
|---|
| 150 | if ((*s==0x0009 || *s==0x0020) && !in_quotes) {
|
|---|
| 151 | /* Close the argument and copy it */
|
|---|
| 152 | *d=0;
|
|---|
| 153 | argv[argc++]=arg;
|
|---|
| 154 |
|
|---|
| 155 | /* skip the remaining spaces */
|
|---|
| 156 | do {
|
|---|
| 157 | s++;
|
|---|
| 158 | } while (*s==0x0009 || *s==0x0020);
|
|---|
| 159 |
|
|---|
| 160 | /* Start with a new argument */
|
|---|
| 161 | arg=d=s;
|
|---|
| 162 | bcount=0;
|
|---|
| 163 | } else if (*s==0x005c) {
|
|---|
| 164 | /* '\\' */
|
|---|
| 165 | *d++=*s++;
|
|---|
| 166 | bcount++;
|
|---|
| 167 | } else if (*s==0x0022) {
|
|---|
| 168 | /* '"' */
|
|---|
| 169 | if ((bcount & 1)==0) {
|
|---|
| 170 | /* Preceeded by an even number of '\', this is half that
|
|---|
| 171 | * number of '\', plus a quote which we erase.
|
|---|
| 172 | */
|
|---|
| 173 | d-=bcount/2;
|
|---|
| 174 | in_quotes=!in_quotes;
|
|---|
| 175 | s++;
|
|---|
| 176 | } else {
|
|---|
| 177 | /* Preceeded by an odd number of '\', this is half that
|
|---|
| 178 | * number of '\' followed by a '"'
|
|---|
| 179 | */
|
|---|
| 180 | d=d-bcount/2-1;
|
|---|
| 181 | *d++='"';
|
|---|
| 182 | s++;
|
|---|
| 183 | }
|
|---|
| 184 | bcount=0;
|
|---|
| 185 | } else {
|
|---|
| 186 | /* a regular character */
|
|---|
| 187 | *d++=*s++;
|
|---|
| 188 | bcount=0;
|
|---|
| 189 | }
|
|---|
| 190 | }
|
|---|
| 191 | if (*arg) {
|
|---|
| 192 | *d='\0';
|
|---|
| 193 | argv[argc]=arg;
|
|---|
| 194 | }
|
|---|
| 195 | if (numargs)
|
|---|
| 196 | *numargs=argc;
|
|---|
| 197 |
|
|---|
| 198 | return argv;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /*************************************************************************
|
|---|
| 202 | * SHGetFileInfoA [SHELL32.@]
|
|---|
| 203 | *
|
|---|
| 204 | */
|
|---|
| 205 |
|
|---|
| 206 | DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
|
|---|
| 207 | SHFILEINFOA *psfi, UINT sizeofpsfi,
|
|---|
| 208 | UINT flags )
|
|---|
| 209 | {
|
|---|
| 210 | char szLoaction[MAX_PATH];
|
|---|
| 211 | int iIndex;
|
|---|
| 212 | DWORD ret = TRUE, dwAttributes = 0;
|
|---|
| 213 | IShellFolder * psfParent = NULL;
|
|---|
| 214 | IExtractIconA * pei = NULL;
|
|---|
| 215 | LPITEMIDLIST pidlLast = NULL, pidl = NULL;
|
|---|
| 216 | HRESULT hr = S_OK;
|
|---|
| 217 | BOOL IconNotYetLoaded=TRUE;
|
|---|
| 218 |
|
|---|
| 219 | TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
|
|---|
| 220 | (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
|
|---|
| 221 |
|
|---|
| 222 | if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
|
|---|
| 223 | return FALSE;
|
|---|
| 224 |
|
|---|
| 225 | /* windows initializes this values regardless of the flags */
|
|---|
| 226 | psfi->szDisplayName[0] = '\0';
|
|---|
| 227 | psfi->szTypeName[0] = '\0';
|
|---|
| 228 | psfi->iIcon = 0;
|
|---|
| 229 |
|
|---|
| 230 | if (flags & SHGFI_EXETYPE) {
|
|---|
| 231 | BOOL status = FALSE;
|
|---|
| 232 | HANDLE hfile;
|
|---|
| 233 | DWORD BinaryType;
|
|---|
| 234 | IMAGE_DOS_HEADER mz_header;
|
|---|
| 235 | IMAGE_NT_HEADERS nt;
|
|---|
| 236 | DWORD len;
|
|---|
| 237 | char magic[4];
|
|---|
| 238 |
|
|---|
| 239 | if (flags != SHGFI_EXETYPE) return 0;
|
|---|
| 240 |
|
|---|
| 241 | status = GetBinaryTypeA (path, &BinaryType);
|
|---|
| 242 | if (!status) return 0;
|
|---|
| 243 | if ((BinaryType == SCS_DOS_BINARY)
|
|---|
| 244 | || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
|
|---|
| 245 |
|
|---|
| 246 | hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
|
|---|
| 247 | NULL, OPEN_EXISTING, 0, 0 );
|
|---|
| 248 | if ( hfile == INVALID_HANDLE_VALUE ) return 0;
|
|---|
| 249 |
|
|---|
| 250 | /* The next section is adapted from MODULE_GetBinaryType, as we need
|
|---|
| 251 | * to examine the image header to get OS and version information. We
|
|---|
| 252 | * know from calling GetBinaryTypeA that the image is valid and either
|
|---|
| 253 | * an NE or PE, so much error handling can be omitted.
|
|---|
| 254 | * Seek to the start of the file and read the header information.
|
|---|
| 255 | */
|
|---|
| 256 |
|
|---|
| 257 | SetFilePointer( hfile, 0, NULL, SEEK_SET );
|
|---|
| 258 | ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
|
|---|
| 259 |
|
|---|
| 260 | SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
|
|---|
| 261 | ReadFile( hfile, magic, sizeof(magic), &len, NULL );
|
|---|
| 262 | if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
|
|---|
| 263 | {
|
|---|
| 264 | SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
|
|---|
| 265 | ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
|
|---|
| 266 | CloseHandle( hfile );
|
|---|
| 267 | if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
|
|---|
| 268 | return IMAGE_NT_SIGNATURE
|
|---|
| 269 | | (nt.OptionalHeader.MajorSubsystemVersion << 24)
|
|---|
| 270 | | (nt.OptionalHeader.MinorSubsystemVersion << 16);
|
|---|
| 271 | }
|
|---|
| 272 | return IMAGE_NT_SIGNATURE;
|
|---|
| 273 | }
|
|---|
| 274 | else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
|
|---|
| 275 | {
|
|---|
| 276 | IMAGE_OS2_HEADER ne;
|
|---|
| 277 | SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
|
|---|
| 278 | ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
|
|---|
| 279 | CloseHandle( hfile );
|
|---|
| 280 | if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
|
|---|
| 281 | | (ne.ne_expver << 16);
|
|---|
| 282 | return 0;
|
|---|
| 283 | }
|
|---|
| 284 | CloseHandle( hfile );
|
|---|
| 285 | return 0;
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 | /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
|
|---|
| 290 | the pidl functions fail on not existing file names */
|
|---|
| 291 | if (flags & SHGFI_PIDL)
|
|---|
| 292 | {
|
|---|
| 293 | pidl = (LPCITEMIDLIST) path;
|
|---|
| 294 | if (!pidl )
|
|---|
| 295 | {
|
|---|
| 296 | ERR("pidl is null!\n");
|
|---|
| 297 | return FALSE;
|
|---|
| 298 | }
|
|---|
| 299 | }
|
|---|
| 300 | else if (!(flags & SHGFI_USEFILEATTRIBUTES))
|
|---|
| 301 | {
|
|---|
| 302 | hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
|
|---|
| 303 | /* note: the attributes in ISF::ParseDisplayName are not implemented */
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | /* get the parent shellfolder */
|
|---|
| 307 | if (pidl)
|
|---|
| 308 | {
|
|---|
| 309 | hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | /* get the attributes of the child */
|
|---|
| 313 | if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
|
|---|
| 314 | {
|
|---|
| 315 | if (!(flags & SHGFI_ATTR_SPECIFIED))
|
|---|
| 316 | {
|
|---|
| 317 | psfi->dwAttributes = 0xffffffff;
|
|---|
| 318 | }
|
|---|
| 319 | IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | /* get the displayname */
|
|---|
| 323 | if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
|
|---|
| 324 | {
|
|---|
| 325 | if (flags & SHGFI_USEFILEATTRIBUTES)
|
|---|
| 326 | {
|
|---|
| 327 | strcpy (psfi->szDisplayName, PathFindFileNameA(path));
|
|---|
| 328 | }
|
|---|
| 329 | else
|
|---|
| 330 | {
|
|---|
| 331 | STRRET str;
|
|---|
| 332 | hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
|
|---|
| 333 | StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
|
|---|
| 334 | }
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | /* get the type name */
|
|---|
| 338 | if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
|
|---|
| 339 | {
|
|---|
| 340 | if (!(flags & SHGFI_USEFILEATTRIBUTES))
|
|---|
| 341 | _ILGetFileType(pidlLast, psfi->szTypeName, 80);
|
|---|
| 342 | else
|
|---|
| 343 | {
|
|---|
| 344 | char sTemp[64];
|
|---|
| 345 | strcpy(sTemp,PathFindExtensionA(path));
|
|---|
| 346 | if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
|
|---|
| 347 | && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
|
|---|
| 348 | {
|
|---|
| 349 | lstrcpynA (psfi->szTypeName, sTemp, 80 - 6);
|
|---|
| 350 | strcat (psfi->szTypeName, "-file");
|
|---|
| 351 | }
|
|---|
| 352 | }
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | /* ### icons ###*/
|
|---|
| 356 | if (flags & SHGFI_LINKOVERLAY)
|
|---|
| 357 | FIXME("set icon to link, stub\n");
|
|---|
| 358 |
|
|---|
| 359 | if (flags & SHGFI_SELECTED)
|
|---|
| 360 | FIXME("set icon to selected, stub\n");
|
|---|
| 361 |
|
|---|
| 362 | if (flags & SHGFI_SHELLICONSIZE)
|
|---|
| 363 | FIXME("set icon to shell size, stub\n");
|
|---|
| 364 |
|
|---|
| 365 | /* get the iconlocation */
|
|---|
| 366 | if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
|
|---|
| 367 | {
|
|---|
| 368 | UINT uDummy,uFlags;
|
|---|
| 369 | hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
|
|---|
| 370 |
|
|---|
| 371 | if (SUCCEEDED(hr))
|
|---|
| 372 | {
|
|---|
| 373 | hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
|
|---|
| 374 | /* FIXME what to do with the index? */
|
|---|
| 375 |
|
|---|
| 376 | if(uFlags != GIL_NOTFILENAME)
|
|---|
| 377 | strcpy (psfi->szDisplayName, szLoaction);
|
|---|
| 378 | else
|
|---|
| 379 | ret = FALSE;
|
|---|
| 380 |
|
|---|
| 381 | IExtractIconA_Release(pei);
|
|---|
| 382 | }
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | /* get icon index (or load icon)*/
|
|---|
| 386 | if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
|
|---|
| 387 | {
|
|---|
| 388 |
|
|---|
| 389 | if (flags & SHGFI_USEFILEATTRIBUTES)
|
|---|
| 390 | {
|
|---|
| 391 | char sTemp [MAX_PATH];
|
|---|
| 392 | char * szExt;
|
|---|
| 393 | DWORD dwNr=0;
|
|---|
| 394 |
|
|---|
| 395 | lstrcpynA(sTemp, path, MAX_PATH);
|
|---|
| 396 | szExt = (LPSTR) PathFindExtensionA(sTemp);
|
|---|
| 397 | if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
|
|---|
| 398 | && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
|
|---|
| 399 | {
|
|---|
| 400 | if (!strcmp("%1",sTemp)) /* icon is in the file */
|
|---|
| 401 | {
|
|---|
| 402 | strcpy(sTemp, path);
|
|---|
| 403 | }
|
|---|
| 404 | IconNotYetLoaded=FALSE;
|
|---|
| 405 | psfi->iIcon = 0;
|
|---|
| 406 | if (SHGFI_LARGEICON)
|
|---|
| 407 | PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXICON),
|
|---|
| 408 | GetSystemMetrics(SM_CYICON),
|
|---|
| 409 | &psfi->hIcon,0,1,0);
|
|---|
| 410 | else
|
|---|
| 411 | PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXSMICON),
|
|---|
| 412 | GetSystemMetrics(SM_CYSMICON),
|
|---|
| 413 | &psfi->hIcon,0,1,0);
|
|---|
| 414 | }
|
|---|
| 415 | else /* default icon */
|
|---|
| 416 | {
|
|---|
| 417 | psfi->iIcon = 0;
|
|---|
| 418 | }
|
|---|
| 419 | }
|
|---|
| 420 | else
|
|---|
| 421 | {
|
|---|
| 422 | if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
|
|---|
| 423 | (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
|
|---|
| 424 | {
|
|---|
| 425 | ret = FALSE;
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|
| 428 | if (ret)
|
|---|
| 429 | {
|
|---|
| 430 | ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
|
|---|
| 431 | }
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | /* icon handle */
|
|---|
| 435 | if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
|
|---|
| 436 | psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
|
|---|
| 437 |
|
|---|
| 438 | if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
|
|---|
| 439 | FIXME("unknown attribute!\n");
|
|---|
| 440 |
|
|---|
| 441 | if (psfParent)
|
|---|
| 442 | IShellFolder_Release(psfParent);
|
|---|
| 443 |
|
|---|
| 444 | if (hr != S_OK)
|
|---|
| 445 | ret = FALSE;
|
|---|
| 446 |
|
|---|
| 447 | if(pidlLast) SHFree(pidlLast);
|
|---|
| 448 | #ifdef MORE_DEBUG
|
|---|
| 449 | TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
|
|---|
| 450 | psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
|
|---|
| 451 | #endif
|
|---|
| 452 | return ret;
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | /*************************************************************************
|
|---|
| 456 | * SHGetFileInfoW [SHELL32.@]
|
|---|
| 457 | */
|
|---|
| 458 |
|
|---|
| 459 | DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
|---|
| 460 | SHFILEINFOW *psfi, UINT sizeofpsfi,
|
|---|
| 461 | UINT flags )
|
|---|
| 462 | {
|
|---|
| 463 | INT len;
|
|---|
| 464 | LPSTR temppath;
|
|---|
| 465 | DWORD ret;
|
|---|
| 466 | SHFILEINFOA temppsfi;
|
|---|
| 467 |
|
|---|
| 468 | len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
|
|---|
| 469 | temppath = HeapAlloc(GetProcessHeap(), 0, len);
|
|---|
| 470 | WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
|
|---|
| 471 |
|
|---|
| 472 | WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
|
|---|
| 473 | sizeof(temppsfi.szDisplayName), NULL, NULL);
|
|---|
| 474 | WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
|
|---|
| 475 | sizeof(temppsfi.szTypeName), NULL, NULL);
|
|---|
| 476 |
|
|---|
| 477 | ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
|
|---|
| 478 |
|
|---|
| 479 | HeapFree(GetProcessHeap(), 0, temppath);
|
|---|
| 480 |
|
|---|
| 481 | return ret;
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | /*************************************************************************
|
|---|
| 485 | * SHGetFileInfo [SHELL32.@]
|
|---|
| 486 | */
|
|---|
| 487 | DWORD WINAPI SHGetFileInfoAW(
|
|---|
| 488 | LPCVOID path,
|
|---|
| 489 | DWORD dwFileAttributes,
|
|---|
| 490 | LPVOID psfi,
|
|---|
| 491 | UINT sizeofpsfi,
|
|---|
| 492 | UINT flags)
|
|---|
| 493 | {
|
|---|
| 494 | if(SHELL_OsIsUnicode())
|
|---|
| 495 | return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
|
|---|
| 496 | return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | /*************************************************************************
|
|---|
| 500 | * DuplicateIcon [SHELL32.188]
|
|---|
| 501 | */
|
|---|
| 502 | HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
|
|---|
| 503 | {
|
|---|
| 504 | ICONINFO IconInfo;
|
|---|
| 505 | HICON hDupIcon = 0;
|
|---|
| 506 |
|
|---|
| 507 | TRACE("(%04x, %04x)\n", hInstance, hIcon);
|
|---|
| 508 |
|
|---|
| 509 | if(GetIconInfo(hIcon, &IconInfo))
|
|---|
| 510 | {
|
|---|
| 511 | hDupIcon = CreateIconIndirect(&IconInfo);
|
|---|
| 512 |
|
|---|
| 513 | /* clean up hbmMask and hbmColor */
|
|---|
| 514 | DeleteObject(IconInfo.hbmMask);
|
|---|
| 515 | DeleteObject(IconInfo.hbmColor);
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | return hDupIcon;
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 | /*************************************************************************
|
|---|
| 523 | * ExtractIconA [SHELL32.133]
|
|---|
| 524 | *
|
|---|
| 525 | * fixme
|
|---|
| 526 | * is the filename is not a file return 1
|
|---|
| 527 | */
|
|---|
| 528 | #ifdef __WIN32OS2__
|
|---|
| 529 | HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
|
|---|
| 530 | UINT nIconIndex )
|
|---|
| 531 | {
|
|---|
| 532 | HGLOBAL handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
|
|---|
| 533 | TRACE_(shell)("\n");
|
|---|
| 534 | if( handle )
|
|---|
| 535 | {
|
|---|
| 536 | HICON* ptr = (HICON*)GlobalLock(handle);
|
|---|
| 537 | HICON hIcon = *ptr;
|
|---|
| 538 |
|
|---|
| 539 | GlobalFree(handle);
|
|---|
| 540 | return hIcon;
|
|---|
| 541 | }
|
|---|
| 542 | return 0;
|
|---|
| 543 | }
|
|---|
| 544 | #else
|
|---|
| 545 | HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
|
|---|
| 546 | UINT nIconIndex )
|
|---|
| 547 | { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
|
|---|
| 548 | TRACE("\n");
|
|---|
| 549 | if( handle )
|
|---|
| 550 | {
|
|---|
| 551 | HICON16* ptr = (HICON16*)GlobalLock16(handle);
|
|---|
| 552 | HICON16 hIcon = *ptr;
|
|---|
| 553 |
|
|---|
| 554 | GlobalFree16(handle);
|
|---|
| 555 | return hIcon;
|
|---|
| 556 | }
|
|---|
| 557 | return 0;
|
|---|
| 558 | }
|
|---|
| 559 | #endif
|
|---|
| 560 |
|
|---|
| 561 | /*************************************************************************
|
|---|
| 562 | * ExtractIconW [SHELL32.180]
|
|---|
| 563 | *
|
|---|
| 564 | * fixme
|
|---|
| 565 | * is the filename is not a file return 1
|
|---|
| 566 | */
|
|---|
| 567 | HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
|
|---|
| 568 | UINT nIconIndex )
|
|---|
| 569 | { LPSTR exefn;
|
|---|
| 570 | HICON ret;
|
|---|
| 571 | TRACE("\n");
|
|---|
| 572 |
|
|---|
| 573 | exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
|
|---|
| 574 | ret = ExtractIconA(hInstance,exefn,nIconIndex);
|
|---|
| 575 |
|
|---|
| 576 | HeapFree(GetProcessHeap(),0,exefn);
|
|---|
| 577 | return ret;
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | /*************************************************************************
|
|---|
| 581 | * FindExecutableA [SHELL32.184]
|
|---|
| 582 | */
|
|---|
| 583 | HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
|
|---|
| 584 | LPSTR lpResult )
|
|---|
| 585 | { HINSTANCE retval=31; /* default - 'No association was found' */
|
|---|
| 586 | char old_dir[1024];
|
|---|
| 587 |
|
|---|
| 588 | TRACE("File %s, Dir %s\n",
|
|---|
| 589 | (lpFile != NULL?lpFile:"-"),
|
|---|
| 590 | (lpDirectory != NULL?lpDirectory:"-"));
|
|---|
| 591 |
|
|---|
| 592 | lpResult[0]='\0'; /* Start off with an empty return string */
|
|---|
| 593 |
|
|---|
| 594 | /* trap NULL parameters on entry */
|
|---|
| 595 | if (( lpFile == NULL ) || ( lpResult == NULL ))
|
|---|
| 596 | { /* FIXME - should throw a warning, perhaps! */
|
|---|
| 597 | return 2; /* File not found. Close enough, I guess. */
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | if (lpDirectory)
|
|---|
| 601 | { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
|
|---|
| 602 | SetCurrentDirectoryA( lpDirectory );
|
|---|
| 603 | }
|
|---|
| 604 |
|
|---|
| 605 | retval = SHELL_FindExecutable( lpFile, "open", lpResult );
|
|---|
| 606 |
|
|---|
| 607 | TRACE("returning %s\n", lpResult);
|
|---|
| 608 | if (lpDirectory)
|
|---|
| 609 | SetCurrentDirectoryA( old_dir );
|
|---|
| 610 | return retval;
|
|---|
| 611 | }
|
|---|
| 612 |
|
|---|
| 613 | /*************************************************************************
|
|---|
| 614 | * FindExecutableW [SHELL32.219]
|
|---|
| 615 | */
|
|---|
| 616 | HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
|
|---|
| 617 | LPWSTR lpResult)
|
|---|
| 618 | {
|
|---|
| 619 | FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
|
|---|
| 620 | return 31; /* default - 'No association was found' */
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | typedef struct
|
|---|
| 624 | { LPCSTR szApp;
|
|---|
| 625 | LPCSTR szOtherStuff;
|
|---|
| 626 | HICON hIcon;
|
|---|
| 627 | } ABOUT_INFO;
|
|---|
| 628 |
|
|---|
| 629 | #define IDC_STATIC_TEXT 100
|
|---|
| 630 | #define IDC_LISTBOX 99
|
|---|
| 631 | #define IDC_WINE_TEXT 98
|
|---|
| 632 |
|
|---|
| 633 | #define DROP_FIELD_TOP (-15)
|
|---|
| 634 | #define DROP_FIELD_HEIGHT 15
|
|---|
| 635 |
|
|---|
| 636 | extern HICON hIconTitleFont;
|
|---|
| 637 |
|
|---|
| 638 | static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
|
|---|
| 639 | { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
|
|---|
| 640 | if( hWndCtl )
|
|---|
| 641 | { GetWindowRect( hWndCtl, lprect );
|
|---|
| 642 | MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
|
|---|
| 643 | lprect->bottom = (lprect->top += DROP_FIELD_TOP);
|
|---|
| 644 | return TRUE;
|
|---|
| 645 | }
|
|---|
| 646 | return FALSE;
|
|---|
| 647 | }
|
|---|
| 648 |
|
|---|
| 649 | /*************************************************************************
|
|---|
| 650 | * SHAppBarMessage [SHELL32.207]
|
|---|
| 651 | */
|
|---|
| 652 | UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
|
|---|
| 653 | {
|
|---|
| 654 | int width=data->rc.right - data->rc.left;
|
|---|
| 655 | int height=data->rc.bottom - data->rc.top;
|
|---|
| 656 | RECT rec=data->rc;
|
|---|
| 657 | switch (msg)
|
|---|
| 658 | { case ABM_GETSTATE:
|
|---|
| 659 | return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
|
|---|
| 660 | case ABM_GETTASKBARPOS:
|
|---|
| 661 | GetWindowRect(data->hWnd, &rec);
|
|---|
| 662 | data->rc=rec;
|
|---|
| 663 | return TRUE;
|
|---|
| 664 | case ABM_ACTIVATE:
|
|---|
| 665 | SetActiveWindow(data->hWnd);
|
|---|
| 666 | return TRUE;
|
|---|
| 667 | case ABM_GETAUTOHIDEBAR:
|
|---|
| 668 | data->hWnd=GetActiveWindow();
|
|---|
| 669 | return TRUE;
|
|---|
| 670 | case ABM_NEW:
|
|---|
| 671 | SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
|
|---|
| 672 | width,height,SWP_SHOWWINDOW);
|
|---|
| 673 | return TRUE;
|
|---|
| 674 | case ABM_QUERYPOS:
|
|---|
| 675 | GetWindowRect(data->hWnd, &(data->rc));
|
|---|
| 676 | return TRUE;
|
|---|
| 677 | case ABM_REMOVE:
|
|---|
| 678 | FIXME("ABM_REMOVE broken\n");
|
|---|
| 679 | /* FIXME: this is wrong; should it be DestroyWindow instead? */
|
|---|
| 680 | /*CloseHandle(data->hWnd);*/
|
|---|
| 681 | return TRUE;
|
|---|
| 682 | case ABM_SETAUTOHIDEBAR:
|
|---|
| 683 | SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
|
|---|
| 684 | width,height,SWP_SHOWWINDOW);
|
|---|
| 685 | return TRUE;
|
|---|
| 686 | case ABM_SETPOS:
|
|---|
| 687 | data->uEdge=(ABE_RIGHT | ABE_LEFT);
|
|---|
| 688 | SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
|
|---|
| 689 | width,height,SWP_SHOWWINDOW);
|
|---|
| 690 | return TRUE;
|
|---|
| 691 | case ABM_WINDOWPOSCHANGED:
|
|---|
| 692 | SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
|
|---|
| 693 | width,height,SWP_SHOWWINDOW);
|
|---|
| 694 | return TRUE;
|
|---|
| 695 | }
|
|---|
| 696 | return FALSE;
|
|---|
| 697 | }
|
|---|
| 698 |
|
|---|
| 699 | /*************************************************************************
|
|---|
| 700 | * SHHelpShortcuts_RunDLL [SHELL32.224]
|
|---|
| 701 | *
|
|---|
| 702 | */
|
|---|
| 703 | DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
|
|---|
| 704 | { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
|
|---|
| 705 | dwArg1, dwArg2, dwArg3, dwArg4);
|
|---|
| 706 |
|
|---|
| 707 | return 0;
|
|---|
| 708 | }
|
|---|
| 709 |
|
|---|
| 710 | /*************************************************************************
|
|---|
| 711 | * SHLoadInProc [SHELL32.225]
|
|---|
| 712 | * Create an instance of specified object class from within
|
|---|
| 713 | * the shell process and release it immediately
|
|---|
| 714 | */
|
|---|
| 715 |
|
|---|
| 716 | DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
|
|---|
| 717 | {
|
|---|
| 718 | IUnknown * pUnk = NULL;
|
|---|
| 719 | TRACE("%s\n", debugstr_guid(rclsid));
|
|---|
| 720 |
|
|---|
| 721 | CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
|
|---|
| 722 | if(pUnk)
|
|---|
| 723 | {
|
|---|
| 724 | IUnknown_Release(pUnk);
|
|---|
| 725 | return NOERROR;
|
|---|
| 726 | }
|
|---|
| 727 | return DISP_E_MEMBERNOTFOUND;
|
|---|
| 728 | }
|
|---|
| 729 |
|
|---|
| 730 | //replacement in shell32_odin.cpp
|
|---|
| 731 | #ifndef __WIN32OS2__
|
|---|
| 732 | /*************************************************************************
|
|---|
| 733 | * ShellExecuteA [SHELL32.245]
|
|---|
| 734 | */
|
|---|
| 735 | HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
|
|---|
| 736 | LPCSTR lpFile, LPCSTR lpParameters,
|
|---|
| 737 | LPCSTR lpDirectory, INT iShowCmd )
|
|---|
| 738 | { TRACE("\n");
|
|---|
| 739 | return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
|
|---|
| 740 | lpDirectory, iShowCmd );
|
|---|
| 741 | }
|
|---|
| 742 | #endif
|
|---|
| 743 |
|
|---|
| 744 | /*************************************************************************
|
|---|
| 745 | * ShellExecuteW [SHELL32.294]
|
|---|
| 746 | * from shellapi.h
|
|---|
| 747 | * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
|
|---|
| 748 | * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
|
|---|
| 749 | */
|
|---|
| 750 | HINSTANCE WINAPI
|
|---|
| 751 | ShellExecuteW(
|
|---|
| 752 | HWND hwnd,
|
|---|
| 753 | LPCWSTR lpOperation,
|
|---|
| 754 | LPCWSTR lpFile,
|
|---|
| 755 | LPCWSTR lpParameters,
|
|---|
| 756 | LPCWSTR lpDirectory,
|
|---|
| 757 | INT nShowCmd) {
|
|---|
| 758 |
|
|---|
| 759 | FIXME(": stub\n");
|
|---|
| 760 | return 0;
|
|---|
| 761 | }
|
|---|
| 762 |
|
|---|
| 763 | //replacement in shell32_odin.cpp
|
|---|
| 764 | #ifndef __WIN32OS2__
|
|---|
| 765 | /*************************************************************************
|
|---|
| 766 | * AboutDlgProc (internal)
|
|---|
| 767 | */
|
|---|
| 768 | BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
|
|---|
| 769 | LPARAM lParam )
|
|---|
| 770 | { HWND hWndCtl;
|
|---|
| 771 | char Template[512], AppTitle[512];
|
|---|
| 772 |
|
|---|
| 773 | TRACE("\n");
|
|---|
| 774 |
|
|---|
| 775 | switch(msg)
|
|---|
| 776 | { case WM_INITDIALOG:
|
|---|
| 777 | { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
|
|---|
| 778 | if (info)
|
|---|
| 779 | { const char* const *pstr = SHELL_People;
|
|---|
| 780 | SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
|
|---|
| 781 | GetWindowTextA( hWnd, Template, sizeof(Template) );
|
|---|
| 782 | sprintf( AppTitle, Template, info->szApp );
|
|---|
| 783 | SetWindowTextA( hWnd, AppTitle );
|
|---|
| 784 | SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
|
|---|
| 785 | info->szOtherStuff );
|
|---|
| 786 | hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
|
|---|
| 787 | SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
|
|---|
| 788 | if (!hIconTitleFont)
|
|---|
| 789 | {
|
|---|
| 790 | LOGFONTA logFont;
|
|---|
| 791 | SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
|
|---|
| 792 | hIconTitleFont = CreateFontIndirectA( &logFont );
|
|---|
| 793 | }
|
|---|
| 794 | SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
|
|---|
| 795 | while (*pstr)
|
|---|
| 796 | { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
|
|---|
| 797 | pstr++;
|
|---|
| 798 | }
|
|---|
| 799 | SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
|
|---|
| 800 | }
|
|---|
| 801 | }
|
|---|
| 802 | return 1;
|
|---|
| 803 |
|
|---|
| 804 | case WM_PAINT:
|
|---|
| 805 | { RECT rect;
|
|---|
| 806 | PAINTSTRUCT ps;
|
|---|
| 807 | HDC hDC = BeginPaint( hWnd, &ps );
|
|---|
| 808 |
|
|---|
| 809 | if( __get_dropline( hWnd, &rect ) ) {
|
|---|
| 810 | SelectObject( hDC, GetStockObject( BLACK_PEN ) );
|
|---|
| 811 | MoveToEx( hDC, rect.left, rect.top, NULL );
|
|---|
| 812 | LineTo( hDC, rect.right, rect.bottom );
|
|---|
| 813 | }
|
|---|
| 814 | EndPaint( hWnd, &ps );
|
|---|
| 815 | }
|
|---|
| 816 | break;
|
|---|
| 817 |
|
|---|
| 818 | case WM_LBTRACKPOINT:
|
|---|
| 819 | hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
|
|---|
| 820 | if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
|
|---|
| 821 | { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
|
|---|
| 822 | { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
|
|---|
| 823 | if( idx != -1 )
|
|---|
| 824 | { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
|
|---|
| 825 | HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
|
|---|
| 826 | char* pstr = (char*)GlobalLock16( hMemObj );
|
|---|
| 827 |
|
|---|
| 828 | if( pstr )
|
|---|
| 829 | { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
|
|---|
| 830 | SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
|
|---|
| 831 | SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
|
|---|
| 832 | UpdateWindow( hWndCtl );
|
|---|
| 833 | if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
|
|---|
| 834 | SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
|
|---|
| 835 | }
|
|---|
| 836 | if( hMemObj )
|
|---|
| 837 | GlobalFree16( hMemObj );
|
|---|
| 838 | }
|
|---|
| 839 | }
|
|---|
| 840 | }
|
|---|
| 841 | break;
|
|---|
| 842 |
|
|---|
| 843 | case WM_QUERYDROPOBJECT:
|
|---|
| 844 | if( wParam == 0 )
|
|---|
| 845 | { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
|
|---|
| 846 | if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
|
|---|
| 847 | { RECT rect;
|
|---|
| 848 | if( __get_dropline( hWnd, &rect ) )
|
|---|
| 849 | { POINT pt;
|
|---|
| 850 | pt.x=lpDragInfo->pt.x;
|
|---|
| 851 | pt.x=lpDragInfo->pt.y;
|
|---|
| 852 | rect.bottom += DROP_FIELD_HEIGHT;
|
|---|
| 853 | if( PtInRect( &rect, pt ) )
|
|---|
| 854 | { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
|
|---|
| 855 | return TRUE;
|
|---|
| 856 | }
|
|---|
| 857 | }
|
|---|
| 858 | }
|
|---|
| 859 | }
|
|---|
| 860 | break;
|
|---|
| 861 |
|
|---|
| 862 | case WM_DROPOBJECT:
|
|---|
| 863 | if( wParam == hWnd )
|
|---|
| 864 | { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
|
|---|
| 865 | if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
|
|---|
| 866 | { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
|
|---|
| 867 | if( pstr )
|
|---|
| 868 | { static char __appendix_str[] = " with";
|
|---|
| 869 |
|
|---|
| 870 | hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
|
|---|
| 871 | SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
|
|---|
| 872 | if( !strncmp( Template, "WINE", 4 ) )
|
|---|
| 873 | SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
|
|---|
| 874 | else
|
|---|
| 875 | { char* pch = Template + strlen(Template) - strlen(__appendix_str);
|
|---|
| 876 | *pch = '\0';
|
|---|
| 877 | SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
|
|---|
| 878 | (WPARAM)-1, (LPARAM)Template );
|
|---|
| 879 | }
|
|---|
| 880 |
|
|---|
| 881 | strcpy( Template, pstr );
|
|---|
| 882 | strcat( Template, __appendix_str );
|
|---|
| 883 | SetWindowTextA( hWndCtl, Template );
|
|---|
| 884 | SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
|
|---|
| 885 | return TRUE;
|
|---|
| 886 | }
|
|---|
| 887 | }
|
|---|
| 888 | }
|
|---|
| 889 | break;
|
|---|
| 890 |
|
|---|
| 891 | case WM_COMMAND:
|
|---|
| 892 | if (wParam == IDOK)
|
|---|
| 893 | { EndDialog(hWnd, TRUE);
|
|---|
| 894 | return TRUE;
|
|---|
| 895 | }
|
|---|
| 896 | break;
|
|---|
| 897 | case WM_CLOSE:
|
|---|
| 898 | EndDialog(hWnd, TRUE);
|
|---|
| 899 | break;
|
|---|
| 900 | }
|
|---|
| 901 |
|
|---|
| 902 | return 0;
|
|---|
| 903 | }
|
|---|
| 904 |
|
|---|
| 905 |
|
|---|
| 906 | /*************************************************************************
|
|---|
| 907 | * ShellAboutA [SHELL32.243]
|
|---|
| 908 | */
|
|---|
| 909 | BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
|
|---|
| 910 | HICON hIcon )
|
|---|
| 911 | { ABOUT_INFO info;
|
|---|
| 912 | HRSRC hRes;
|
|---|
| 913 | LPVOID template;
|
|---|
| 914 | TRACE("\n");
|
|---|
| 915 |
|
|---|
| 916 | if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
|
|---|
| 917 | return FALSE;
|
|---|
| 918 | if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
|
|---|
| 919 | return FALSE;
|
|---|
| 920 |
|
|---|
| 921 | info.szApp = szApp;
|
|---|
| 922 | info.szOtherStuff = szOtherStuff;
|
|---|
| 923 | info.hIcon = hIcon;
|
|---|
| 924 | if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
|
|---|
| 925 | return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
|
|---|
| 926 | template, hWnd, AboutDlgProc, (LPARAM)&info );
|
|---|
| 927 | }
|
|---|
| 928 |
|
|---|
| 929 |
|
|---|
| 930 | /*************************************************************************
|
|---|
| 931 | * ShellAboutW [SHELL32.244]
|
|---|
| 932 | */
|
|---|
| 933 | BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
|
|---|
| 934 | HICON hIcon )
|
|---|
| 935 | { BOOL ret;
|
|---|
| 936 | ABOUT_INFO info;
|
|---|
| 937 | HRSRC hRes;
|
|---|
| 938 | LPVOID template;
|
|---|
| 939 |
|
|---|
| 940 | TRACE("\n");
|
|---|
| 941 |
|
|---|
| 942 | if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
|
|---|
| 943 | return FALSE;
|
|---|
| 944 | if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
|
|---|
| 945 | return FALSE;
|
|---|
| 946 |
|
|---|
| 947 | info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
|
|---|
| 948 | info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
|
|---|
| 949 | info.hIcon = hIcon;
|
|---|
| 950 | if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
|
|---|
| 951 | ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
|
|---|
| 952 | template, hWnd, AboutDlgProc, (LPARAM)&info );
|
|---|
| 953 | HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
|
|---|
| 954 | HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
|
|---|
| 955 | return ret;
|
|---|
| 956 | }
|
|---|
| 957 | #endif //#ifndef __WIN32OS2__
|
|---|
| 958 |
|
|---|
| 959 | /*************************************************************************
|
|---|
| 960 | * FreeIconList
|
|---|
| 961 | */
|
|---|
| 962 | void WINAPI FreeIconList( DWORD dw )
|
|---|
| 963 | { FIXME("(%lx): stub\n",dw);
|
|---|
| 964 | }
|
|---|
| 965 |
|
|---|
| 966 | /***********************************************************************
|
|---|
| 967 | * DllGetVersion [SHELL32]
|
|---|
| 968 | *
|
|---|
| 969 | * Retrieves version information of the 'SHELL32.DLL'
|
|---|
| 970 | *
|
|---|
| 971 | * PARAMS
|
|---|
| 972 | * pdvi [O] pointer to version information structure.
|
|---|
| 973 | *
|
|---|
| 974 | * RETURNS
|
|---|
| 975 | * Success: S_OK
|
|---|
| 976 | * Failure: E_INVALIDARG
|
|---|
| 977 | *
|
|---|
| 978 | * NOTES
|
|---|
| 979 | * Returns version of a shell32.dll from IE4.01 SP1.
|
|---|
| 980 | */
|
|---|
| 981 |
|
|---|
| 982 | HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
|
|---|
| 983 | {
|
|---|
| 984 | if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
|
|---|
| 985 | {
|
|---|
| 986 | WARN("wrong DLLVERSIONINFO size from app");
|
|---|
| 987 | return E_INVALIDARG;
|
|---|
| 988 | }
|
|---|
| 989 |
|
|---|
| 990 | pdvi->dwMajorVersion = 4;
|
|---|
| 991 | pdvi->dwMinorVersion = 72;
|
|---|
| 992 | pdvi->dwBuildNumber = 3110;
|
|---|
| 993 | pdvi->dwPlatformID = 1;
|
|---|
| 994 |
|
|---|
| 995 | TRACE("%lu.%lu.%lu.%lu\n",
|
|---|
| 996 | pdvi->dwMajorVersion, pdvi->dwMinorVersion,
|
|---|
| 997 | pdvi->dwBuildNumber, pdvi->dwPlatformID);
|
|---|
| 998 |
|
|---|
| 999 | return S_OK;
|
|---|
| 1000 | }
|
|---|
| 1001 | /*************************************************************************
|
|---|
| 1002 | * global variables of the shell32.dll
|
|---|
| 1003 | * all are once per process
|
|---|
| 1004 | *
|
|---|
| 1005 | */
|
|---|
| 1006 | void (* WINAPI pDLLInitComctl)(LPVOID);
|
|---|
| 1007 | LPVOID (* WINAPI pCOMCTL32_Alloc) (INT);
|
|---|
| 1008 | BOOL (* WINAPI pCOMCTL32_Free) (LPVOID);
|
|---|
| 1009 |
|
|---|
| 1010 | /* 2001-10-17 @@@PH
|
|---|
| 1011 | either me or VAC308 seems to be confused here:
|
|---|
| 1012 | if complains about redeclaration of the corresponding functions
|
|---|
| 1013 | in commctrl.h
|
|---|
| 1014 |
|
|---|
| 1015 | Even more strangely, all variables "pFunction" are automatically
|
|---|
| 1016 | percieved as "Function".
|
|---|
| 1017 | */
|
|---|
| 1018 | #if 0
|
|---|
| 1019 | HDPA (* WINAPI lpDPA_Create) (INT);
|
|---|
| 1020 | INT (* WINAPI lpDPA_InsertPtr) (const HDPA, INT, LPVOID);
|
|---|
| 1021 | BOOL (* WINAPI lpDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
|
|---|
| 1022 | LPVOID (* WINAPI lpDPA_GetPtr) (const HDPA, INT);
|
|---|
| 1023 | BOOL (* WINAPI lpDPA_Destroy) (const HDPA);
|
|---|
| 1024 | INT (* WINAPI lpDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
|
|---|
| 1025 | LPVOID (* WINAPI lpDPA_DeletePtr) (const HDPA hdpa, INT i);
|
|---|
| 1026 | HANDLE (* WINAPI lpCreateMRUListA) (LPVOID lpcml);
|
|---|
| 1027 | DWORD (* WINAPI lpFreeMRUListA) (HANDLE hMRUList);
|
|---|
| 1028 | INT (* WINAPI lpAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
|
|---|
| 1029 | INT (* WINAPI lpFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
|
|---|
| 1030 | INT (* WINAPI lpEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
|
|---|
| 1031 | #endif
|
|---|
| 1032 |
|
|---|
| 1033 | static HINSTANCE hComctl32;
|
|---|
| 1034 | static INT shell32_RefCount = 0;
|
|---|
| 1035 |
|
|---|
| 1036 | LONG shell32_ObjCount = 0;
|
|---|
| 1037 | HINSTANCE shell32_hInstance = 0;
|
|---|
| 1038 | HIMAGELIST ShellSmallIconList = 0;
|
|---|
| 1039 | HIMAGELIST ShellBigIconList = 0;
|
|---|
| 1040 |
|
|---|
| 1041 |
|
|---|
| 1042 | /*************************************************************************
|
|---|
| 1043 | * SHELL32 LibMain
|
|---|
| 1044 | *
|
|---|
| 1045 | * NOTES
|
|---|
| 1046 | * calling oleinitialize here breaks sone apps.
|
|---|
| 1047 | */
|
|---|
| 1048 |
|
|---|
| 1049 | BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
|---|
| 1050 | {
|
|---|
| 1051 | TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
|
|---|
| 1052 |
|
|---|
| 1053 | switch (fdwReason)
|
|---|
| 1054 | {
|
|---|
| 1055 | case DLL_PROCESS_ATTACH:
|
|---|
| 1056 | shell32_RefCount++;
|
|---|
| 1057 | if (shell32_hInstance) return TRUE;
|
|---|
| 1058 |
|
|---|
| 1059 | shell32_hInstance = hinstDLL;
|
|---|
| 1060 | hComctl32 = GetModuleHandleA("COMCTL32.DLL");
|
|---|
| 1061 | DisableThreadLibraryCalls(shell32_hInstance);
|
|---|
| 1062 |
|
|---|
| 1063 | if (!hComctl32)
|
|---|
| 1064 | {
|
|---|
| 1065 | ERR("P A N I C SHELL32 loading failed\n");
|
|---|
| 1066 | return FALSE;
|
|---|
| 1067 | }
|
|---|
| 1068 |
|
|---|
| 1069 | /* comctl32 */
|
|---|
| 1070 | pDLLInitComctl=(void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
|
|---|
| 1071 | pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
|
|---|
| 1072 | pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
|
|---|
| 1073 | #if 0
|
|---|
| 1074 | lpDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
|
|---|
| 1075 | lpDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
|
|---|
| 1076 | lpDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
|
|---|
| 1077 | lpDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
|
|---|
| 1078 | lpDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
|
|---|
| 1079 | lpDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
|
|---|
| 1080 | lpDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
|
|---|
| 1081 | lpCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
|
|---|
| 1082 | lpFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
|
|---|
| 1083 | lpAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
|
|---|
| 1084 | lpFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
|
|---|
| 1085 | lpEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
|
|---|
| 1086 | #endif
|
|---|
| 1087 | /* initialize the common controls */
|
|---|
| 1088 | if (pDLLInitComctl)
|
|---|
| 1089 | {
|
|---|
| 1090 | pDLLInitComctl(NULL);
|
|---|
| 1091 | }
|
|---|
| 1092 | InitCommonControlsEx(NULL);
|
|---|
| 1093 |
|
|---|
| 1094 | SIC_Initialize();
|
|---|
| 1095 | SYSTRAY_Init();
|
|---|
| 1096 | InitChangeNotifications();
|
|---|
| 1097 | SHInitRestricted(NULL, NULL);
|
|---|
| 1098 | break;
|
|---|
| 1099 |
|
|---|
| 1100 | case DLL_THREAD_ATTACH:
|
|---|
| 1101 | shell32_RefCount++;
|
|---|
| 1102 | break;
|
|---|
| 1103 |
|
|---|
| 1104 | case DLL_THREAD_DETACH:
|
|---|
| 1105 | shell32_RefCount--;
|
|---|
| 1106 | break;
|
|---|
| 1107 |
|
|---|
| 1108 | case DLL_PROCESS_DETACH:
|
|---|
| 1109 | shell32_RefCount--;
|
|---|
| 1110 |
|
|---|
| 1111 | if ( !shell32_RefCount )
|
|---|
| 1112 | {
|
|---|
| 1113 | shell32_hInstance = 0;
|
|---|
| 1114 |
|
|---|
| 1115 | if (pdesktopfolder)
|
|---|
| 1116 | {
|
|---|
| 1117 | IShellFolder_Release(pdesktopfolder);
|
|---|
| 1118 | pdesktopfolder = NULL;
|
|---|
| 1119 | }
|
|---|
| 1120 |
|
|---|
| 1121 | SIC_Destroy();
|
|---|
| 1122 | FreeChangeNotifications();
|
|---|
| 1123 |
|
|---|
| 1124 | /* this one is here to check if AddRef/Release is balanced */
|
|---|
| 1125 | if (shell32_ObjCount)
|
|---|
| 1126 | {
|
|---|
| 1127 | WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
|
|---|
| 1128 | }
|
|---|
| 1129 | }
|
|---|
| 1130 |
|
|---|
| 1131 | TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
|
|---|
| 1132 | break;
|
|---|
| 1133 | }
|
|---|
| 1134 | return TRUE;
|
|---|
| 1135 | }
|
|---|
| 1136 |
|
|---|
| 1137 | /*************************************************************************
|
|---|
| 1138 | * DllInstall [SHELL32.202]
|
|---|
| 1139 | *
|
|---|
| 1140 | * PARAMETERS
|
|---|
| 1141 | *
|
|---|
| 1142 | * BOOL bInstall - TRUE for install, FALSE for uninstall
|
|---|
| 1143 | * LPCWSTR pszCmdLine - command line (unused by shell32?)
|
|---|
| 1144 | */
|
|---|
| 1145 |
|
|---|
| 1146 | HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
|
|---|
| 1147 | {
|
|---|
| 1148 | FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
|
|---|
| 1149 |
|
|---|
| 1150 | return S_OK; /* indicate success */
|
|---|
| 1151 | }
|
|---|
| 1152 |
|
|---|
| 1153 | /***********************************************************************
|
|---|
| 1154 | * DllCanUnloadNow (SHELL32.@)
|
|---|
| 1155 | */
|
|---|
| 1156 | HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
|
|---|
| 1157 | {
|
|---|
| 1158 | FIXME("(void): stub\n");
|
|---|
| 1159 |
|
|---|
| 1160 | return S_FALSE;
|
|---|
| 1161 | }
|
|---|