4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
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
44 #include "undocshell.h"
46 #include "shell32_main.h"
52 #include "wine/debug.h"
53 #include "wine/unicode.h"
55 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
57 /*************************************************************************
58 * CommandLineToArgvW [SHELL32.@]
60 * We must interpret the quotes in the command line to rebuild the argv
62 * - arguments are separated by spaces or tabs
63 * - quotes serve as optional argument delimiters
65 * - escaped quotes must be converted back to '"'
67 * - consecutive backslashes preceding a quote see their number halved with
68 * the remainder escaping the quote:
69 * 2n backslashes + quote -> n backslashes + quote as an argument delimiter
70 * 2n+1 backslashes + quote -> n backslashes + literal quote
71 * - backslashes that are not followed by a quote are copied literally:
74 * - in quoted strings, consecutive quotes see their number divided by three
75 * with the remainder modulo 3 deciding whether to close the string or not.
76 * Note that the opening quote must be counted in the consecutive quotes,
77 * that's the (1+) below:
78 * (1+) 3n quotes -> n quotes
79 * (1+) 3n+1 quotes -> n quotes plus closes the quoted string
80 * (1+) 3n+2 quotes -> n+1 quotes plus closes the quoted string
81 * - in unquoted strings, the first quote opens the quoted string and the
82 * remaining consecutive quotes follow the above rule.
84 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
95 SetLastError(ERROR_INVALID_PARAMETER
);
101 /* Return the path to the executable */
102 DWORD len
, deslen
=MAX_PATH
, size
;
104 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
107 if (!(argv
= LocalAlloc(LMEM_FIXED
, size
))) return NULL
;
108 len
= GetModuleFileNameW(0, (LPWSTR
)(argv
+1), deslen
);
114 if (len
< deslen
) break;
116 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
119 argv
[0]=(LPWSTR
)(argv
+1);
125 /* --- First count the arguments */
128 /* The first argument, the executable path, follows special rules */
131 /* The executable path ends at the next quote, no matter what */
139 /* The executable path ends at the next space, no matter what */
140 while (*s
&& *s
!=' ' && *s
!='\t')
143 /* skip to the first argument, if any */
144 while (*s
==' ' || *s
=='\t')
149 /* Analyze the remaining arguments */
153 if ((*s
==' ' || *s
=='\t') && qcount
==0)
155 /* skip to the next argument and count it if any */
156 while (*s
==' ' || *s
=='\t')
164 /* '\', count them */
172 qcount
++; /* unescaped '"' */
175 /* consecutive quotes, see comment in copying code below */
187 /* a regular character */
193 /* Allocate in a single lump, the string array, and the strings that go
194 * with it. This way the caller can make a single LocalFree() call to free
197 argv
=LocalAlloc(LMEM_FIXED
, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
200 cmdline
=(LPWSTR
)(argv
+argc
);
201 strcpyW(cmdline
, lpCmdline
);
203 /* --- Then split and copy the arguments */
206 /* The first argument, the executable path, follows special rules */
209 /* The executable path ends at the next quote, no matter what */
223 /* The executable path ends at the next space, no matter what */
224 while (*d
&& *d
!=' ' && *d
!='\t')
230 /* close the argument */
232 /* skip to the first argument and initialize it if any */
233 while (*s
==' ' || *s
=='\t')
238 /* Split and copy the remaining arguments */
242 if ((*s
==' ' || *s
=='\t') && qcount
==0)
244 /* close the argument */
248 /* skip to the next one and initialize it if any */
251 } while (*s
==' ' || *s
=='\t');
264 /* Preceded by an even number of '\', this is half that
265 * number of '\', plus a quote which we erase.
272 /* Preceded by an odd number of '\', this is half that
273 * number of '\' followed by a '"'
280 /* Now count the number of consecutive quotes. Note that qcount
281 * already takes into account the opening quote if any, as well as
282 * the quote that lead us here.
298 /* a regular character */
309 static DWORD
shgfi_get_exe_type(LPCWSTR szFullPath
)
314 IMAGE_DOS_HEADER mz_header
;
319 status
= GetBinaryTypeW (szFullPath
, &BinaryType
);
322 if (BinaryType
== SCS_DOS_BINARY
|| BinaryType
== SCS_PIF_BINARY
)
325 hfile
= CreateFileW( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
326 NULL
, OPEN_EXISTING
, 0, 0 );
327 if ( hfile
== INVALID_HANDLE_VALUE
)
331 * The next section is adapted from MODULE_GetBinaryType, as we need
332 * to examine the image header to get OS and version information. We
333 * know from calling GetBinaryTypeA that the image is valid and either
334 * an NE or PE, so much error handling can be omitted.
335 * Seek to the start of the file and read the header information.
338 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
339 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
341 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
342 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
343 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
345 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
346 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
347 CloseHandle( hfile
);
348 /* DLL files are not executable and should return 0 */
349 if (nt
.FileHeader
.Characteristics
& IMAGE_FILE_DLL
)
351 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
)
353 return IMAGE_NT_SIGNATURE
|
354 (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24) |
355 (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
357 return IMAGE_NT_SIGNATURE
;
359 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
362 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
363 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
364 CloseHandle( hfile
);
365 if (ne
.ne_exetyp
== 2)
366 return IMAGE_OS2_SIGNATURE
| (ne
.ne_expver
<< 16);
369 CloseHandle( hfile
);
373 /*************************************************************************
374 * SHELL_IsShortcut [internal]
376 * Decide if an item id list points to a shell shortcut
378 BOOL
SHELL_IsShortcut(LPCITEMIDLIST pidlLast
)
380 char szTemp
[MAX_PATH
];
384 if (_ILGetExtension(pidlLast
, szTemp
, MAX_PATH
) &&
385 HCR_MapTypeToValueA(szTemp
, szTemp
, MAX_PATH
, TRUE
))
387 if (ERROR_SUCCESS
== RegOpenKeyExA(HKEY_CLASSES_ROOT
, szTemp
, 0, KEY_QUERY_VALUE
, &keyCls
))
389 if (ERROR_SUCCESS
== RegQueryValueExA(keyCls
, "IsShortcut", NULL
, NULL
, NULL
, NULL
))
399 #define SHGFI_KNOWN_FLAGS \
400 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
401 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
402 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
403 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
404 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
406 /*************************************************************************
407 * SHGetFileInfoW [SHELL32.@]
410 DWORD_PTR WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
411 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
413 WCHAR szLocation
[MAX_PATH
], szFullPath
[MAX_PATH
];
415 DWORD_PTR ret
= TRUE
;
416 DWORD dwAttributes
= 0;
417 IShellFolder
* psfParent
= NULL
;
418 IExtractIconW
* pei
= NULL
;
419 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
421 BOOL IconNotYetLoaded
=TRUE
;
424 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
425 (flags
& SHGFI_PIDL
)? "pidl" : debugstr_w(path
), dwFileAttributes
,
426 psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
431 /* windows initializes these values regardless of the flags */
434 psfi
->szDisplayName
[0] = '\0';
435 psfi
->szTypeName
[0] = '\0';
439 if (!(flags
& SHGFI_PIDL
))
441 /* SHGetFileInfo should work with absolute and relative paths */
442 if (PathIsRelativeW(path
))
444 GetCurrentDirectoryW(MAX_PATH
, szLocation
);
445 PathCombineW(szFullPath
, szLocation
, path
);
449 lstrcpynW(szFullPath
, path
, MAX_PATH
);
453 if (flags
& SHGFI_EXETYPE
)
455 if (flags
!= SHGFI_EXETYPE
)
457 return shgfi_get_exe_type(szFullPath
);
461 * psfi is NULL normally to query EXE type. If it is NULL, none of the
462 * below makes sense anyway. Windows allows this and just returns FALSE
468 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
470 * The pidl functions fail on not existing file names
473 if (flags
& SHGFI_PIDL
)
475 pidl
= ILClone((LPCITEMIDLIST
)path
);
477 else if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
479 hr
= SHILCreateFromPathW(szFullPath
, &pidl
, &dwAttributes
);
482 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
484 /* get the parent shellfolder */
487 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
,
488 (LPCITEMIDLIST
*)&pidlLast
);
490 pidlLast
= ILClone(pidlLast
);
495 ERR("pidl is null!\n");
500 /* get the attributes of the child */
501 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
503 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
505 psfi
->dwAttributes
= 0xffffffff;
508 IShellFolder_GetAttributesOf( psfParent
, 1, (LPCITEMIDLIST
*)&pidlLast
,
509 &(psfi
->dwAttributes
) );
512 /* get the displayname */
513 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
515 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
517 lstrcpyW (psfi
->szDisplayName
, PathFindFileNameW(szFullPath
));
522 hr
= IShellFolder_GetDisplayNameOf( psfParent
, pidlLast
,
523 SHGDN_INFOLDER
, &str
);
524 StrRetToStrNW (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
528 /* get the type name */
529 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
531 static const WCHAR szFile
[] = { 'F','i','l','e',0 };
532 static const WCHAR szDashFile
[] = { '-','f','i','l','e',0 };
534 if (!(flags
& SHGFI_USEFILEATTRIBUTES
) || (flags
& SHGFI_PIDL
))
538 _ILGetFileType(pidlLast
, ftype
, 80);
539 MultiByteToWideChar(CP_ACP
, 0, ftype
, -1, psfi
->szTypeName
, 80 );
543 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
544 strcatW (psfi
->szTypeName
, szFile
);
549 lstrcpyW(sTemp
,PathFindExtensionW(szFullPath
));
550 if (!( HCR_MapTypeToValueW(sTemp
, sTemp
, 64, TRUE
) &&
551 HCR_MapTypeToValueW(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
553 lstrcpynW (psfi
->szTypeName
, sTemp
, 64);
554 strcatW (psfi
->szTypeName
, szDashFile
);
561 if (flags
& SHGFI_OPENICON
)
562 uGilFlags
|= GIL_OPENICON
;
564 if (flags
& SHGFI_LINKOVERLAY
)
565 uGilFlags
|= GIL_FORSHORTCUT
;
566 else if ((flags
&SHGFI_ADDOVERLAYS
) ||
567 (flags
&(SHGFI_ICON
|SHGFI_SMALLICON
))==SHGFI_ICON
)
569 if (SHELL_IsShortcut(pidlLast
))
570 uGilFlags
|= GIL_FORSHORTCUT
;
573 if (flags
& SHGFI_OVERLAYINDEX
)
574 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
576 if (flags
& SHGFI_SELECTED
)
577 FIXME("set icon to selected, stub\n");
579 if (flags
& SHGFI_SHELLICONSIZE
)
580 FIXME("set icon to shell size, stub\n");
582 /* get the iconlocation */
583 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
587 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
589 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
591 lstrcpyW(psfi
->szDisplayName
, swShell32Name
);
592 psfi
->iIcon
= -IDI_SHELL_FOLDER
;
597 static const WCHAR p1W
[] = {'%','1',0};
598 WCHAR sTemp
[MAX_PATH
];
600 szExt
= PathFindExtensionW(szFullPath
);
601 TRACE("szExt=%s\n", debugstr_w(szExt
));
603 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
604 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &psfi
->iIcon
))
606 if (lstrcmpW(p1W
, sTemp
))
607 strcpyW(psfi
->szDisplayName
, sTemp
);
610 /* the icon is in the file */
611 strcpyW(psfi
->szDisplayName
, szFullPath
);
620 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1,
621 (LPCITEMIDLIST
*)&pidlLast
, &IID_IExtractIconW
,
622 &uDummy
, (LPVOID
*)&pei
);
625 hr
= IExtractIconW_GetIconLocation(pei
, uGilFlags
,
626 szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
628 if (uFlags
& GIL_NOTFILENAME
)
632 lstrcpyW (psfi
->szDisplayName
, szLocation
);
633 psfi
->iIcon
= iIndex
;
635 IExtractIconW_Release(pei
);
640 /* get icon index (or load icon)*/
641 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
643 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
645 WCHAR sTemp
[MAX_PATH
];
649 lstrcpynW(sTemp
, szFullPath
, MAX_PATH
);
651 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
652 psfi
->iIcon
= SIC_GetIconIndex(swShell32Name
, -IDI_SHELL_FOLDER
, 0);
655 static const WCHAR p1W
[] = {'%','1',0};
658 szExt
= PathFindExtensionW(sTemp
);
660 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
661 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &icon_idx
))
663 if (!lstrcmpW(p1W
,sTemp
)) /* icon is in the file */
664 strcpyW(sTemp
, szFullPath
);
666 if (flags
& SHGFI_SYSICONINDEX
)
668 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,icon_idx
,0);
669 if (psfi
->iIcon
== -1)
675 if (flags
& SHGFI_SMALLICON
)
676 ret
= PrivateExtractIconsW( sTemp
,icon_idx
,
677 GetSystemMetrics( SM_CXSMICON
),
678 GetSystemMetrics( SM_CYSMICON
),
679 &psfi
->hIcon
, 0, 1, 0);
681 ret
= PrivateExtractIconsW( sTemp
, icon_idx
,
682 GetSystemMetrics( SM_CXICON
),
683 GetSystemMetrics( SM_CYICON
),
684 &psfi
->hIcon
, 0, 1, 0);
685 if (ret
!= 0 && ret
!= (UINT
)-1)
687 IconNotYetLoaded
=FALSE
;
688 psfi
->iIcon
= icon_idx
;
696 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
697 uGilFlags
, &(psfi
->iIcon
))))
702 if (ret
&& (flags
& SHGFI_SYSICONINDEX
))
704 if (flags
& SHGFI_SMALLICON
)
705 ret
= (DWORD_PTR
) ShellSmallIconList
;
707 ret
= (DWORD_PTR
) ShellBigIconList
;
712 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
714 if (flags
& SHGFI_SMALLICON
)
715 psfi
->hIcon
= ImageList_GetIcon( ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
717 psfi
->hIcon
= ImageList_GetIcon( ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
720 if (flags
& ~SHGFI_KNOWN_FLAGS
)
721 FIXME("unknown flags %08x\n", flags
& ~SHGFI_KNOWN_FLAGS
);
724 IShellFolder_Release(psfParent
);
731 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
732 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
,
733 debugstr_w(psfi
->szDisplayName
), debugstr_w(psfi
->szTypeName
), ret
);
738 /*************************************************************************
739 * SHGetFileInfoA [SHELL32.@]
742 * MSVBVM60.__vbaNew2 expects this function to return a value in range
743 * 1 .. 0x7fff when the function succeeds and flags does not contain
744 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
746 DWORD_PTR WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
747 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
751 LPWSTR temppath
= NULL
;
754 SHFILEINFOW temppsfi
;
756 if (flags
& SHGFI_PIDL
)
758 /* path contains a pidl */
759 pathW
= (LPCWSTR
)path
;
763 len
= MultiByteToWideChar(CP_ACP
, 0, path
, -1, NULL
, 0);
764 temppath
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
765 MultiByteToWideChar(CP_ACP
, 0, path
, -1, temppath
, len
);
769 if (psfi
&& (flags
& SHGFI_ATTR_SPECIFIED
))
770 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
773 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, NULL
, sizeof(temppsfi
), flags
);
775 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
779 if(flags
& SHGFI_ICON
)
780 psfi
->hIcon
=temppsfi
.hIcon
;
781 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
782 psfi
->iIcon
=temppsfi
.iIcon
;
783 if(flags
& SHGFI_ATTRIBUTES
)
784 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
785 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
787 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szDisplayName
, -1,
788 psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
), NULL
, NULL
);
790 if(flags
& SHGFI_TYPENAME
)
792 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szTypeName
, -1,
793 psfi
->szTypeName
, sizeof(psfi
->szTypeName
), NULL
, NULL
);
797 HeapFree(GetProcessHeap(), 0, temppath
);
802 /*************************************************************************
803 * DuplicateIcon [SHELL32.@]
805 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
810 TRACE("%p %p\n", hInstance
, hIcon
);
812 if (GetIconInfo(hIcon
, &IconInfo
))
814 hDupIcon
= CreateIconIndirect(&IconInfo
);
816 /* clean up hbmMask and hbmColor */
817 DeleteObject(IconInfo
.hbmMask
);
818 DeleteObject(IconInfo
.hbmColor
);
824 /*************************************************************************
825 * ExtractIconA [SHELL32.@]
827 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
830 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
831 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
833 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
835 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
836 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
837 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
842 /*************************************************************************
843 * ExtractIconW [SHELL32.@]
845 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
849 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
851 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
853 if (nIconIndex
== (UINT
)-1)
855 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
856 if (ret
!= (UINT
)-1 && ret
)
857 return (HICON
)(UINT_PTR
)ret
;
861 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
865 else if (ret
> 0 && hIcon
)
871 HRESULT WINAPI
SHCreateFileExtractIconW(LPCWSTR file
, DWORD attribs
, REFIID riid
, void **ppv
)
873 FIXME("%s, %x, %s, %p\n", debugstr_w(file
), attribs
, debugstr_guid(riid
), ppv
);
878 /*************************************************************************
879 * Printer_LoadIconsW [SHELL32.205]
881 VOID WINAPI
Printer_LoadIconsW(LPCWSTR wsPrinterName
, HICON
* pLargeIcon
, HICON
* pSmallIcon
)
883 INT iconindex
=IDI_SHELL_PRINTER
;
885 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName
), pLargeIcon
, pSmallIcon
);
887 /* We should check if wsPrinterName is
888 1. the Default Printer or not
890 3. a Local Printer or a Network-Printer
891 and use different Icons
893 if((wsPrinterName
!= NULL
) && (wsPrinterName
[0] != 0))
895 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName
));
898 if(pLargeIcon
!= NULL
)
899 *pLargeIcon
= LoadImageW(shell32_hInstance
,
900 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
901 0, 0, LR_DEFAULTCOLOR
|LR_DEFAULTSIZE
);
903 if(pSmallIcon
!= NULL
)
904 *pSmallIcon
= LoadImageW(shell32_hInstance
,
905 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
906 16, 16, LR_DEFAULTCOLOR
);
909 /*************************************************************************
910 * Printers_RegisterWindowW [SHELL32.213]
911 * used by "printui.dll":
912 * find the Window of the given Type for the specific Printer and
913 * return the already existent hwnd or open a new window
915 BOOL WINAPI
Printers_RegisterWindowW(LPCWSTR wsPrinter
, DWORD dwType
,
916 HANDLE
* phClassPidl
, HWND
* phwnd
)
918 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter
), dwType
,
919 phClassPidl
, (phClassPidl
!= NULL
) ? *(phClassPidl
) : NULL
,
920 phwnd
, (phwnd
!= NULL
) ? *(phwnd
) : NULL
);
925 /*************************************************************************
926 * Printers_UnregisterWindow [SHELL32.214]
928 VOID WINAPI
Printers_UnregisterWindow(HANDLE hClassPidl
, HWND hwnd
)
930 FIXME("(%p, %p) stub!\n", hClassPidl
, hwnd
);
933 /*************************************************************************
934 * SHGetPropertyStoreFromParsingName [SHELL32.@]
936 HRESULT WINAPI
SHGetPropertyStoreFromParsingName(PCWSTR pszPath
, IBindCtx
*pbc
, GETPROPERTYSTOREFLAGS flags
, REFIID riid
, void **ppv
)
938 FIXME("(%s %p %u %p %p) stub!\n", debugstr_w(pszPath
), pbc
, flags
, riid
, ppv
);
942 /*************************************************************************/
947 LPCWSTR szOtherStuff
;
952 #define DROP_FIELD_TOP (-12)
954 static void paint_dropline( HDC hdc
, HWND hWnd
)
956 HWND hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_WINE_TEXT
);
959 if (!hWndCtl
) return;
960 GetWindowRect( hWndCtl
, &rect
);
961 MapWindowPoints( 0, hWnd
, (LPPOINT
)&rect
, 2 );
962 rect
.top
+= DROP_FIELD_TOP
;
963 rect
.bottom
= rect
.top
+ 2;
964 DrawEdge( hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
967 /*************************************************************************
968 * SHHelpShortcuts_RunDLLA [SHELL32.@]
971 DWORD WINAPI
SHHelpShortcuts_RunDLLA(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
973 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
977 /*************************************************************************
978 * SHHelpShortcuts_RunDLLA [SHELL32.@]
981 DWORD WINAPI
SHHelpShortcuts_RunDLLW(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
983 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
987 /*************************************************************************
988 * SHLoadInProc [SHELL32.@]
989 * Create an instance of specified object class from within
990 * the shell process and release it immediately
992 HRESULT WINAPI
SHLoadInProc (REFCLSID rclsid
)
996 TRACE("%s\n", debugstr_guid(rclsid
));
998 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
1001 IUnknown
* pUnk
= ptr
;
1002 IUnknown_Release(pUnk
);
1005 return DISP_E_MEMBERNOTFOUND
;
1008 static void add_authors( HWND list
)
1010 static const WCHAR eol
[] = {'\r','\n',0};
1011 static const WCHAR authors
[] = {'A','U','T','H','O','R','S',0};
1012 WCHAR
*strW
, *start
, *end
;
1013 HRSRC rsrc
= FindResourceW( shell32_hInstance
, authors
, (LPCWSTR
)RT_RCDATA
);
1014 char *strA
= LockResource( LoadResource( shell32_hInstance
, rsrc
));
1015 DWORD sizeW
, sizeA
= SizeofResource( shell32_hInstance
, rsrc
);
1018 sizeW
= MultiByteToWideChar( CP_UTF8
, 0, strA
, sizeA
, NULL
, 0 ) + 1;
1019 if (!(strW
= HeapAlloc( GetProcessHeap(), 0, sizeW
* sizeof(WCHAR
) ))) return;
1020 MultiByteToWideChar( CP_UTF8
, 0, strA
, sizeA
, strW
, sizeW
);
1021 strW
[sizeW
- 1] = 0;
1023 start
= strpbrkW( strW
, eol
); /* skip the header line */
1026 while (*start
&& strchrW( eol
, *start
)) start
++;
1028 end
= strpbrkW( start
, eol
);
1029 if (end
) *end
++ = 0;
1030 SendMessageW( list
, LB_ADDSTRING
, -1, (LPARAM
)start
);
1033 HeapFree( GetProcessHeap(), 0, strW
);
1036 /*************************************************************************
1037 * AboutDlgProc (internal)
1039 static INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
1050 ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
1051 WCHAR
template[512], buffer
[512], version
[64];
1052 extern const char *wine_get_build_id(void);
1056 SendDlgItemMessageW(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
1057 GetWindowTextW( hWnd
, template, sizeof(template)/sizeof(WCHAR
) );
1058 sprintfW( buffer
, template, info
->szApp
);
1059 SetWindowTextW( hWnd
, buffer
);
1060 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT1
), info
->szApp
);
1061 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT2
), info
->szOtherStuff
);
1062 GetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
),
1063 template, sizeof(template)/sizeof(WCHAR
) );
1064 MultiByteToWideChar( CP_UTF8
, 0, wine_get_build_id(), -1,
1065 version
, sizeof(version
)/sizeof(WCHAR
) );
1066 sprintfW( buffer
, template, version
);
1067 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
), buffer
);
1068 hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_LISTBOX
);
1069 SendMessageW( hWndCtl
, WM_SETREDRAW
, 0, 0 );
1070 SendMessageW( hWndCtl
, WM_SETFONT
, (WPARAM
)info
->hFont
, 0 );
1071 add_authors( hWndCtl
);
1072 SendMessageW( hWndCtl
, WM_SETREDRAW
, 1, 0 );
1080 HDC hDC
= BeginPaint( hWnd
, &ps
);
1081 paint_dropline( hDC
, hWnd
);
1082 EndPaint( hWnd
, &ps
);
1087 if (wParam
== IDOK
|| wParam
== IDCANCEL
)
1089 EndDialog(hWnd
, TRUE
);
1092 if (wParam
== IDC_ABOUT_LICENSE
)
1094 MSGBOXPARAMSW params
;
1096 params
.cbSize
= sizeof(params
);
1097 params
.hwndOwner
= hWnd
;
1098 params
.hInstance
= shell32_hInstance
;
1099 params
.lpszText
= MAKEINTRESOURCEW(IDS_LICENSE
);
1100 params
.lpszCaption
= MAKEINTRESOURCEW(IDS_LICENSE_CAPTION
);
1101 params
.dwStyle
= MB_ICONINFORMATION
| MB_OK
;
1102 params
.lpszIcon
= 0;
1103 params
.dwContextHelpId
= 0;
1104 params
.lpfnMsgBoxCallback
= NULL
;
1105 params
.dwLanguageId
= LANG_NEUTRAL
;
1106 MessageBoxIndirectW( ¶ms
);
1110 EndDialog(hWnd
, TRUE
);
1118 /*************************************************************************
1119 * ShellAboutA [SHELL32.288]
1121 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
, HICON hIcon
)
1124 LPWSTR appW
= NULL
, otherW
= NULL
;
1129 len
= MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, NULL
, 0);
1130 appW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1131 MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, appW
, len
);
1135 len
= MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, NULL
, 0);
1136 otherW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1137 MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, otherW
, len
);
1140 ret
= ShellAboutW(hWnd
, appW
, otherW
, hIcon
);
1142 HeapFree(GetProcessHeap(), 0, otherW
);
1143 HeapFree(GetProcessHeap(), 0, appW
);
1148 /*************************************************************************
1149 * ShellAboutW [SHELL32.289]
1151 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
1157 static const WCHAR wszSHELL_ABOUT_MSGBOX
[] =
1158 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1162 if (!hIcon
) hIcon
= LoadImageW( 0, (LPWSTR
)IDI_WINLOGO
, IMAGE_ICON
, 48, 48, LR_SHARED
);
1164 info
.szOtherStuff
= szOtherStuff
;
1167 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
1168 info
.hFont
= CreateFontIndirectW( &logFont
);
1170 bRet
= DialogBoxParamW( shell32_hInstance
, wszSHELL_ABOUT_MSGBOX
, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
1171 DeleteObject(info
.hFont
);
1175 /*************************************************************************
1176 * FreeIconList (SHELL32.@)
1178 void WINAPI
FreeIconList( DWORD dw
)
1180 FIXME("%x: stub\n",dw
);
1183 /*************************************************************************
1184 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1186 HRESULT WINAPI
SHLoadNonloadedIconOverlayIdentifiers( VOID
)
1192 /***********************************************************************
1193 * DllGetVersion [SHELL32.@]
1195 * Retrieves version information of the 'SHELL32.DLL'
1198 * pdvi [O] pointer to version information structure.
1202 * Failure: E_INVALIDARG
1205 * Returns version of a shell32.dll from IE4.01 SP1.
1208 HRESULT WINAPI
DllGetVersion (DLLVERSIONINFO
*pdvi
)
1210 /* FIXME: shouldn't these values come from the version resource? */
1211 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
1212 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1214 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
1215 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
1216 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
1217 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
1218 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1220 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
1223 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
1224 WINE_FILEVERSION_MINOR
,
1225 WINE_FILEVERSION_BUILD
,
1226 WINE_FILEVERSION_PLATFORMID
);
1228 TRACE("%u.%u.%u.%u\n",
1229 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
1230 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
1235 WARN("wrong DLLVERSIONINFO size from app\n");
1236 return E_INVALIDARG
;
1240 /*************************************************************************
1241 * global variables of the shell32.dll
1242 * all are once per process
1245 HINSTANCE shell32_hInstance
= 0;
1246 HIMAGELIST ShellSmallIconList
= 0;
1247 HIMAGELIST ShellBigIconList
= 0;
1250 /*************************************************************************
1254 * calling oleinitialize here breaks some apps.
1256 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
1258 TRACE("%p 0x%x %p\n", hinstDLL
, fdwReason
, fImpLoad
);
1262 case DLL_PROCESS_ATTACH
:
1263 shell32_hInstance
= hinstDLL
;
1264 DisableThreadLibraryCalls(shell32_hInstance
);
1266 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1267 GetModuleFileNameW(hinstDLL
, swShell32Name
, MAX_PATH
);
1268 swShell32Name
[MAX_PATH
- 1] = '\0';
1270 InitCommonControlsEx(NULL
);
1273 InitChangeNotifications();
1276 case DLL_PROCESS_DETACH
:
1277 shell32_hInstance
= 0;
1279 FreeChangeNotifications();
1285 /*************************************************************************
1286 * DllInstall [SHELL32.@]
1290 * BOOL bInstall - TRUE for install, FALSE for uninstall
1291 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1294 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1296 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1297 return S_OK
; /* indicate success */
1300 /***********************************************************************
1301 * DllCanUnloadNow (SHELL32.@)
1303 HRESULT WINAPI
DllCanUnloadNow(void)
1308 /***********************************************************************
1309 * DllRegisterServer (SHELL32.@)
1311 HRESULT WINAPI
DllRegisterServer(void)
1313 HRESULT hr
= __wine_register_resources( shell32_hInstance
);
1314 if (SUCCEEDED(hr
)) hr
= SHELL_RegisterShellFolders();
1318 /***********************************************************************
1319 * DllUnregisterServer (SHELL32.@)
1321 HRESULT WINAPI
DllUnregisterServer(void)
1323 return __wine_unregister_resources( shell32_hInstance
);
1326 /***********************************************************************
1327 * ExtractVersionResource16W (SHELL32.@)
1329 BOOL WINAPI
ExtractVersionResource16W(LPWSTR s
, DWORD d
)
1331 FIXME("(%s %x) stub!\n", debugstr_w(s
), d
);
1335 /***********************************************************************
1336 * InitNetworkAddressControl (SHELL32.@)
1338 BOOL WINAPI
InitNetworkAddressControl(void)
1344 /***********************************************************************
1345 * ShellHookProc (SHELL32.@)
1347 LRESULT CALLBACK
ShellHookProc(DWORD a
, DWORD b
, DWORD c
)
1353 /***********************************************************************
1354 * SHGetLocalizedName (SHELL32.@)
1356 HRESULT WINAPI
SHGetLocalizedName(LPCWSTR path
, LPWSTR module
, UINT size
, INT
*res
)
1358 FIXME("%s %p %u %p: stub\n", debugstr_w(path
), module
, size
, res
);
1362 /***********************************************************************
1363 * SetCurrentProcessExplicitAppUserModelID (SHELL32.@)
1365 HRESULT WINAPI
SetCurrentProcessExplicitAppUserModelID(PCWSTR appid
)
1367 FIXME("%s: stub\n", debugstr_w(appid
));
1371 /***********************************************************************
1372 * SHSetUnreadMailCountW (SHELL32.@)
1374 HRESULT WINAPI
SHSetUnreadMailCountW(LPCWSTR mailaddress
, DWORD count
, LPCWSTR executecommand
)
1376 FIXME("%s %x %s: stub\n", debugstr_w(mailaddress
), count
, debugstr_w(executecommand
));