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
43 #include "undocshell.h"
45 #include "shell32_main.h"
49 #include "wine/debug.h"
50 #include "wine/unicode.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
54 extern const char * const SHELL_Authors
[];
56 /*************************************************************************
57 * CommandLineToArgvW [SHELL32.@]
59 * We must interpret the quotes in the command line to rebuild the argv
61 * - arguments are separated by spaces or tabs
62 * - quotes serve as optional argument delimiters
64 * - escaped quotes must be converted back to '"'
66 * - an odd number of '\'s followed by '"' correspond to half that number
67 * of '\' followed by a '"' (extension of the above)
70 * - an even number of '\'s followed by a '"' correspond to half that number
71 * of '\', plus a regular quote serving as an argument delimiter (which
72 * means it does not appear in the result)
73 * 'a\\"b c"' -> 'a\b c'
74 * 'a\\\\"b c"' -> 'a\\b c'
75 * - '\' that are not followed by a '"' are copied literally
85 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
96 /* Return the path to the executable */
97 DWORD len
, deslen
=MAX_PATH
, size
;
99 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
102 if (!(argv
= LocalAlloc(LMEM_FIXED
, size
))) return NULL
;
103 len
= GetModuleFileNameW(0, (LPWSTR
)(argv
+1), deslen
);
109 if (len
< deslen
) break;
111 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
114 argv
[0]=(LPWSTR
)(argv
+1);
121 /* to get a writable copy */
128 if (*cs
==0 || ((*cs
==0x0009 || *cs
==0x0020) && !in_quotes
))
132 /* skip the remaining spaces */
133 while (*cs
==0x0009 || *cs
==0x0020) {
141 else if (*cs
==0x005c)
143 /* '\', count them */
146 else if ((*cs
==0x0022) && ((bcount
& 1)==0))
149 in_quotes
=!in_quotes
;
154 /* a regular character */
159 /* Allocate in a single lump, the string array, and the strings that go with it.
160 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
162 argv
=LocalAlloc(LMEM_FIXED
, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
165 cmdline
=(LPWSTR
)(argv
+argc
);
166 strcpyW(cmdline
, lpCmdline
);
174 if ((*s
==0x0009 || *s
==0x0020) && !in_quotes
)
176 /* Close the argument and copy it */
180 /* skip the remaining spaces */
183 } while (*s
==0x0009 || *s
==0x0020);
185 /* Start with a new argument */
200 /* Preceded by an even number of '\', this is half that
201 * number of '\', plus a quote which we erase.
204 in_quotes
=!in_quotes
;
209 /* Preceded by an odd number of '\', this is half that
210 * number of '\' followed by a '"'
220 /* a regular character */
236 static DWORD
shgfi_get_exe_type(LPCWSTR szFullPath
)
241 IMAGE_DOS_HEADER mz_header
;
246 status
= GetBinaryTypeW (szFullPath
, &BinaryType
);
249 if (BinaryType
== SCS_DOS_BINARY
|| BinaryType
== SCS_PIF_BINARY
)
252 hfile
= CreateFileW( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
253 NULL
, OPEN_EXISTING
, 0, 0 );
254 if ( hfile
== INVALID_HANDLE_VALUE
)
258 * The next section is adapted from MODULE_GetBinaryType, as we need
259 * to examine the image header to get OS and version information. We
260 * know from calling GetBinaryTypeA that the image is valid and either
261 * an NE or PE, so much error handling can be omitted.
262 * Seek to the start of the file and read the header information.
265 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
266 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
268 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
269 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
270 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
272 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
273 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
274 CloseHandle( hfile
);
275 /* DLL files are not executable and should return 0 */
276 if (nt
.FileHeader
.Characteristics
& IMAGE_FILE_DLL
)
278 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
)
280 return IMAGE_NT_SIGNATURE
|
281 (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24) |
282 (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
284 return IMAGE_NT_SIGNATURE
;
286 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
289 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
290 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
291 CloseHandle( hfile
);
292 if (ne
.ne_exetyp
== 2)
293 return IMAGE_OS2_SIGNATURE
| (ne
.ne_expver
<< 16);
296 CloseHandle( hfile
);
300 /*************************************************************************
301 * SHELL_IsShortcut [internal]
303 * Decide if an item id list points to a shell shortcut
305 BOOL
SHELL_IsShortcut(LPCITEMIDLIST pidlLast
)
307 char szTemp
[MAX_PATH
];
311 if (_ILGetExtension(pidlLast
, szTemp
, MAX_PATH
) &&
312 HCR_MapTypeToValueA(szTemp
, szTemp
, MAX_PATH
, TRUE
))
314 if (ERROR_SUCCESS
== RegOpenKeyExA(HKEY_CLASSES_ROOT
, szTemp
, 0, KEY_QUERY_VALUE
, &keyCls
))
316 if (ERROR_SUCCESS
== RegQueryValueExA(keyCls
, "IsShortcut", NULL
, NULL
, NULL
, NULL
))
326 #define SHGFI_KNOWN_FLAGS \
327 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
328 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
329 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
330 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
331 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
333 /*************************************************************************
334 * SHGetFileInfoW [SHELL32.@]
337 DWORD_PTR WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
338 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
340 WCHAR szLocation
[MAX_PATH
], szFullPath
[MAX_PATH
];
342 DWORD_PTR ret
= TRUE
;
343 DWORD dwAttributes
= 0;
344 IShellFolder
* psfParent
= NULL
;
345 IExtractIconW
* pei
= NULL
;
346 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
348 BOOL IconNotYetLoaded
=TRUE
;
351 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
352 (flags
& SHGFI_PIDL
)? "pidl" : debugstr_w(path
), dwFileAttributes
,
353 psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
358 /* windows initializes these values regardless of the flags */
361 psfi
->szDisplayName
[0] = '\0';
362 psfi
->szTypeName
[0] = '\0';
366 if (!(flags
& SHGFI_PIDL
))
368 /* SHGetFileInfo should work with absolute and relative paths */
369 if (PathIsRelativeW(path
))
371 GetCurrentDirectoryW(MAX_PATH
, szLocation
);
372 PathCombineW(szFullPath
, szLocation
, path
);
376 lstrcpynW(szFullPath
, path
, MAX_PATH
);
380 if (flags
& SHGFI_EXETYPE
)
382 if (flags
!= SHGFI_EXETYPE
)
384 return shgfi_get_exe_type(szFullPath
);
388 * psfi is NULL normally to query EXE type. If it is NULL, none of the
389 * below makes sense anyway. Windows allows this and just returns FALSE
395 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
397 * The pidl functions fail on not existing file names
400 if (flags
& SHGFI_PIDL
)
402 pidl
= ILClone((LPCITEMIDLIST
)path
);
404 else if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
406 hr
= SHILCreateFromPathW(szFullPath
, &pidl
, &dwAttributes
);
409 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
411 /* get the parent shellfolder */
414 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
,
415 (LPCITEMIDLIST
*)&pidlLast
);
417 pidlLast
= ILClone(pidlLast
);
422 ERR("pidl is null!\n");
427 /* get the attributes of the child */
428 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
430 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
432 psfi
->dwAttributes
= 0xffffffff;
435 IShellFolder_GetAttributesOf( psfParent
, 1, (LPCITEMIDLIST
*)&pidlLast
,
436 &(psfi
->dwAttributes
) );
439 /* get the displayname */
440 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
442 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
444 lstrcpyW (psfi
->szDisplayName
, PathFindFileNameW(szFullPath
));
449 hr
= IShellFolder_GetDisplayNameOf( psfParent
, pidlLast
,
450 SHGDN_INFOLDER
, &str
);
451 StrRetToStrNW (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
455 /* get the type name */
456 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
458 static const WCHAR szFile
[] = { 'F','i','l','e',0 };
459 static const WCHAR szDashFile
[] = { '-','f','i','l','e',0 };
461 if (!(flags
& SHGFI_USEFILEATTRIBUTES
) || (flags
& SHGFI_PIDL
))
465 _ILGetFileType(pidlLast
, ftype
, 80);
466 MultiByteToWideChar(CP_ACP
, 0, ftype
, -1, psfi
->szTypeName
, 80 );
470 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
471 strcatW (psfi
->szTypeName
, szFile
);
476 lstrcpyW(sTemp
,PathFindExtensionW(szFullPath
));
477 if (!( HCR_MapTypeToValueW(sTemp
, sTemp
, 64, TRUE
) &&
478 HCR_MapTypeToValueW(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
480 lstrcpynW (psfi
->szTypeName
, sTemp
, 64);
481 strcatW (psfi
->szTypeName
, szDashFile
);
488 if (flags
& SHGFI_OPENICON
)
489 uGilFlags
|= GIL_OPENICON
;
491 if (flags
& SHGFI_LINKOVERLAY
)
492 uGilFlags
|= GIL_FORSHORTCUT
;
493 else if ((flags
&SHGFI_ADDOVERLAYS
) ||
494 (flags
&(SHGFI_ICON
|SHGFI_SMALLICON
))==SHGFI_ICON
)
496 if (SHELL_IsShortcut(pidlLast
))
497 uGilFlags
|= GIL_FORSHORTCUT
;
500 if (flags
& SHGFI_OVERLAYINDEX
)
501 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
503 if (flags
& SHGFI_SELECTED
)
504 FIXME("set icon to selected, stub\n");
506 if (flags
& SHGFI_SHELLICONSIZE
)
507 FIXME("set icon to shell size, stub\n");
509 /* get the iconlocation */
510 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
514 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
516 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
518 lstrcpyW(psfi
->szDisplayName
, swShell32Name
);
519 psfi
->iIcon
= -IDI_SHELL_FOLDER
;
524 static const WCHAR p1W
[] = {'%','1',0};
525 WCHAR sTemp
[MAX_PATH
];
527 szExt
= PathFindExtensionW(szFullPath
);
528 TRACE("szExt=%s\n", debugstr_w(szExt
));
530 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
531 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &psfi
->iIcon
))
533 if (lstrcmpW(p1W
, sTemp
))
534 strcpyW(psfi
->szDisplayName
, sTemp
);
537 /* the icon is in the file */
538 strcpyW(psfi
->szDisplayName
, szFullPath
);
547 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1,
548 (LPCITEMIDLIST
*)&pidlLast
, &IID_IExtractIconW
,
549 &uDummy
, (LPVOID
*)&pei
);
552 hr
= IExtractIconW_GetIconLocation(pei
, uGilFlags
,
553 szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
555 if (uFlags
& GIL_NOTFILENAME
)
559 lstrcpyW (psfi
->szDisplayName
, szLocation
);
560 psfi
->iIcon
= iIndex
;
562 IExtractIconW_Release(pei
);
567 /* get icon index (or load icon)*/
568 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
570 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
572 WCHAR sTemp
[MAX_PATH
];
576 lstrcpynW(sTemp
, szFullPath
, MAX_PATH
);
578 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
579 psfi
->iIcon
= SIC_GetIconIndex(swShell32Name
, -IDI_SHELL_FOLDER
, 0);
582 static const WCHAR p1W
[] = {'%','1',0};
585 szExt
= PathFindExtensionW(sTemp
);
587 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
588 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &icon_idx
))
590 if (!lstrcmpW(p1W
,sTemp
)) /* icon is in the file */
591 strcpyW(sTemp
, szFullPath
);
593 if (flags
& SHGFI_SYSICONINDEX
)
595 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,icon_idx
,0);
596 if (psfi
->iIcon
== -1)
602 if (flags
& SHGFI_SMALLICON
)
603 ret
= PrivateExtractIconsW( sTemp
,icon_idx
,
604 GetSystemMetrics( SM_CXSMICON
),
605 GetSystemMetrics( SM_CYSMICON
),
606 &psfi
->hIcon
, 0, 1, 0);
608 ret
= PrivateExtractIconsW( sTemp
, icon_idx
,
609 GetSystemMetrics( SM_CXICON
),
610 GetSystemMetrics( SM_CYICON
),
611 &psfi
->hIcon
, 0, 1, 0);
612 if (ret
!= 0 && ret
!= (UINT
)-1)
614 IconNotYetLoaded
=FALSE
;
615 psfi
->iIcon
= icon_idx
;
623 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
624 uGilFlags
, &(psfi
->iIcon
))))
629 if (ret
&& (flags
& SHGFI_SYSICONINDEX
))
631 if (flags
& SHGFI_SMALLICON
)
632 ret
= (DWORD_PTR
) ShellSmallIconList
;
634 ret
= (DWORD_PTR
) ShellBigIconList
;
639 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
641 if (flags
& SHGFI_SMALLICON
)
642 psfi
->hIcon
= ImageList_GetIcon( ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
644 psfi
->hIcon
= ImageList_GetIcon( ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
647 if (flags
& ~SHGFI_KNOWN_FLAGS
)
648 FIXME("unknown flags %08x\n", flags
& ~SHGFI_KNOWN_FLAGS
);
651 IShellFolder_Release(psfParent
);
658 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
659 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
,
660 debugstr_w(psfi
->szDisplayName
), debugstr_w(psfi
->szTypeName
), ret
);
665 /*************************************************************************
666 * SHGetFileInfoA [SHELL32.@]
669 * MSVBVM60.__vbaNew2 expects this function to return a value in range
670 * 1 .. 0x7fff when the function succeeds and flags does not contain
671 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
673 DWORD_PTR WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
674 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
678 LPWSTR temppath
= NULL
;
681 SHFILEINFOW temppsfi
;
683 if (flags
& SHGFI_PIDL
)
685 /* path contains a pidl */
686 pathW
= (LPCWSTR
)path
;
690 len
= MultiByteToWideChar(CP_ACP
, 0, path
, -1, NULL
, 0);
691 temppath
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
692 MultiByteToWideChar(CP_ACP
, 0, path
, -1, temppath
, len
);
696 if (psfi
&& (flags
& SHGFI_ATTR_SPECIFIED
))
697 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
700 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, NULL
, sizeof(temppsfi
), flags
);
702 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
706 if(flags
& SHGFI_ICON
)
707 psfi
->hIcon
=temppsfi
.hIcon
;
708 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
709 psfi
->iIcon
=temppsfi
.iIcon
;
710 if(flags
& SHGFI_ATTRIBUTES
)
711 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
712 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
714 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szDisplayName
, -1,
715 psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
), NULL
, NULL
);
717 if(flags
& SHGFI_TYPENAME
)
719 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szTypeName
, -1,
720 psfi
->szTypeName
, sizeof(psfi
->szTypeName
), NULL
, NULL
);
724 HeapFree(GetProcessHeap(), 0, temppath
);
729 /*************************************************************************
730 * DuplicateIcon [SHELL32.@]
732 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
737 TRACE("%p %p\n", hInstance
, hIcon
);
739 if (GetIconInfo(hIcon
, &IconInfo
))
741 hDupIcon
= CreateIconIndirect(&IconInfo
);
743 /* clean up hbmMask and hbmColor */
744 DeleteObject(IconInfo
.hbmMask
);
745 DeleteObject(IconInfo
.hbmColor
);
751 /*************************************************************************
752 * ExtractIconA [SHELL32.@]
754 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
757 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
758 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
760 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
762 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
763 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
764 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
769 /*************************************************************************
770 * ExtractIconW [SHELL32.@]
772 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
776 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
778 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
780 if (nIconIndex
== (UINT
)-1)
782 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
783 if (ret
!= (UINT
)-1 && ret
)
784 return (HICON
)(UINT_PTR
)ret
;
788 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
792 else if (ret
> 0 && hIcon
)
798 HRESULT WINAPI
SHCreateFileExtractIconW(LPCWSTR file
, DWORD attribs
, REFIID riid
, void **ppv
)
800 FIXME("%s, %x, %s, %p\n", debugstr_w(file
), attribs
, debugstr_guid(riid
), ppv
);
805 /*************************************************************************
806 * Printer_LoadIconsW [SHELL32.205]
808 VOID WINAPI
Printer_LoadIconsW(LPCWSTR wsPrinterName
, HICON
* pLargeIcon
, HICON
* pSmallIcon
)
810 INT iconindex
=IDI_SHELL_PRINTER
;
812 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName
), pLargeIcon
, pSmallIcon
);
814 /* We should check if wsPrinterName is
815 1. the Default Printer or not
817 3. a Local Printer or a Network-Printer
818 and use different Icons
820 if((wsPrinterName
!= NULL
) && (wsPrinterName
[0] != 0))
822 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName
));
825 if(pLargeIcon
!= NULL
)
826 *pLargeIcon
= LoadImageW(shell32_hInstance
,
827 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
828 0, 0, LR_DEFAULTCOLOR
|LR_DEFAULTSIZE
);
830 if(pSmallIcon
!= NULL
)
831 *pSmallIcon
= LoadImageW(shell32_hInstance
,
832 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
833 16, 16, LR_DEFAULTCOLOR
);
836 /*************************************************************************
837 * Printers_RegisterWindowW [SHELL32.213]
838 * used by "printui.dll":
839 * find the Window of the given Type for the specific Printer and
840 * return the already existent hwnd or open a new window
842 BOOL WINAPI
Printers_RegisterWindowW(LPCWSTR wsPrinter
, DWORD dwType
,
843 HANDLE
* phClassPidl
, HWND
* phwnd
)
845 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter
), dwType
,
846 phClassPidl
, (phClassPidl
!= NULL
) ? *(phClassPidl
) : NULL
,
847 phwnd
, (phwnd
!= NULL
) ? *(phwnd
) : NULL
);
852 /*************************************************************************
853 * Printers_UnregisterWindow [SHELL32.214]
855 VOID WINAPI
Printers_UnregisterWindow(HANDLE hClassPidl
, HWND hwnd
)
857 FIXME("(%p, %p) stub!\n", hClassPidl
, hwnd
);
860 /*************************************************************************
861 * SHGetPropertyStoreFromParsingName [SHELL32.@]
863 HRESULT WINAPI
SHGetPropertyStoreFromParsingName(PCWSTR pszPath
, IBindCtx
*pbc
, GETPROPERTYSTOREFLAGS flags
, REFIID riid
, void **ppv
)
865 FIXME("(%s %p %u %p %p) stub!\n", debugstr_w(pszPath
), pbc
, flags
, riid
, ppv
);
869 /*************************************************************************/
874 LPCWSTR szOtherStuff
;
879 #define DROP_FIELD_TOP (-12)
881 static void paint_dropline( HDC hdc
, HWND hWnd
)
883 HWND hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_WINE_TEXT
);
886 if (!hWndCtl
) return;
887 GetWindowRect( hWndCtl
, &rect
);
888 MapWindowPoints( 0, hWnd
, (LPPOINT
)&rect
, 2 );
889 rect
.top
+= DROP_FIELD_TOP
;
890 rect
.bottom
= rect
.top
+ 2;
891 DrawEdge( hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
894 /*************************************************************************
895 * SHHelpShortcuts_RunDLLA [SHELL32.@]
898 DWORD WINAPI
SHHelpShortcuts_RunDLLA(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
900 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
904 /*************************************************************************
905 * SHHelpShortcuts_RunDLLA [SHELL32.@]
908 DWORD WINAPI
SHHelpShortcuts_RunDLLW(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
910 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
914 /*************************************************************************
915 * SHLoadInProc [SHELL32.@]
916 * Create an instance of specified object class from within
917 * the shell process and release it immediately
919 HRESULT WINAPI
SHLoadInProc (REFCLSID rclsid
)
923 TRACE("%s\n", debugstr_guid(rclsid
));
925 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
928 IUnknown
* pUnk
= ptr
;
929 IUnknown_Release(pUnk
);
932 return DISP_E_MEMBERNOTFOUND
;
935 /*************************************************************************
936 * AboutDlgProc (internal)
938 static INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
949 ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
950 WCHAR
template[512], buffer
[512], version
[64];
951 extern const char *wine_get_build_id(void);
955 const char* const *pstr
= SHELL_Authors
;
956 SendDlgItemMessageW(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
957 GetWindowTextW( hWnd
, template, sizeof(template)/sizeof(WCHAR
) );
958 sprintfW( buffer
, template, info
->szApp
);
959 SetWindowTextW( hWnd
, buffer
);
960 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT1
), info
->szApp
);
961 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT2
), info
->szOtherStuff
);
962 GetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
),
963 template, sizeof(template)/sizeof(WCHAR
) );
964 MultiByteToWideChar( CP_UTF8
, 0, wine_get_build_id(), -1,
965 version
, sizeof(version
)/sizeof(WCHAR
) );
966 sprintfW( buffer
, template, version
);
967 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
), buffer
);
968 hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_LISTBOX
);
969 SendMessageW( hWndCtl
, WM_SETREDRAW
, 0, 0 );
970 SendMessageW( hWndCtl
, WM_SETFONT
, (WPARAM
)info
->hFont
, 0 );
973 /* authors list is in utf-8 format */
974 MultiByteToWideChar( CP_UTF8
, 0, *pstr
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) );
975 SendMessageW( hWndCtl
, LB_ADDSTRING
, -1, (LPARAM
)buffer
);
978 SendMessageW( hWndCtl
, WM_SETREDRAW
, 1, 0 );
986 HDC hDC
= BeginPaint( hWnd
, &ps
);
987 paint_dropline( hDC
, hWnd
);
988 EndPaint( hWnd
, &ps
);
993 if (wParam
== IDOK
|| wParam
== IDCANCEL
)
995 EndDialog(hWnd
, TRUE
);
998 if (wParam
== IDC_ABOUT_LICENSE
)
1000 MSGBOXPARAMSW params
;
1002 params
.cbSize
= sizeof(params
);
1003 params
.hwndOwner
= hWnd
;
1004 params
.hInstance
= shell32_hInstance
;
1005 params
.lpszText
= MAKEINTRESOURCEW(IDS_LICENSE
);
1006 params
.lpszCaption
= MAKEINTRESOURCEW(IDS_LICENSE_CAPTION
);
1007 params
.dwStyle
= MB_ICONINFORMATION
| MB_OK
;
1008 params
.lpszIcon
= 0;
1009 params
.dwContextHelpId
= 0;
1010 params
.lpfnMsgBoxCallback
= NULL
;
1011 params
.dwLanguageId
= LANG_NEUTRAL
;
1012 MessageBoxIndirectW( ¶ms
);
1016 EndDialog(hWnd
, TRUE
);
1024 /*************************************************************************
1025 * ShellAboutA [SHELL32.288]
1027 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
, HICON hIcon
)
1030 LPWSTR appW
= NULL
, otherW
= NULL
;
1035 len
= MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, NULL
, 0);
1036 appW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1037 MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, appW
, len
);
1041 len
= MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, NULL
, 0);
1042 otherW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1043 MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, otherW
, len
);
1046 ret
= ShellAboutW(hWnd
, appW
, otherW
, hIcon
);
1048 HeapFree(GetProcessHeap(), 0, otherW
);
1049 HeapFree(GetProcessHeap(), 0, appW
);
1054 /*************************************************************************
1055 * ShellAboutW [SHELL32.289]
1057 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
1063 static const WCHAR wszSHELL_ABOUT_MSGBOX
[] =
1064 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1068 if (!hIcon
) hIcon
= LoadImageW( 0, (LPWSTR
)IDI_WINLOGO
, IMAGE_ICON
, 48, 48, LR_SHARED
);
1070 info
.szOtherStuff
= szOtherStuff
;
1073 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
1074 info
.hFont
= CreateFontIndirectW( &logFont
);
1076 bRet
= DialogBoxParamW( shell32_hInstance
, wszSHELL_ABOUT_MSGBOX
, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
1077 DeleteObject(info
.hFont
);
1081 /*************************************************************************
1082 * FreeIconList (SHELL32.@)
1084 void WINAPI
FreeIconList( DWORD dw
)
1086 FIXME("%x: stub\n",dw
);
1089 /*************************************************************************
1090 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1092 HRESULT WINAPI
SHLoadNonloadedIconOverlayIdentifiers( VOID
)
1098 /***********************************************************************
1099 * DllGetVersion [SHELL32.@]
1101 * Retrieves version information of the 'SHELL32.DLL'
1104 * pdvi [O] pointer to version information structure.
1108 * Failure: E_INVALIDARG
1111 * Returns version of a shell32.dll from IE4.01 SP1.
1114 HRESULT WINAPI
DllGetVersion (DLLVERSIONINFO
*pdvi
)
1116 /* FIXME: shouldn't these values come from the version resource? */
1117 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
1118 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1120 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
1121 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
1122 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
1123 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
1124 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1126 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
1129 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
1130 WINE_FILEVERSION_MINOR
,
1131 WINE_FILEVERSION_BUILD
,
1132 WINE_FILEVERSION_PLATFORMID
);
1134 TRACE("%u.%u.%u.%u\n",
1135 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
1136 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
1141 WARN("wrong DLLVERSIONINFO size from app\n");
1142 return E_INVALIDARG
;
1146 /*************************************************************************
1147 * global variables of the shell32.dll
1148 * all are once per process
1151 HINSTANCE shell32_hInstance
= 0;
1152 HIMAGELIST ShellSmallIconList
= 0;
1153 HIMAGELIST ShellBigIconList
= 0;
1156 /*************************************************************************
1160 * calling oleinitialize here breaks sone apps.
1162 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
1164 TRACE("%p 0x%x %p\n", hinstDLL
, fdwReason
, fImpLoad
);
1168 case DLL_PROCESS_ATTACH
:
1169 shell32_hInstance
= hinstDLL
;
1170 DisableThreadLibraryCalls(shell32_hInstance
);
1172 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1173 GetModuleFileNameW(hinstDLL
, swShell32Name
, MAX_PATH
);
1174 swShell32Name
[MAX_PATH
- 1] = '\0';
1176 InitCommonControlsEx(NULL
);
1179 InitChangeNotifications();
1182 case DLL_PROCESS_DETACH
:
1183 shell32_hInstance
= 0;
1185 FreeChangeNotifications();
1191 /*************************************************************************
1192 * DllInstall [SHELL32.@]
1196 * BOOL bInstall - TRUE for install, FALSE for uninstall
1197 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1200 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1202 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1203 return S_OK
; /* indicate success */
1206 /***********************************************************************
1207 * DllCanUnloadNow (SHELL32.@)
1209 HRESULT WINAPI
DllCanUnloadNow(void)
1214 /***********************************************************************
1215 * ExtractVersionResource16W (SHELL32.@)
1217 BOOL WINAPI
ExtractVersionResource16W(LPWSTR s
, DWORD d
)
1219 FIXME("(%s %x) stub!\n", debugstr_w(s
), d
);
1223 /***********************************************************************
1224 * InitNetworkAddressControl (SHELL32.@)
1226 BOOL WINAPI
InitNetworkAddressControl(void)
1232 /***********************************************************************
1233 * ShellHookProc (SHELL32.@)
1235 LRESULT CALLBACK
ShellHookProc(DWORD a
, DWORD b
, DWORD c
)
1241 HRESULT WINAPI
SHGetLocalizedName(LPCWSTR path
, LPWSTR module
, UINT size
, INT
*res
)
1243 FIXME("%s %p %u %p: stub\n", debugstr_w(path
), module
, size
, res
);