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 * - an odd number of '\'s followed by '"' correspond to half that number
68 * of '\' followed by a '"' (extension of the above)
71 * - an even number of '\'s followed by a '"' correspond to half that number
72 * of '\', plus a regular quote serving as an argument delimiter (which
73 * means it does not appear in the result)
74 * 'a\\"b c"' -> 'a\b c'
75 * 'a\\\\"b c"' -> 'a\\b c'
76 * - '\' that are not followed by a '"' are copied literally
86 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
97 /* Return the path to the executable */
98 DWORD len
, deslen
=MAX_PATH
, size
;
100 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
103 if (!(argv
= LocalAlloc(LMEM_FIXED
, size
))) return NULL
;
104 len
= GetModuleFileNameW(0, (LPWSTR
)(argv
+1), deslen
);
110 if (len
< deslen
) break;
112 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
115 argv
[0]=(LPWSTR
)(argv
+1);
122 /* to get a writable copy */
129 if (*cs
==0 || ((*cs
==0x0009 || *cs
==0x0020) && !in_quotes
))
133 /* skip the remaining spaces */
134 while (*cs
==0x0009 || *cs
==0x0020) {
142 else if (*cs
==0x005c)
144 /* '\', count them */
147 else if ((*cs
==0x0022) && ((bcount
& 1)==0))
150 in_quotes
=!in_quotes
;
155 /* a regular character */
160 /* Allocate in a single lump, the string array, and the strings that go with it.
161 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
163 argv
=LocalAlloc(LMEM_FIXED
, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
166 cmdline
=(LPWSTR
)(argv
+argc
);
167 strcpyW(cmdline
, lpCmdline
);
175 if ((*s
==0x0009 || *s
==0x0020) && !in_quotes
)
177 /* Close the argument and copy it */
181 /* skip the remaining spaces */
184 } while (*s
==0x0009 || *s
==0x0020);
186 /* Start with a new argument */
201 /* Preceded by an even number of '\', this is half that
202 * number of '\', plus a quote which we erase.
205 in_quotes
=!in_quotes
;
210 /* Preceded by an odd number of '\', this is half that
211 * number of '\' followed by a '"'
221 /* a regular character */
237 static DWORD
shgfi_get_exe_type(LPCWSTR szFullPath
)
242 IMAGE_DOS_HEADER mz_header
;
247 status
= GetBinaryTypeW (szFullPath
, &BinaryType
);
250 if (BinaryType
== SCS_DOS_BINARY
|| BinaryType
== SCS_PIF_BINARY
)
253 hfile
= CreateFileW( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
254 NULL
, OPEN_EXISTING
, 0, 0 );
255 if ( hfile
== INVALID_HANDLE_VALUE
)
259 * The next section is adapted from MODULE_GetBinaryType, as we need
260 * to examine the image header to get OS and version information. We
261 * know from calling GetBinaryTypeA that the image is valid and either
262 * an NE or PE, so much error handling can be omitted.
263 * Seek to the start of the file and read the header information.
266 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
267 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
269 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
270 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
271 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
273 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
274 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
275 CloseHandle( hfile
);
276 /* DLL files are not executable and should return 0 */
277 if (nt
.FileHeader
.Characteristics
& IMAGE_FILE_DLL
)
279 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
)
281 return IMAGE_NT_SIGNATURE
|
282 (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24) |
283 (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
285 return IMAGE_NT_SIGNATURE
;
287 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
290 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
291 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
292 CloseHandle( hfile
);
293 if (ne
.ne_exetyp
== 2)
294 return IMAGE_OS2_SIGNATURE
| (ne
.ne_expver
<< 16);
297 CloseHandle( hfile
);
301 /*************************************************************************
302 * SHELL_IsShortcut [internal]
304 * Decide if an item id list points to a shell shortcut
306 BOOL
SHELL_IsShortcut(LPCITEMIDLIST pidlLast
)
308 char szTemp
[MAX_PATH
];
312 if (_ILGetExtension(pidlLast
, szTemp
, MAX_PATH
) &&
313 HCR_MapTypeToValueA(szTemp
, szTemp
, MAX_PATH
, TRUE
))
315 if (ERROR_SUCCESS
== RegOpenKeyExA(HKEY_CLASSES_ROOT
, szTemp
, 0, KEY_QUERY_VALUE
, &keyCls
))
317 if (ERROR_SUCCESS
== RegQueryValueExA(keyCls
, "IsShortcut", NULL
, NULL
, NULL
, NULL
))
327 #define SHGFI_KNOWN_FLAGS \
328 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
329 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
330 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
331 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
332 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
334 /*************************************************************************
335 * SHGetFileInfoW [SHELL32.@]
338 DWORD_PTR WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
339 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
341 WCHAR szLocation
[MAX_PATH
], szFullPath
[MAX_PATH
];
343 DWORD_PTR ret
= TRUE
;
344 DWORD dwAttributes
= 0;
345 IShellFolder
* psfParent
= NULL
;
346 IExtractIconW
* pei
= NULL
;
347 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
349 BOOL IconNotYetLoaded
=TRUE
;
352 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
353 (flags
& SHGFI_PIDL
)? "pidl" : debugstr_w(path
), dwFileAttributes
,
354 psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
359 /* windows initializes these values regardless of the flags */
362 psfi
->szDisplayName
[0] = '\0';
363 psfi
->szTypeName
[0] = '\0';
367 if (!(flags
& SHGFI_PIDL
))
369 /* SHGetFileInfo should work with absolute and relative paths */
370 if (PathIsRelativeW(path
))
372 GetCurrentDirectoryW(MAX_PATH
, szLocation
);
373 PathCombineW(szFullPath
, szLocation
, path
);
377 lstrcpynW(szFullPath
, path
, MAX_PATH
);
381 if (flags
& SHGFI_EXETYPE
)
383 if (flags
!= SHGFI_EXETYPE
)
385 return shgfi_get_exe_type(szFullPath
);
389 * psfi is NULL normally to query EXE type. If it is NULL, none of the
390 * below makes sense anyway. Windows allows this and just returns FALSE
396 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
398 * The pidl functions fail on not existing file names
401 if (flags
& SHGFI_PIDL
)
403 pidl
= ILClone((LPCITEMIDLIST
)path
);
405 else if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
407 hr
= SHILCreateFromPathW(szFullPath
, &pidl
, &dwAttributes
);
410 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
412 /* get the parent shellfolder */
415 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
,
416 (LPCITEMIDLIST
*)&pidlLast
);
418 pidlLast
= ILClone(pidlLast
);
423 ERR("pidl is null!\n");
428 /* get the attributes of the child */
429 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
431 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
433 psfi
->dwAttributes
= 0xffffffff;
436 IShellFolder_GetAttributesOf( psfParent
, 1, (LPCITEMIDLIST
*)&pidlLast
,
437 &(psfi
->dwAttributes
) );
440 /* get the displayname */
441 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
443 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
445 lstrcpyW (psfi
->szDisplayName
, PathFindFileNameW(szFullPath
));
450 hr
= IShellFolder_GetDisplayNameOf( psfParent
, pidlLast
,
451 SHGDN_INFOLDER
, &str
);
452 StrRetToStrNW (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
456 /* get the type name */
457 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
459 static const WCHAR szFile
[] = { 'F','i','l','e',0 };
460 static const WCHAR szDashFile
[] = { '-','f','i','l','e',0 };
462 if (!(flags
& SHGFI_USEFILEATTRIBUTES
) || (flags
& SHGFI_PIDL
))
466 _ILGetFileType(pidlLast
, ftype
, 80);
467 MultiByteToWideChar(CP_ACP
, 0, ftype
, -1, psfi
->szTypeName
, 80 );
471 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
472 strcatW (psfi
->szTypeName
, szFile
);
477 lstrcpyW(sTemp
,PathFindExtensionW(szFullPath
));
478 if (!( HCR_MapTypeToValueW(sTemp
, sTemp
, 64, TRUE
) &&
479 HCR_MapTypeToValueW(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
481 lstrcpynW (psfi
->szTypeName
, sTemp
, 64);
482 strcatW (psfi
->szTypeName
, szDashFile
);
489 if (flags
& SHGFI_OPENICON
)
490 uGilFlags
|= GIL_OPENICON
;
492 if (flags
& SHGFI_LINKOVERLAY
)
493 uGilFlags
|= GIL_FORSHORTCUT
;
494 else if ((flags
&SHGFI_ADDOVERLAYS
) ||
495 (flags
&(SHGFI_ICON
|SHGFI_SMALLICON
))==SHGFI_ICON
)
497 if (SHELL_IsShortcut(pidlLast
))
498 uGilFlags
|= GIL_FORSHORTCUT
;
501 if (flags
& SHGFI_OVERLAYINDEX
)
502 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
504 if (flags
& SHGFI_SELECTED
)
505 FIXME("set icon to selected, stub\n");
507 if (flags
& SHGFI_SHELLICONSIZE
)
508 FIXME("set icon to shell size, stub\n");
510 /* get the iconlocation */
511 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
515 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
517 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
519 lstrcpyW(psfi
->szDisplayName
, swShell32Name
);
520 psfi
->iIcon
= -IDI_SHELL_FOLDER
;
525 static const WCHAR p1W
[] = {'%','1',0};
526 WCHAR sTemp
[MAX_PATH
];
528 szExt
= PathFindExtensionW(szFullPath
);
529 TRACE("szExt=%s\n", debugstr_w(szExt
));
531 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
532 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &psfi
->iIcon
))
534 if (lstrcmpW(p1W
, sTemp
))
535 strcpyW(psfi
->szDisplayName
, sTemp
);
538 /* the icon is in the file */
539 strcpyW(psfi
->szDisplayName
, szFullPath
);
548 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1,
549 (LPCITEMIDLIST
*)&pidlLast
, &IID_IExtractIconW
,
550 &uDummy
, (LPVOID
*)&pei
);
553 hr
= IExtractIconW_GetIconLocation(pei
, uGilFlags
,
554 szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
556 if (uFlags
& GIL_NOTFILENAME
)
560 lstrcpyW (psfi
->szDisplayName
, szLocation
);
561 psfi
->iIcon
= iIndex
;
563 IExtractIconW_Release(pei
);
568 /* get icon index (or load icon)*/
569 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
571 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
573 WCHAR sTemp
[MAX_PATH
];
577 lstrcpynW(sTemp
, szFullPath
, MAX_PATH
);
579 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
580 psfi
->iIcon
= SIC_GetIconIndex(swShell32Name
, -IDI_SHELL_FOLDER
, 0);
583 static const WCHAR p1W
[] = {'%','1',0};
586 szExt
= PathFindExtensionW(sTemp
);
588 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
589 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &icon_idx
))
591 if (!lstrcmpW(p1W
,sTemp
)) /* icon is in the file */
592 strcpyW(sTemp
, szFullPath
);
594 if (flags
& SHGFI_SYSICONINDEX
)
596 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,icon_idx
,0);
597 if (psfi
->iIcon
== -1)
603 if (flags
& SHGFI_SMALLICON
)
604 ret
= PrivateExtractIconsW( sTemp
,icon_idx
,
605 GetSystemMetrics( SM_CXSMICON
),
606 GetSystemMetrics( SM_CYSMICON
),
607 &psfi
->hIcon
, 0, 1, 0);
609 ret
= PrivateExtractIconsW( sTemp
, icon_idx
,
610 GetSystemMetrics( SM_CXICON
),
611 GetSystemMetrics( SM_CYICON
),
612 &psfi
->hIcon
, 0, 1, 0);
613 if (ret
!= 0 && ret
!= (UINT
)-1)
615 IconNotYetLoaded
=FALSE
;
616 psfi
->iIcon
= icon_idx
;
624 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
625 uGilFlags
, &(psfi
->iIcon
))))
630 if (ret
&& (flags
& SHGFI_SYSICONINDEX
))
632 if (flags
& SHGFI_SMALLICON
)
633 ret
= (DWORD_PTR
) ShellSmallIconList
;
635 ret
= (DWORD_PTR
) ShellBigIconList
;
640 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
642 if (flags
& SHGFI_SMALLICON
)
643 psfi
->hIcon
= ImageList_GetIcon( ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
645 psfi
->hIcon
= ImageList_GetIcon( ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
648 if (flags
& ~SHGFI_KNOWN_FLAGS
)
649 FIXME("unknown flags %08x\n", flags
& ~SHGFI_KNOWN_FLAGS
);
652 IShellFolder_Release(psfParent
);
659 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
660 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
,
661 debugstr_w(psfi
->szDisplayName
), debugstr_w(psfi
->szTypeName
), ret
);
666 /*************************************************************************
667 * SHGetFileInfoA [SHELL32.@]
670 * MSVBVM60.__vbaNew2 expects this function to return a value in range
671 * 1 .. 0x7fff when the function succeeds and flags does not contain
672 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
674 DWORD_PTR WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
675 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
679 LPWSTR temppath
= NULL
;
682 SHFILEINFOW temppsfi
;
684 if (flags
& SHGFI_PIDL
)
686 /* path contains a pidl */
687 pathW
= (LPCWSTR
)path
;
691 len
= MultiByteToWideChar(CP_ACP
, 0, path
, -1, NULL
, 0);
692 temppath
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
693 MultiByteToWideChar(CP_ACP
, 0, path
, -1, temppath
, len
);
697 if (psfi
&& (flags
& SHGFI_ATTR_SPECIFIED
))
698 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
701 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, NULL
, sizeof(temppsfi
), flags
);
703 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
707 if(flags
& SHGFI_ICON
)
708 psfi
->hIcon
=temppsfi
.hIcon
;
709 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
710 psfi
->iIcon
=temppsfi
.iIcon
;
711 if(flags
& SHGFI_ATTRIBUTES
)
712 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
713 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
715 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szDisplayName
, -1,
716 psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
), NULL
, NULL
);
718 if(flags
& SHGFI_TYPENAME
)
720 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szTypeName
, -1,
721 psfi
->szTypeName
, sizeof(psfi
->szTypeName
), NULL
, NULL
);
725 HeapFree(GetProcessHeap(), 0, temppath
);
730 /*************************************************************************
731 * DuplicateIcon [SHELL32.@]
733 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
738 TRACE("%p %p\n", hInstance
, hIcon
);
740 if (GetIconInfo(hIcon
, &IconInfo
))
742 hDupIcon
= CreateIconIndirect(&IconInfo
);
744 /* clean up hbmMask and hbmColor */
745 DeleteObject(IconInfo
.hbmMask
);
746 DeleteObject(IconInfo
.hbmColor
);
752 /*************************************************************************
753 * ExtractIconA [SHELL32.@]
755 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
758 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
759 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
761 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
763 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
764 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
765 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
770 /*************************************************************************
771 * ExtractIconW [SHELL32.@]
773 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
777 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
779 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
781 if (nIconIndex
== (UINT
)-1)
783 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
784 if (ret
!= (UINT
)-1 && ret
)
785 return (HICON
)(UINT_PTR
)ret
;
789 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
793 else if (ret
> 0 && hIcon
)
799 HRESULT WINAPI
SHCreateFileExtractIconW(LPCWSTR file
, DWORD attribs
, REFIID riid
, void **ppv
)
801 FIXME("%s, %x, %s, %p\n", debugstr_w(file
), attribs
, debugstr_guid(riid
), ppv
);
806 /*************************************************************************
807 * Printer_LoadIconsW [SHELL32.205]
809 VOID WINAPI
Printer_LoadIconsW(LPCWSTR wsPrinterName
, HICON
* pLargeIcon
, HICON
* pSmallIcon
)
811 INT iconindex
=IDI_SHELL_PRINTER
;
813 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName
), pLargeIcon
, pSmallIcon
);
815 /* We should check if wsPrinterName is
816 1. the Default Printer or not
818 3. a Local Printer or a Network-Printer
819 and use different Icons
821 if((wsPrinterName
!= NULL
) && (wsPrinterName
[0] != 0))
823 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName
));
826 if(pLargeIcon
!= NULL
)
827 *pLargeIcon
= LoadImageW(shell32_hInstance
,
828 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
829 0, 0, LR_DEFAULTCOLOR
|LR_DEFAULTSIZE
);
831 if(pSmallIcon
!= NULL
)
832 *pSmallIcon
= LoadImageW(shell32_hInstance
,
833 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
834 16, 16, LR_DEFAULTCOLOR
);
837 /*************************************************************************
838 * Printers_RegisterWindowW [SHELL32.213]
839 * used by "printui.dll":
840 * find the Window of the given Type for the specific Printer and
841 * return the already existent hwnd or open a new window
843 BOOL WINAPI
Printers_RegisterWindowW(LPCWSTR wsPrinter
, DWORD dwType
,
844 HANDLE
* phClassPidl
, HWND
* phwnd
)
846 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter
), dwType
,
847 phClassPidl
, (phClassPidl
!= NULL
) ? *(phClassPidl
) : NULL
,
848 phwnd
, (phwnd
!= NULL
) ? *(phwnd
) : NULL
);
853 /*************************************************************************
854 * Printers_UnregisterWindow [SHELL32.214]
856 VOID WINAPI
Printers_UnregisterWindow(HANDLE hClassPidl
, HWND hwnd
)
858 FIXME("(%p, %p) stub!\n", hClassPidl
, hwnd
);
861 /*************************************************************************
862 * SHGetPropertyStoreFromParsingName [SHELL32.@]
864 HRESULT WINAPI
SHGetPropertyStoreFromParsingName(PCWSTR pszPath
, IBindCtx
*pbc
, GETPROPERTYSTOREFLAGS flags
, REFIID riid
, void **ppv
)
866 FIXME("(%s %p %u %p %p) stub!\n", debugstr_w(pszPath
), pbc
, flags
, riid
, ppv
);
870 /*************************************************************************/
875 LPCWSTR szOtherStuff
;
880 #define DROP_FIELD_TOP (-12)
882 static void paint_dropline( HDC hdc
, HWND hWnd
)
884 HWND hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_WINE_TEXT
);
887 if (!hWndCtl
) return;
888 GetWindowRect( hWndCtl
, &rect
);
889 MapWindowPoints( 0, hWnd
, (LPPOINT
)&rect
, 2 );
890 rect
.top
+= DROP_FIELD_TOP
;
891 rect
.bottom
= rect
.top
+ 2;
892 DrawEdge( hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
895 /*************************************************************************
896 * SHHelpShortcuts_RunDLLA [SHELL32.@]
899 DWORD WINAPI
SHHelpShortcuts_RunDLLA(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
901 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
905 /*************************************************************************
906 * SHHelpShortcuts_RunDLLA [SHELL32.@]
909 DWORD WINAPI
SHHelpShortcuts_RunDLLW(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
911 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
915 /*************************************************************************
916 * SHLoadInProc [SHELL32.@]
917 * Create an instance of specified object class from within
918 * the shell process and release it immediately
920 HRESULT WINAPI
SHLoadInProc (REFCLSID rclsid
)
924 TRACE("%s\n", debugstr_guid(rclsid
));
926 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
929 IUnknown
* pUnk
= ptr
;
930 IUnknown_Release(pUnk
);
933 return DISP_E_MEMBERNOTFOUND
;
936 static void add_authors( HWND list
)
938 static const WCHAR eol
[] = {'\r','\n',0};
939 static const WCHAR authors
[] = {'A','U','T','H','O','R','S',0};
940 WCHAR
*strW
, *start
, *end
;
941 HRSRC rsrc
= FindResourceW( shell32_hInstance
, authors
, (LPCWSTR
)RT_RCDATA
);
942 char *strA
= LockResource( LoadResource( shell32_hInstance
, rsrc
));
943 DWORD sizeW
, sizeA
= SizeofResource( shell32_hInstance
, rsrc
);
946 sizeW
= MultiByteToWideChar( CP_UTF8
, 0, strA
, sizeA
, NULL
, 0 ) + 1;
947 if (!(strW
= HeapAlloc( GetProcessHeap(), 0, sizeW
* sizeof(WCHAR
) ))) return;
948 MultiByteToWideChar( CP_UTF8
, 0, strA
, sizeA
, strW
, sizeW
);
951 start
= strpbrkW( strW
, eol
); /* skip the header line */
954 while (*start
&& strchrW( eol
, *start
)) start
++;
956 end
= strpbrkW( start
, eol
);
958 SendMessageW( list
, LB_ADDSTRING
, -1, (LPARAM
)start
);
961 HeapFree( GetProcessHeap(), 0, strW
);
964 /*************************************************************************
965 * AboutDlgProc (internal)
967 static INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
978 ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
979 WCHAR
template[512], buffer
[512], version
[64];
980 extern const char *wine_get_build_id(void);
984 SendDlgItemMessageW(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
985 GetWindowTextW( hWnd
, template, sizeof(template)/sizeof(WCHAR
) );
986 sprintfW( buffer
, template, info
->szApp
);
987 SetWindowTextW( hWnd
, buffer
);
988 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT1
), info
->szApp
);
989 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT2
), info
->szOtherStuff
);
990 GetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
),
991 template, sizeof(template)/sizeof(WCHAR
) );
992 MultiByteToWideChar( CP_UTF8
, 0, wine_get_build_id(), -1,
993 version
, sizeof(version
)/sizeof(WCHAR
) );
994 sprintfW( buffer
, template, version
);
995 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
), buffer
);
996 hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_LISTBOX
);
997 SendMessageW( hWndCtl
, WM_SETREDRAW
, 0, 0 );
998 SendMessageW( hWndCtl
, WM_SETFONT
, (WPARAM
)info
->hFont
, 0 );
999 add_authors( hWndCtl
);
1000 SendMessageW( hWndCtl
, WM_SETREDRAW
, 1, 0 );
1008 HDC hDC
= BeginPaint( hWnd
, &ps
);
1009 paint_dropline( hDC
, hWnd
);
1010 EndPaint( hWnd
, &ps
);
1015 if (wParam
== IDOK
|| wParam
== IDCANCEL
)
1017 EndDialog(hWnd
, TRUE
);
1020 if (wParam
== IDC_ABOUT_LICENSE
)
1022 MSGBOXPARAMSW params
;
1024 params
.cbSize
= sizeof(params
);
1025 params
.hwndOwner
= hWnd
;
1026 params
.hInstance
= shell32_hInstance
;
1027 params
.lpszText
= MAKEINTRESOURCEW(IDS_LICENSE
);
1028 params
.lpszCaption
= MAKEINTRESOURCEW(IDS_LICENSE_CAPTION
);
1029 params
.dwStyle
= MB_ICONINFORMATION
| MB_OK
;
1030 params
.lpszIcon
= 0;
1031 params
.dwContextHelpId
= 0;
1032 params
.lpfnMsgBoxCallback
= NULL
;
1033 params
.dwLanguageId
= LANG_NEUTRAL
;
1034 MessageBoxIndirectW( ¶ms
);
1038 EndDialog(hWnd
, TRUE
);
1046 /*************************************************************************
1047 * ShellAboutA [SHELL32.288]
1049 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
, HICON hIcon
)
1052 LPWSTR appW
= NULL
, otherW
= NULL
;
1057 len
= MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, NULL
, 0);
1058 appW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1059 MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, appW
, len
);
1063 len
= MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, NULL
, 0);
1064 otherW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1065 MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, otherW
, len
);
1068 ret
= ShellAboutW(hWnd
, appW
, otherW
, hIcon
);
1070 HeapFree(GetProcessHeap(), 0, otherW
);
1071 HeapFree(GetProcessHeap(), 0, appW
);
1076 /*************************************************************************
1077 * ShellAboutW [SHELL32.289]
1079 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
1085 static const WCHAR wszSHELL_ABOUT_MSGBOX
[] =
1086 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1090 if (!hIcon
) hIcon
= LoadImageW( 0, (LPWSTR
)IDI_WINLOGO
, IMAGE_ICON
, 48, 48, LR_SHARED
);
1092 info
.szOtherStuff
= szOtherStuff
;
1095 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
1096 info
.hFont
= CreateFontIndirectW( &logFont
);
1098 bRet
= DialogBoxParamW( shell32_hInstance
, wszSHELL_ABOUT_MSGBOX
, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
1099 DeleteObject(info
.hFont
);
1103 /*************************************************************************
1104 * FreeIconList (SHELL32.@)
1106 void WINAPI
FreeIconList( DWORD dw
)
1108 FIXME("%x: stub\n",dw
);
1111 /*************************************************************************
1112 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1114 HRESULT WINAPI
SHLoadNonloadedIconOverlayIdentifiers( VOID
)
1120 /***********************************************************************
1121 * DllGetVersion [SHELL32.@]
1123 * Retrieves version information of the 'SHELL32.DLL'
1126 * pdvi [O] pointer to version information structure.
1130 * Failure: E_INVALIDARG
1133 * Returns version of a shell32.dll from IE4.01 SP1.
1136 HRESULT WINAPI
DllGetVersion (DLLVERSIONINFO
*pdvi
)
1138 /* FIXME: shouldn't these values come from the version resource? */
1139 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
1140 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1142 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
1143 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
1144 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
1145 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
1146 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1148 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
1151 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
1152 WINE_FILEVERSION_MINOR
,
1153 WINE_FILEVERSION_BUILD
,
1154 WINE_FILEVERSION_PLATFORMID
);
1156 TRACE("%u.%u.%u.%u\n",
1157 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
1158 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
1163 WARN("wrong DLLVERSIONINFO size from app\n");
1164 return E_INVALIDARG
;
1168 /*************************************************************************
1169 * global variables of the shell32.dll
1170 * all are once per process
1173 HINSTANCE shell32_hInstance
= 0;
1174 HIMAGELIST ShellSmallIconList
= 0;
1175 HIMAGELIST ShellBigIconList
= 0;
1178 /*************************************************************************
1182 * calling oleinitialize here breaks sone apps.
1184 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
1186 TRACE("%p 0x%x %p\n", hinstDLL
, fdwReason
, fImpLoad
);
1190 case DLL_PROCESS_ATTACH
:
1191 shell32_hInstance
= hinstDLL
;
1192 DisableThreadLibraryCalls(shell32_hInstance
);
1194 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1195 GetModuleFileNameW(hinstDLL
, swShell32Name
, MAX_PATH
);
1196 swShell32Name
[MAX_PATH
- 1] = '\0';
1198 InitCommonControlsEx(NULL
);
1201 InitChangeNotifications();
1204 case DLL_PROCESS_DETACH
:
1205 shell32_hInstance
= 0;
1207 FreeChangeNotifications();
1213 /*************************************************************************
1214 * DllInstall [SHELL32.@]
1218 * BOOL bInstall - TRUE for install, FALSE for uninstall
1219 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1222 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1224 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1225 return S_OK
; /* indicate success */
1228 /***********************************************************************
1229 * DllCanUnloadNow (SHELL32.@)
1231 HRESULT WINAPI
DllCanUnloadNow(void)
1236 /***********************************************************************
1237 * DllRegisterServer (SHELL32.@)
1239 HRESULT WINAPI
DllRegisterServer(void)
1241 HRESULT hr
= __wine_register_resources( shell32_hInstance
, NULL
);
1242 if (SUCCEEDED(hr
)) hr
= SHELL_RegisterShellFolders();
1246 /***********************************************************************
1247 * DllUnregisterServer (SHELL32.@)
1249 HRESULT WINAPI
DllUnregisterServer(void)
1251 return __wine_unregister_resources( shell32_hInstance
, NULL
);
1254 /***********************************************************************
1255 * ExtractVersionResource16W (SHELL32.@)
1257 BOOL WINAPI
ExtractVersionResource16W(LPWSTR s
, DWORD d
)
1259 FIXME("(%s %x) stub!\n", debugstr_w(s
), d
);
1263 /***********************************************************************
1264 * InitNetworkAddressControl (SHELL32.@)
1266 BOOL WINAPI
InitNetworkAddressControl(void)
1272 /***********************************************************************
1273 * ShellHookProc (SHELL32.@)
1275 LRESULT CALLBACK
ShellHookProc(DWORD a
, DWORD b
, DWORD c
)
1281 HRESULT WINAPI
SHGetLocalizedName(LPCWSTR path
, LPWSTR module
, UINT size
, INT
*res
)
1283 FIXME("%s %p %u %p: stub\n", debugstr_w(path
), module
, size
, res
);
1287 HRESULT WINAPI
SetCurrentProcessExplicitAppUserModelID(PCWSTR appid
)
1289 FIXME("%s: stub\n", debugstr_w(appid
));