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
42 #include "undocshell.h"
44 #include "shell32_main.h"
48 #include "wine/debug.h"
49 #include "wine/unicode.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
53 extern const char * const SHELL_Authors
[];
55 /*************************************************************************
56 * CommandLineToArgvW [SHELL32.@]
58 * We must interpret the quotes in the command line to rebuild the argv
60 * - arguments are separated by spaces or tabs
61 * - quotes serve as optional argument delimiters
63 * - escaped quotes must be converted back to '"'
65 * - an odd number of '\'s followed by '"' correspond to half that number
66 * of '\' followed by a '"' (extension of the above)
69 * - an even number of '\'s followed by a '"' correspond to half that number
70 * of '\', plus a regular quote serving as an argument delimiter (which
71 * means it does not appear in the result)
72 * 'a\\"b c"' -> 'a\b c'
73 * 'a\\\\"b c"' -> 'a\\b c'
74 * - '\' that are not followed by a '"' are copied literally
84 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
95 /* Return the path to the executable */
98 argv
=LocalAlloc(LMEM_FIXED
, size
);
101 len
= GetModuleFileNameW(0, (LPWSTR
)(argv
+1), (size
-sizeof(LPWSTR
))/sizeof(WCHAR
));
107 if (len
< size
) break;
109 argv
=LocalReAlloc(argv
, size
, 0);
111 argv
[0]=(LPWSTR
)(argv
+1);
118 /* to get a writable copy */
125 if (*cs
==0 || ((*cs
==0x0009 || *cs
==0x0020) && !in_quotes
))
129 /* skip the remaining spaces */
130 while (*cs
==0x0009 || *cs
==0x0020) {
138 else if (*cs
==0x005c)
140 /* '\', count them */
143 else if ((*cs
==0x0022) && ((bcount
& 1)==0))
146 in_quotes
=!in_quotes
;
151 /* a regular character */
156 /* Allocate in a single lump, the string array, and the strings that go with it.
157 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
159 argv
=LocalAlloc(LMEM_FIXED
, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
162 cmdline
=(LPWSTR
)(argv
+argc
);
163 strcpyW(cmdline
, lpCmdline
);
171 if ((*s
==0x0009 || *s
==0x0020) && !in_quotes
)
173 /* Close the argument and copy it */
177 /* skip the remaining spaces */
180 } while (*s
==0x0009 || *s
==0x0020);
182 /* Start with a new argument */
197 /* Preceded by an even number of '\', this is half that
198 * number of '\', plus a quote which we erase.
201 in_quotes
=!in_quotes
;
206 /* Preceded by an odd number of '\', this is half that
207 * number of '\' followed by a '"'
217 /* a regular character */
233 static DWORD
shgfi_get_exe_type(LPCWSTR szFullPath
)
238 IMAGE_DOS_HEADER mz_header
;
243 status
= GetBinaryTypeW (szFullPath
, &BinaryType
);
246 if (BinaryType
== SCS_DOS_BINARY
|| BinaryType
== SCS_PIF_BINARY
)
249 hfile
= CreateFileW( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
250 NULL
, OPEN_EXISTING
, 0, 0 );
251 if ( hfile
== INVALID_HANDLE_VALUE
)
255 * The next section is adapted from MODULE_GetBinaryType, as we need
256 * to examine the image header to get OS and version information. We
257 * know from calling GetBinaryTypeA that the image is valid and either
258 * an NE or PE, so much error handling can be omitted.
259 * Seek to the start of the file and read the header information.
262 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
263 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
265 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
266 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
267 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
269 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
270 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
271 CloseHandle( hfile
);
272 /* DLL files are not executable and should return 0 */
273 if (nt
.FileHeader
.Characteristics
& IMAGE_FILE_DLL
)
275 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
)
277 return IMAGE_NT_SIGNATURE
|
278 (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24) |
279 (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
281 return IMAGE_NT_SIGNATURE
;
283 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
286 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
287 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
288 CloseHandle( hfile
);
289 if (ne
.ne_exetyp
== 2)
290 return IMAGE_OS2_SIGNATURE
| (ne
.ne_expver
<< 16);
293 CloseHandle( hfile
);
297 /*************************************************************************
298 * SHELL_IsShortcut [internal]
300 * Decide if an item id list points to a shell shortcut
302 BOOL
SHELL_IsShortcut(LPCITEMIDLIST pidlLast
)
304 char szTemp
[MAX_PATH
];
308 if (_ILGetExtension(pidlLast
, szTemp
, MAX_PATH
) &&
309 HCR_MapTypeToValueA(szTemp
, szTemp
, MAX_PATH
, TRUE
))
311 if (ERROR_SUCCESS
== RegOpenKeyExA(HKEY_CLASSES_ROOT
, szTemp
, 0, KEY_QUERY_VALUE
, &keyCls
))
313 if (ERROR_SUCCESS
== RegQueryValueExA(keyCls
, "IsShortcut", NULL
, NULL
, NULL
, NULL
))
323 #define SHGFI_KNOWN_FLAGS \
324 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
325 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
326 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
327 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
328 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
330 /*************************************************************************
331 * SHGetFileInfoW [SHELL32.@]
334 DWORD_PTR WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
335 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
337 WCHAR szLocation
[MAX_PATH
], szFullPath
[MAX_PATH
];
339 DWORD_PTR ret
= TRUE
;
340 DWORD dwAttributes
= 0;
341 IShellFolder
* psfParent
= NULL
;
342 IExtractIconW
* pei
= NULL
;
343 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
345 BOOL IconNotYetLoaded
=TRUE
;
348 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
349 (flags
& SHGFI_PIDL
)? "pidl" : debugstr_w(path
), dwFileAttributes
,
350 psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
355 /* windows initializes these values regardless of the flags */
358 psfi
->szDisplayName
[0] = '\0';
359 psfi
->szTypeName
[0] = '\0';
363 if (!(flags
& SHGFI_PIDL
))
365 /* SHGetFileInfo should work with absolute and relative paths */
366 if (PathIsRelativeW(path
))
368 GetCurrentDirectoryW(MAX_PATH
, szLocation
);
369 PathCombineW(szFullPath
, szLocation
, path
);
373 lstrcpynW(szFullPath
, path
, MAX_PATH
);
377 if (flags
& SHGFI_EXETYPE
)
379 if (flags
!= SHGFI_EXETYPE
)
381 return shgfi_get_exe_type(szFullPath
);
385 * psfi is NULL normally to query EXE type. If it is NULL, none of the
386 * below makes sense anyway. Windows allows this and just returns FALSE
392 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
394 * The pidl functions fail on not existing file names
397 if (flags
& SHGFI_PIDL
)
399 pidl
= ILClone((LPCITEMIDLIST
)path
);
401 else if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
403 hr
= SHILCreateFromPathW(szFullPath
, &pidl
, &dwAttributes
);
406 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
408 /* get the parent shellfolder */
411 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
,
412 (LPCITEMIDLIST
*)&pidlLast
);
414 pidlLast
= ILClone(pidlLast
);
419 ERR("pidl is null!\n");
424 /* get the attributes of the child */
425 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
427 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
429 psfi
->dwAttributes
= 0xffffffff;
432 IShellFolder_GetAttributesOf( psfParent
, 1, (LPCITEMIDLIST
*)&pidlLast
,
433 &(psfi
->dwAttributes
) );
436 /* get the displayname */
437 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
439 if (flags
& SHGFI_USEFILEATTRIBUTES
)
441 lstrcpyW (psfi
->szDisplayName
, PathFindFileNameW(szFullPath
));
446 hr
= IShellFolder_GetDisplayNameOf( psfParent
, pidlLast
,
447 SHGDN_INFOLDER
, &str
);
448 StrRetToStrNW (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
452 /* get the type name */
453 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
455 static const WCHAR szFile
[] = { 'F','i','l','e',0 };
456 static const WCHAR szDashFile
[] = { '-','f','i','l','e',0 };
458 if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
462 _ILGetFileType(pidlLast
, ftype
, 80);
463 MultiByteToWideChar(CP_ACP
, 0, ftype
, -1, psfi
->szTypeName
, 80 );
467 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
468 strcatW (psfi
->szTypeName
, szFile
);
473 lstrcpyW(sTemp
,PathFindExtensionW(szFullPath
));
474 if (!( HCR_MapTypeToValueW(sTemp
, sTemp
, 64, TRUE
) &&
475 HCR_MapTypeToValueW(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
477 lstrcpynW (psfi
->szTypeName
, sTemp
, 64);
478 strcatW (psfi
->szTypeName
, szDashFile
);
485 if (flags
& SHGFI_OPENICON
)
486 uGilFlags
|= GIL_OPENICON
;
488 if (flags
& SHGFI_LINKOVERLAY
)
489 uGilFlags
|= GIL_FORSHORTCUT
;
490 else if ((flags
&SHGFI_ADDOVERLAYS
) ||
491 (flags
&(SHGFI_ICON
|SHGFI_SMALLICON
))==SHGFI_ICON
)
493 if (SHELL_IsShortcut(pidlLast
))
494 uGilFlags
|= GIL_FORSHORTCUT
;
497 if (flags
& SHGFI_OVERLAYINDEX
)
498 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
500 if (flags
& SHGFI_SELECTED
)
501 FIXME("set icon to selected, stub\n");
503 if (flags
& SHGFI_SHELLICONSIZE
)
504 FIXME("set icon to shell size, stub\n");
506 /* get the iconlocation */
507 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
511 if (flags
& SHGFI_USEFILEATTRIBUTES
)
513 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
515 lstrcpyW(psfi
->szDisplayName
, swShell32Name
);
516 psfi
->iIcon
= -IDI_SHELL_FOLDER
;
521 static const WCHAR p1W
[] = {'%','1',0};
522 WCHAR sTemp
[MAX_PATH
];
524 szExt
= PathFindExtensionW(szFullPath
);
525 TRACE("szExt=%s\n", debugstr_w(szExt
));
527 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
528 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &psfi
->iIcon
))
530 if (lstrcmpW(p1W
, sTemp
))
531 strcpyW(psfi
->szDisplayName
, sTemp
);
534 /* the icon is in the file */
535 strcpyW(psfi
->szDisplayName
, szFullPath
);
544 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1,
545 (LPCITEMIDLIST
*)&pidlLast
, &IID_IExtractIconW
,
546 &uDummy
, (LPVOID
*)&pei
);
549 hr
= IExtractIconW_GetIconLocation(pei
, uGilFlags
,
550 szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
552 if (uFlags
& GIL_NOTFILENAME
)
556 lstrcpyW (psfi
->szDisplayName
, szLocation
);
557 psfi
->iIcon
= iIndex
;
559 IExtractIconW_Release(pei
);
564 /* get icon index (or load icon)*/
565 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
567 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
569 WCHAR sTemp
[MAX_PATH
];
573 lstrcpynW(sTemp
, szFullPath
, MAX_PATH
);
575 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
576 psfi
->iIcon
= SIC_GetIconIndex(swShell32Name
, -IDI_SHELL_FOLDER
, 0);
579 static const WCHAR p1W
[] = {'%','1',0};
582 szExt
= PathFindExtensionW(sTemp
);
584 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
585 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &icon_idx
))
587 if (!lstrcmpW(p1W
,sTemp
)) /* icon is in the file */
588 strcpyW(sTemp
, szFullPath
);
590 if (flags
& SHGFI_SYSICONINDEX
)
592 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,icon_idx
,0);
593 if (psfi
->iIcon
== -1)
599 if (flags
& SHGFI_SMALLICON
)
600 ret
= PrivateExtractIconsW( sTemp
,icon_idx
,
601 GetSystemMetrics( SM_CXSMICON
),
602 GetSystemMetrics( SM_CYSMICON
),
603 &psfi
->hIcon
, 0, 1, 0);
605 ret
= PrivateExtractIconsW( sTemp
, icon_idx
,
606 GetSystemMetrics( SM_CXICON
),
607 GetSystemMetrics( SM_CYICON
),
608 &psfi
->hIcon
, 0, 1, 0);
609 if (ret
!= 0 && ret
!= (UINT
)-1)
611 IconNotYetLoaded
=FALSE
;
612 psfi
->iIcon
= icon_idx
;
620 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
621 uGilFlags
, &(psfi
->iIcon
))))
626 if (ret
&& (flags
& SHGFI_SYSICONINDEX
))
628 if (flags
& SHGFI_SMALLICON
)
629 ret
= (DWORD_PTR
) ShellSmallIconList
;
631 ret
= (DWORD_PTR
) ShellBigIconList
;
636 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
638 if (flags
& SHGFI_SMALLICON
)
639 psfi
->hIcon
= ImageList_GetIcon( ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
641 psfi
->hIcon
= ImageList_GetIcon( ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
644 if (flags
& ~SHGFI_KNOWN_FLAGS
)
645 FIXME("unknown flags %08x\n", flags
& ~SHGFI_KNOWN_FLAGS
);
648 IShellFolder_Release(psfParent
);
655 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
656 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
,
657 debugstr_w(psfi
->szDisplayName
), debugstr_w(psfi
->szTypeName
), ret
);
662 /*************************************************************************
663 * SHGetFileInfoA [SHELL32.@]
666 * MSVBVM60.__vbaNew2 expects this function to return a value in range
667 * 1 .. 0x7fff when the function succeeds and flags does not contain
668 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
670 DWORD_PTR WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
671 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
675 LPWSTR temppath
= NULL
;
678 SHFILEINFOW temppsfi
;
680 if (flags
& SHGFI_PIDL
)
682 /* path contains a pidl */
683 pathW
= (LPCWSTR
)path
;
687 len
= MultiByteToWideChar(CP_ACP
, 0, path
, -1, NULL
, 0);
688 temppath
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
689 MultiByteToWideChar(CP_ACP
, 0, path
, -1, temppath
, len
);
693 if (psfi
&& (flags
& SHGFI_ATTR_SPECIFIED
))
694 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
697 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, NULL
, sizeof(temppsfi
), flags
);
699 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
703 if(flags
& SHGFI_ICON
)
704 psfi
->hIcon
=temppsfi
.hIcon
;
705 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
706 psfi
->iIcon
=temppsfi
.iIcon
;
707 if(flags
& SHGFI_ATTRIBUTES
)
708 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
709 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
711 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szDisplayName
, -1,
712 psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
), NULL
, NULL
);
714 if(flags
& SHGFI_TYPENAME
)
716 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szTypeName
, -1,
717 psfi
->szTypeName
, sizeof(psfi
->szTypeName
), NULL
, NULL
);
721 HeapFree(GetProcessHeap(), 0, temppath
);
726 /*************************************************************************
727 * DuplicateIcon [SHELL32.@]
729 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
734 TRACE("%p %p\n", hInstance
, hIcon
);
736 if (GetIconInfo(hIcon
, &IconInfo
))
738 hDupIcon
= CreateIconIndirect(&IconInfo
);
740 /* clean up hbmMask and hbmColor */
741 DeleteObject(IconInfo
.hbmMask
);
742 DeleteObject(IconInfo
.hbmColor
);
748 /*************************************************************************
749 * ExtractIconA [SHELL32.@]
751 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
754 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
755 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
757 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
759 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
760 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
761 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
766 /*************************************************************************
767 * ExtractIconW [SHELL32.@]
769 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
773 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
775 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
777 if (nIconIndex
== (UINT
)-1)
779 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
780 if (ret
!= (UINT
)-1 && ret
)
781 return (HICON
)(UINT_PTR
)ret
;
785 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
789 else if (ret
> 0 && hIcon
)
795 HRESULT WINAPI
SHCreateFileExtractIconW(LPCWSTR file
, DWORD attribs
, REFIID riid
, void **ppv
)
797 FIXME("%s, %x, %s, %p\n", debugstr_w(file
), attribs
, debugstr_guid(riid
), ppv
);
802 /*************************************************************************
803 * Printer_LoadIconsW [SHELL32.205]
805 VOID WINAPI
Printer_LoadIconsW(LPCWSTR wsPrinterName
, HICON
* pLargeIcon
, HICON
* pSmallIcon
)
807 INT iconindex
=IDI_SHELL_PRINTER
;
809 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName
), pLargeIcon
, pSmallIcon
);
811 /* We should check if wsPrinterName is
812 1. the Default Printer or not
814 3. a Local Printer or a Network-Printer
815 and use different Icons
817 if((wsPrinterName
!= NULL
) && (wsPrinterName
[0] != 0))
819 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName
));
822 if(pLargeIcon
!= NULL
)
823 *pLargeIcon
= LoadImageW(shell32_hInstance
,
824 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
825 0, 0, LR_DEFAULTCOLOR
|LR_DEFAULTSIZE
);
827 if(pSmallIcon
!= NULL
)
828 *pSmallIcon
= LoadImageW(shell32_hInstance
,
829 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
830 16, 16, LR_DEFAULTCOLOR
);
833 /*************************************************************************
834 * Printers_RegisterWindowW [SHELL32.213]
835 * used by "printui.dll":
836 * find the Window of the given Type for the specific Printer and
837 * return the already existent hwnd or open a new window
839 BOOL WINAPI
Printers_RegisterWindowW(LPCWSTR wsPrinter
, DWORD dwType
,
840 HANDLE
* phClassPidl
, HWND
* phwnd
)
842 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter
), dwType
,
843 phClassPidl
, (phClassPidl
!= NULL
) ? *(phClassPidl
) : NULL
,
844 phwnd
, (phwnd
!= NULL
) ? *(phwnd
) : NULL
);
849 /*************************************************************************
850 * Printers_UnregisterWindow [SHELL32.214]
852 VOID WINAPI
Printers_UnregisterWindow(HANDLE hClassPidl
, HWND hwnd
)
854 FIXME("(%p, %p) stub!\n", hClassPidl
, hwnd
);
857 /*************************************************************************/
862 LPCWSTR szOtherStuff
;
867 #define DROP_FIELD_TOP (-12)
869 static void paint_dropline( HDC hdc
, HWND hWnd
)
871 HWND hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_WINE_TEXT
);
874 if (!hWndCtl
) return;
875 GetWindowRect( hWndCtl
, &rect
);
876 MapWindowPoints( 0, hWnd
, (LPPOINT
)&rect
, 2 );
877 rect
.top
+= DROP_FIELD_TOP
;
878 rect
.bottom
= rect
.top
+ 2;
879 DrawEdge( hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
882 /*************************************************************************
883 * SHHelpShortcuts_RunDLLA [SHELL32.@]
886 DWORD WINAPI
SHHelpShortcuts_RunDLLA(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
888 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
892 /*************************************************************************
893 * SHHelpShortcuts_RunDLLA [SHELL32.@]
896 DWORD WINAPI
SHHelpShortcuts_RunDLLW(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
898 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
902 /*************************************************************************
903 * SHLoadInProc [SHELL32.@]
904 * Create an instance of specified object class from within
905 * the shell process and release it immediately
907 HRESULT WINAPI
SHLoadInProc (REFCLSID rclsid
)
911 TRACE("%s\n", debugstr_guid(rclsid
));
913 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
916 IUnknown
* pUnk
= ptr
;
917 IUnknown_Release(pUnk
);
920 return DISP_E_MEMBERNOTFOUND
;
923 /*************************************************************************
924 * AboutDlgProc (internal)
926 static INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
937 ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
938 WCHAR
template[512], buffer
[512], version
[64];
939 extern const char *wine_get_build_id(void);
943 const char* const *pstr
= SHELL_Authors
;
944 SendDlgItemMessageW(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
945 GetWindowTextW( hWnd
, template, sizeof(template)/sizeof(WCHAR
) );
946 sprintfW( buffer
, template, info
->szApp
);
947 SetWindowTextW( hWnd
, buffer
);
948 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT1
), info
->szApp
);
949 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT2
), info
->szOtherStuff
);
950 GetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
),
951 template, sizeof(template)/sizeof(WCHAR
) );
952 MultiByteToWideChar( CP_UTF8
, 0, wine_get_build_id(), -1,
953 version
, sizeof(version
)/sizeof(WCHAR
) );
954 sprintfW( buffer
, template, version
);
955 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
), buffer
);
956 hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_LISTBOX
);
957 SendMessageW( hWndCtl
, WM_SETREDRAW
, 0, 0 );
958 SendMessageW( hWndCtl
, WM_SETFONT
, (WPARAM
)info
->hFont
, 0 );
961 /* authors list is in utf-8 format */
962 MultiByteToWideChar( CP_UTF8
, 0, *pstr
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) );
963 SendMessageW( hWndCtl
, LB_ADDSTRING
, -1, (LPARAM
)buffer
);
966 SendMessageW( hWndCtl
, WM_SETREDRAW
, 1, 0 );
974 HDC hDC
= BeginPaint( hWnd
, &ps
);
975 paint_dropline( hDC
, hWnd
);
976 EndPaint( hWnd
, &ps
);
981 if (wParam
== IDOK
|| wParam
== IDCANCEL
)
983 EndDialog(hWnd
, TRUE
);
986 if (wParam
== IDC_ABOUT_LICENSE
)
988 MSGBOXPARAMSW params
;
990 params
.cbSize
= sizeof(params
);
991 params
.hwndOwner
= hWnd
;
992 params
.hInstance
= shell32_hInstance
;
993 params
.lpszText
= MAKEINTRESOURCEW(IDS_LICENSE
);
994 params
.lpszCaption
= MAKEINTRESOURCEW(IDS_LICENSE_CAPTION
);
995 params
.dwStyle
= MB_ICONINFORMATION
| MB_OK
;
997 params
.dwContextHelpId
= 0;
998 params
.lpfnMsgBoxCallback
= NULL
;
999 params
.dwLanguageId
= LANG_NEUTRAL
;
1000 MessageBoxIndirectW( ¶ms
);
1004 EndDialog(hWnd
, TRUE
);
1012 /*************************************************************************
1013 * ShellAboutA [SHELL32.288]
1015 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
, HICON hIcon
)
1018 LPWSTR appW
= NULL
, otherW
= NULL
;
1023 len
= MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, NULL
, 0);
1024 appW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1025 MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, appW
, len
);
1029 len
= MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, NULL
, 0);
1030 otherW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1031 MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, otherW
, len
);
1034 ret
= ShellAboutW(hWnd
, appW
, otherW
, hIcon
);
1036 HeapFree(GetProcessHeap(), 0, otherW
);
1037 HeapFree(GetProcessHeap(), 0, appW
);
1042 /*************************************************************************
1043 * ShellAboutW [SHELL32.289]
1045 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
1051 static const WCHAR wszSHELL_ABOUT_MSGBOX
[] =
1052 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1056 if (!hIcon
) hIcon
= LoadImageW( 0, (LPWSTR
)IDI_WINLOGO
, IMAGE_ICON
, 48, 48, LR_SHARED
);
1058 info
.szOtherStuff
= szOtherStuff
;
1061 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
1062 info
.hFont
= CreateFontIndirectW( &logFont
);
1064 bRet
= DialogBoxParamW( shell32_hInstance
, wszSHELL_ABOUT_MSGBOX
, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
1065 DeleteObject(info
.hFont
);
1069 /*************************************************************************
1070 * FreeIconList (SHELL32.@)
1072 void WINAPI
FreeIconList( DWORD dw
)
1074 FIXME("%x: stub\n",dw
);
1077 /*************************************************************************
1078 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1080 HRESULT WINAPI
SHLoadNonloadedIconOverlayIdentifiers( VOID
)
1086 /***********************************************************************
1087 * DllGetVersion [SHELL32.@]
1089 * Retrieves version information of the 'SHELL32.DLL'
1092 * pdvi [O] pointer to version information structure.
1096 * Failure: E_INVALIDARG
1099 * Returns version of a shell32.dll from IE4.01 SP1.
1102 HRESULT WINAPI
DllGetVersion (DLLVERSIONINFO
*pdvi
)
1104 /* FIXME: shouldn't these values come from the version resource? */
1105 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
1106 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1108 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
1109 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
1110 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
1111 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
1112 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1114 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
1117 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
1118 WINE_FILEVERSION_MINOR
,
1119 WINE_FILEVERSION_BUILD
,
1120 WINE_FILEVERSION_PLATFORMID
);
1122 TRACE("%u.%u.%u.%u\n",
1123 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
1124 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
1129 WARN("wrong DLLVERSIONINFO size from app\n");
1130 return E_INVALIDARG
;
1134 /*************************************************************************
1135 * global variables of the shell32.dll
1136 * all are once per process
1139 HINSTANCE shell32_hInstance
= 0;
1140 HIMAGELIST ShellSmallIconList
= 0;
1141 HIMAGELIST ShellBigIconList
= 0;
1144 /*************************************************************************
1148 * calling oleinitialize here breaks sone apps.
1150 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
1152 TRACE("%p 0x%x %p\n", hinstDLL
, fdwReason
, fImpLoad
);
1156 case DLL_PROCESS_ATTACH
:
1157 shell32_hInstance
= hinstDLL
;
1158 DisableThreadLibraryCalls(shell32_hInstance
);
1160 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1161 GetModuleFileNameW(hinstDLL
, swShell32Name
, MAX_PATH
);
1162 swShell32Name
[MAX_PATH
- 1] = '\0';
1164 InitCommonControlsEx(NULL
);
1167 InitChangeNotifications();
1170 case DLL_PROCESS_DETACH
:
1171 shell32_hInstance
= 0;
1173 FreeChangeNotifications();
1179 /*************************************************************************
1180 * DllInstall [SHELL32.@]
1184 * BOOL bInstall - TRUE for install, FALSE for uninstall
1185 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1188 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1190 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1191 return S_OK
; /* indicate success */
1194 /***********************************************************************
1195 * DllCanUnloadNow (SHELL32.@)
1197 HRESULT WINAPI
DllCanUnloadNow(void)
1202 /***********************************************************************
1203 * ExtractVersionResource16W (SHELL32.@)
1205 BOOL WINAPI
ExtractVersionResource16W(LPWSTR s
, DWORD d
)
1207 FIXME("(%s %x) stub!\n", debugstr_w(s
), d
);
1211 /***********************************************************************
1212 * InitNetworkAddressControl (SHELL32.@)
1214 BOOL WINAPI
InitNetworkAddressControl(void)
1220 /***********************************************************************
1221 * ShellHookProc (SHELL32.@)
1223 LRESULT CALLBACK
ShellHookProc(DWORD a
, DWORD b
, DWORD c
)
1229 HRESULT WINAPI
SHGetLocalizedName(LPCWSTR path
, LPWSTR module
, UINT size
, INT
*res
)
1231 FIXME("%s %p %u %p: stub\n", debugstr_w(path
), module
, size
, res
);