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 /*************************************************************************
55 * CommandLineToArgvW [SHELL32.@]
57 * We must interpret the quotes in the command line to rebuild the argv
59 * - arguments are separated by spaces or tabs
60 * - quotes serve as optional argument delimiters
62 * - escaped quotes must be converted back to '"'
64 * - an odd number of '\'s followed by '"' correspond to half that number
65 * of '\' followed by a '"' (extension of the above)
68 * - an even number of '\'s followed by a '"' correspond to half that number
69 * of '\', plus a regular quote serving as an argument delimiter (which
70 * means it does not appear in the result)
71 * 'a\\"b c"' -> 'a\b c'
72 * 'a\\\\"b c"' -> 'a\\b c'
73 * - '\' that are not followed by a '"' are copied literally
83 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
94 /* Return the path to the executable */
95 DWORD len
, deslen
=MAX_PATH
, size
;
97 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
100 if (!(argv
= LocalAlloc(LMEM_FIXED
, size
))) return NULL
;
101 len
= GetModuleFileNameW(0, (LPWSTR
)(argv
+1), deslen
);
107 if (len
< deslen
) break;
109 size
= sizeof(LPWSTR
) + deslen
*sizeof(WCHAR
) + sizeof(LPWSTR
);
112 argv
[0]=(LPWSTR
)(argv
+1);
119 /* to get a writable copy */
126 if (*cs
==0 || ((*cs
==0x0009 || *cs
==0x0020) && !in_quotes
))
130 /* skip the remaining spaces */
131 while (*cs
==0x0009 || *cs
==0x0020) {
139 else if (*cs
==0x005c)
141 /* '\', count them */
144 else if ((*cs
==0x0022) && ((bcount
& 1)==0))
147 in_quotes
=!in_quotes
;
152 /* a regular character */
157 /* Allocate in a single lump, the string array, and the strings that go with it.
158 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
160 argv
=LocalAlloc(LMEM_FIXED
, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
163 cmdline
=(LPWSTR
)(argv
+argc
);
164 strcpyW(cmdline
, lpCmdline
);
172 if ((*s
==0x0009 || *s
==0x0020) && !in_quotes
)
174 /* Close the argument and copy it */
178 /* skip the remaining spaces */
181 } while (*s
==0x0009 || *s
==0x0020);
183 /* Start with a new argument */
198 /* Preceded by an even number of '\', this is half that
199 * number of '\', plus a quote which we erase.
202 in_quotes
=!in_quotes
;
207 /* Preceded by an odd number of '\', this is half that
208 * number of '\' followed by a '"'
218 /* a regular character */
234 static DWORD
shgfi_get_exe_type(LPCWSTR szFullPath
)
239 IMAGE_DOS_HEADER mz_header
;
244 status
= GetBinaryTypeW (szFullPath
, &BinaryType
);
247 if (BinaryType
== SCS_DOS_BINARY
|| BinaryType
== SCS_PIF_BINARY
)
250 hfile
= CreateFileW( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
251 NULL
, OPEN_EXISTING
, 0, 0 );
252 if ( hfile
== INVALID_HANDLE_VALUE
)
256 * The next section is adapted from MODULE_GetBinaryType, as we need
257 * to examine the image header to get OS and version information. We
258 * know from calling GetBinaryTypeA that the image is valid and either
259 * an NE or PE, so much error handling can be omitted.
260 * Seek to the start of the file and read the header information.
263 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
264 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
266 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
267 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
268 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
270 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
271 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
272 CloseHandle( hfile
);
273 /* DLL files are not executable and should return 0 */
274 if (nt
.FileHeader
.Characteristics
& IMAGE_FILE_DLL
)
276 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
)
278 return IMAGE_NT_SIGNATURE
|
279 (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24) |
280 (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
282 return IMAGE_NT_SIGNATURE
;
284 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
287 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
288 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
289 CloseHandle( hfile
);
290 if (ne
.ne_exetyp
== 2)
291 return IMAGE_OS2_SIGNATURE
| (ne
.ne_expver
<< 16);
294 CloseHandle( hfile
);
298 /*************************************************************************
299 * SHELL_IsShortcut [internal]
301 * Decide if an item id list points to a shell shortcut
303 BOOL
SHELL_IsShortcut(LPCITEMIDLIST pidlLast
)
305 char szTemp
[MAX_PATH
];
309 if (_ILGetExtension(pidlLast
, szTemp
, MAX_PATH
) &&
310 HCR_MapTypeToValueA(szTemp
, szTemp
, MAX_PATH
, TRUE
))
312 if (ERROR_SUCCESS
== RegOpenKeyExA(HKEY_CLASSES_ROOT
, szTemp
, 0, KEY_QUERY_VALUE
, &keyCls
))
314 if (ERROR_SUCCESS
== RegQueryValueExA(keyCls
, "IsShortcut", NULL
, NULL
, NULL
, NULL
))
324 #define SHGFI_KNOWN_FLAGS \
325 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
326 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
327 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
328 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
329 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
331 /*************************************************************************
332 * SHGetFileInfoW [SHELL32.@]
335 DWORD_PTR WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
336 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
338 WCHAR szLocation
[MAX_PATH
], szFullPath
[MAX_PATH
];
340 DWORD_PTR ret
= TRUE
;
341 DWORD dwAttributes
= 0;
342 IShellFolder
* psfParent
= NULL
;
343 IExtractIconW
* pei
= NULL
;
344 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
346 BOOL IconNotYetLoaded
=TRUE
;
349 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
350 (flags
& SHGFI_PIDL
)? "pidl" : debugstr_w(path
), dwFileAttributes
,
351 psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
356 /* windows initializes these values regardless of the flags */
359 psfi
->szDisplayName
[0] = '\0';
360 psfi
->szTypeName
[0] = '\0';
364 if (!(flags
& SHGFI_PIDL
))
366 /* SHGetFileInfo should work with absolute and relative paths */
367 if (PathIsRelativeW(path
))
369 GetCurrentDirectoryW(MAX_PATH
, szLocation
);
370 PathCombineW(szFullPath
, szLocation
, path
);
374 lstrcpynW(szFullPath
, path
, MAX_PATH
);
378 if (flags
& SHGFI_EXETYPE
)
380 if (flags
!= SHGFI_EXETYPE
)
382 return shgfi_get_exe_type(szFullPath
);
386 * psfi is NULL normally to query EXE type. If it is NULL, none of the
387 * below makes sense anyway. Windows allows this and just returns FALSE
393 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
395 * The pidl functions fail on not existing file names
398 if (flags
& SHGFI_PIDL
)
400 pidl
= ILClone((LPCITEMIDLIST
)path
);
402 else if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
404 hr
= SHILCreateFromPathW(szFullPath
, &pidl
, &dwAttributes
);
407 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
409 /* get the parent shellfolder */
412 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
,
413 (LPCITEMIDLIST
*)&pidlLast
);
415 pidlLast
= ILClone(pidlLast
);
420 ERR("pidl is null!\n");
425 /* get the attributes of the child */
426 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
428 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
430 psfi
->dwAttributes
= 0xffffffff;
433 IShellFolder_GetAttributesOf( psfParent
, 1, (LPCITEMIDLIST
*)&pidlLast
,
434 &(psfi
->dwAttributes
) );
437 /* get the displayname */
438 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
440 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
442 lstrcpyW (psfi
->szDisplayName
, PathFindFileNameW(szFullPath
));
447 hr
= IShellFolder_GetDisplayNameOf( psfParent
, pidlLast
,
448 SHGDN_INFOLDER
, &str
);
449 StrRetToStrNW (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
453 /* get the type name */
454 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
456 static const WCHAR szFile
[] = { 'F','i','l','e',0 };
457 static const WCHAR szDashFile
[] = { '-','f','i','l','e',0 };
459 if (!(flags
& SHGFI_USEFILEATTRIBUTES
) || (flags
& SHGFI_PIDL
))
463 _ILGetFileType(pidlLast
, ftype
, 80);
464 MultiByteToWideChar(CP_ACP
, 0, ftype
, -1, psfi
->szTypeName
, 80 );
468 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
469 strcatW (psfi
->szTypeName
, szFile
);
474 lstrcpyW(sTemp
,PathFindExtensionW(szFullPath
));
475 if (!( HCR_MapTypeToValueW(sTemp
, sTemp
, 64, TRUE
) &&
476 HCR_MapTypeToValueW(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
478 lstrcpynW (psfi
->szTypeName
, sTemp
, 64);
479 strcatW (psfi
->szTypeName
, szDashFile
);
486 if (flags
& SHGFI_OPENICON
)
487 uGilFlags
|= GIL_OPENICON
;
489 if (flags
& SHGFI_LINKOVERLAY
)
490 uGilFlags
|= GIL_FORSHORTCUT
;
491 else if ((flags
&SHGFI_ADDOVERLAYS
) ||
492 (flags
&(SHGFI_ICON
|SHGFI_SMALLICON
))==SHGFI_ICON
)
494 if (SHELL_IsShortcut(pidlLast
))
495 uGilFlags
|= GIL_FORSHORTCUT
;
498 if (flags
& SHGFI_OVERLAYINDEX
)
499 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
501 if (flags
& SHGFI_SELECTED
)
502 FIXME("set icon to selected, stub\n");
504 if (flags
& SHGFI_SHELLICONSIZE
)
505 FIXME("set icon to shell size, stub\n");
507 /* get the iconlocation */
508 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
512 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
514 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
516 lstrcpyW(psfi
->szDisplayName
, swShell32Name
);
517 psfi
->iIcon
= -IDI_SHELL_FOLDER
;
522 static const WCHAR p1W
[] = {'%','1',0};
523 WCHAR sTemp
[MAX_PATH
];
525 szExt
= PathFindExtensionW(szFullPath
);
526 TRACE("szExt=%s\n", debugstr_w(szExt
));
528 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
529 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &psfi
->iIcon
))
531 if (lstrcmpW(p1W
, sTemp
))
532 strcpyW(psfi
->szDisplayName
, sTemp
);
535 /* the icon is in the file */
536 strcpyW(psfi
->szDisplayName
, szFullPath
);
545 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1,
546 (LPCITEMIDLIST
*)&pidlLast
, &IID_IExtractIconW
,
547 &uDummy
, (LPVOID
*)&pei
);
550 hr
= IExtractIconW_GetIconLocation(pei
, uGilFlags
,
551 szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
553 if (uFlags
& GIL_NOTFILENAME
)
557 lstrcpyW (psfi
->szDisplayName
, szLocation
);
558 psfi
->iIcon
= iIndex
;
560 IExtractIconW_Release(pei
);
565 /* get icon index (or load icon)*/
566 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
568 if (flags
& SHGFI_USEFILEATTRIBUTES
&& !(flags
& SHGFI_PIDL
))
570 WCHAR sTemp
[MAX_PATH
];
574 lstrcpynW(sTemp
, szFullPath
, MAX_PATH
);
576 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
577 psfi
->iIcon
= SIC_GetIconIndex(swShell32Name
, -IDI_SHELL_FOLDER
, 0);
580 static const WCHAR p1W
[] = {'%','1',0};
583 szExt
= PathFindExtensionW(sTemp
);
585 HCR_MapTypeToValueW(szExt
, sTemp
, MAX_PATH
, TRUE
) &&
586 HCR_GetDefaultIconW(sTemp
, sTemp
, MAX_PATH
, &icon_idx
))
588 if (!lstrcmpW(p1W
,sTemp
)) /* icon is in the file */
589 strcpyW(sTemp
, szFullPath
);
591 if (flags
& SHGFI_SYSICONINDEX
)
593 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,icon_idx
,0);
594 if (psfi
->iIcon
== -1)
600 if (flags
& SHGFI_SMALLICON
)
601 ret
= PrivateExtractIconsW( sTemp
,icon_idx
,
602 GetSystemMetrics( SM_CXSMICON
),
603 GetSystemMetrics( SM_CYSMICON
),
604 &psfi
->hIcon
, 0, 1, 0);
606 ret
= PrivateExtractIconsW( sTemp
, icon_idx
,
607 GetSystemMetrics( SM_CXICON
),
608 GetSystemMetrics( SM_CYICON
),
609 &psfi
->hIcon
, 0, 1, 0);
610 if (ret
!= 0 && ret
!= (UINT
)-1)
612 IconNotYetLoaded
=FALSE
;
613 psfi
->iIcon
= icon_idx
;
621 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
622 uGilFlags
, &(psfi
->iIcon
))))
627 if (ret
&& (flags
& SHGFI_SYSICONINDEX
))
629 if (flags
& SHGFI_SMALLICON
)
630 ret
= (DWORD_PTR
) ShellSmallIconList
;
632 ret
= (DWORD_PTR
) ShellBigIconList
;
637 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
639 if (flags
& SHGFI_SMALLICON
)
640 psfi
->hIcon
= ImageList_GetIcon( ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
642 psfi
->hIcon
= ImageList_GetIcon( ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
645 if (flags
& ~SHGFI_KNOWN_FLAGS
)
646 FIXME("unknown flags %08x\n", flags
& ~SHGFI_KNOWN_FLAGS
);
649 IShellFolder_Release(psfParent
);
656 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
657 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
,
658 debugstr_w(psfi
->szDisplayName
), debugstr_w(psfi
->szTypeName
), ret
);
663 /*************************************************************************
664 * SHGetFileInfoA [SHELL32.@]
667 * MSVBVM60.__vbaNew2 expects this function to return a value in range
668 * 1 .. 0x7fff when the function succeeds and flags does not contain
669 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
671 DWORD_PTR WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
672 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
676 LPWSTR temppath
= NULL
;
679 SHFILEINFOW temppsfi
;
681 if (flags
& SHGFI_PIDL
)
683 /* path contains a pidl */
684 pathW
= (LPCWSTR
)path
;
688 len
= MultiByteToWideChar(CP_ACP
, 0, path
, -1, NULL
, 0);
689 temppath
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
690 MultiByteToWideChar(CP_ACP
, 0, path
, -1, temppath
, len
);
694 if (psfi
&& (flags
& SHGFI_ATTR_SPECIFIED
))
695 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
698 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, NULL
, sizeof(temppsfi
), flags
);
700 ret
= SHGetFileInfoW(pathW
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
704 if(flags
& SHGFI_ICON
)
705 psfi
->hIcon
=temppsfi
.hIcon
;
706 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
707 psfi
->iIcon
=temppsfi
.iIcon
;
708 if(flags
& SHGFI_ATTRIBUTES
)
709 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
710 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
712 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szDisplayName
, -1,
713 psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
), NULL
, NULL
);
715 if(flags
& SHGFI_TYPENAME
)
717 WideCharToMultiByte(CP_ACP
, 0, temppsfi
.szTypeName
, -1,
718 psfi
->szTypeName
, sizeof(psfi
->szTypeName
), NULL
, NULL
);
722 HeapFree(GetProcessHeap(), 0, temppath
);
727 /*************************************************************************
728 * DuplicateIcon [SHELL32.@]
730 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
735 TRACE("%p %p\n", hInstance
, hIcon
);
737 if (GetIconInfo(hIcon
, &IconInfo
))
739 hDupIcon
= CreateIconIndirect(&IconInfo
);
741 /* clean up hbmMask and hbmColor */
742 DeleteObject(IconInfo
.hbmMask
);
743 DeleteObject(IconInfo
.hbmColor
);
749 /*************************************************************************
750 * ExtractIconA [SHELL32.@]
752 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
755 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
756 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
758 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
760 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
761 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
762 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
767 /*************************************************************************
768 * ExtractIconW [SHELL32.@]
770 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
774 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
776 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
778 if (nIconIndex
== (UINT
)-1)
780 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
781 if (ret
!= (UINT
)-1 && ret
)
782 return (HICON
)(UINT_PTR
)ret
;
786 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
790 else if (ret
> 0 && hIcon
)
796 HRESULT WINAPI
SHCreateFileExtractIconW(LPCWSTR file
, DWORD attribs
, REFIID riid
, void **ppv
)
798 FIXME("%s, %x, %s, %p\n", debugstr_w(file
), attribs
, debugstr_guid(riid
), ppv
);
803 /*************************************************************************
804 * Printer_LoadIconsW [SHELL32.205]
806 VOID WINAPI
Printer_LoadIconsW(LPCWSTR wsPrinterName
, HICON
* pLargeIcon
, HICON
* pSmallIcon
)
808 INT iconindex
=IDI_SHELL_PRINTER
;
810 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName
), pLargeIcon
, pSmallIcon
);
812 /* We should check if wsPrinterName is
813 1. the Default Printer or not
815 3. a Local Printer or a Network-Printer
816 and use different Icons
818 if((wsPrinterName
!= NULL
) && (wsPrinterName
[0] != 0))
820 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName
));
823 if(pLargeIcon
!= NULL
)
824 *pLargeIcon
= LoadImageW(shell32_hInstance
,
825 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
826 0, 0, LR_DEFAULTCOLOR
|LR_DEFAULTSIZE
);
828 if(pSmallIcon
!= NULL
)
829 *pSmallIcon
= LoadImageW(shell32_hInstance
,
830 (LPCWSTR
) MAKEINTRESOURCE(iconindex
), IMAGE_ICON
,
831 16, 16, LR_DEFAULTCOLOR
);
834 /*************************************************************************
835 * Printers_RegisterWindowW [SHELL32.213]
836 * used by "printui.dll":
837 * find the Window of the given Type for the specific Printer and
838 * return the already existent hwnd or open a new window
840 BOOL WINAPI
Printers_RegisterWindowW(LPCWSTR wsPrinter
, DWORD dwType
,
841 HANDLE
* phClassPidl
, HWND
* phwnd
)
843 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter
), dwType
,
844 phClassPidl
, (phClassPidl
!= NULL
) ? *(phClassPidl
) : NULL
,
845 phwnd
, (phwnd
!= NULL
) ? *(phwnd
) : NULL
);
850 /*************************************************************************
851 * Printers_UnregisterWindow [SHELL32.214]
853 VOID WINAPI
Printers_UnregisterWindow(HANDLE hClassPidl
, HWND hwnd
)
855 FIXME("(%p, %p) stub!\n", hClassPidl
, hwnd
);
858 /*************************************************************************
859 * SHGetPropertyStoreFromParsingName [SHELL32.@]
861 HRESULT WINAPI
SHGetPropertyStoreFromParsingName(PCWSTR pszPath
, IBindCtx
*pbc
, GETPROPERTYSTOREFLAGS flags
, REFIID riid
, void **ppv
)
863 FIXME("(%s %p %u %p %p) stub!\n", debugstr_w(pszPath
), pbc
, flags
, riid
, ppv
);
867 /*************************************************************************/
872 LPCWSTR szOtherStuff
;
877 #define DROP_FIELD_TOP (-12)
879 static void paint_dropline( HDC hdc
, HWND hWnd
)
881 HWND hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_WINE_TEXT
);
884 if (!hWndCtl
) return;
885 GetWindowRect( hWndCtl
, &rect
);
886 MapWindowPoints( 0, hWnd
, (LPPOINT
)&rect
, 2 );
887 rect
.top
+= DROP_FIELD_TOP
;
888 rect
.bottom
= rect
.top
+ 2;
889 DrawEdge( hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
892 /*************************************************************************
893 * SHHelpShortcuts_RunDLLA [SHELL32.@]
896 DWORD WINAPI
SHHelpShortcuts_RunDLLA(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
898 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
902 /*************************************************************************
903 * SHHelpShortcuts_RunDLLA [SHELL32.@]
906 DWORD WINAPI
SHHelpShortcuts_RunDLLW(DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
908 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1
, dwArg2
, dwArg3
, dwArg4
);
912 /*************************************************************************
913 * SHLoadInProc [SHELL32.@]
914 * Create an instance of specified object class from within
915 * the shell process and release it immediately
917 HRESULT WINAPI
SHLoadInProc (REFCLSID rclsid
)
921 TRACE("%s\n", debugstr_guid(rclsid
));
923 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
926 IUnknown
* pUnk
= ptr
;
927 IUnknown_Release(pUnk
);
930 return DISP_E_MEMBERNOTFOUND
;
933 static void add_authors( HWND list
)
935 static const WCHAR eol
[] = {'\r','\n',0};
936 static const WCHAR authors
[] = {'A','U','T','H','O','R','S',0};
937 WCHAR
*strW
, *start
, *end
;
938 HRSRC rsrc
= FindResourceW( shell32_hInstance
, authors
, (LPCWSTR
)RT_RCDATA
);
939 char *strA
= LockResource( LoadResource( shell32_hInstance
, rsrc
));
940 DWORD sizeW
, sizeA
= SizeofResource( shell32_hInstance
, rsrc
);
943 sizeW
= MultiByteToWideChar( CP_UTF8
, 0, strA
, sizeA
, NULL
, 0 ) + 1;
944 if (!(strW
= HeapAlloc( GetProcessHeap(), 0, sizeW
* sizeof(WCHAR
) ))) return;
945 MultiByteToWideChar( CP_UTF8
, 0, strA
, sizeA
, strW
, sizeW
);
948 start
= strpbrkW( strW
, eol
); /* skip the header line */
951 while (*start
&& strchrW( eol
, *start
)) start
++;
953 end
= strpbrkW( start
, eol
);
955 SendMessageW( list
, LB_ADDSTRING
, -1, (LPARAM
)start
);
958 HeapFree( GetProcessHeap(), 0, strW
);
961 /*************************************************************************
962 * AboutDlgProc (internal)
964 static INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
975 ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
976 WCHAR
template[512], buffer
[512], version
[64];
977 extern const char *wine_get_build_id(void);
981 SendDlgItemMessageW(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
982 GetWindowTextW( hWnd
, template, sizeof(template)/sizeof(WCHAR
) );
983 sprintfW( buffer
, template, info
->szApp
);
984 SetWindowTextW( hWnd
, buffer
);
985 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT1
), info
->szApp
);
986 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT2
), info
->szOtherStuff
);
987 GetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
),
988 template, sizeof(template)/sizeof(WCHAR
) );
989 MultiByteToWideChar( CP_UTF8
, 0, wine_get_build_id(), -1,
990 version
, sizeof(version
)/sizeof(WCHAR
) );
991 sprintfW( buffer
, template, version
);
992 SetWindowTextW( GetDlgItem(hWnd
, IDC_ABOUT_STATIC_TEXT3
), buffer
);
993 hWndCtl
= GetDlgItem(hWnd
, IDC_ABOUT_LISTBOX
);
994 SendMessageW( hWndCtl
, WM_SETREDRAW
, 0, 0 );
995 SendMessageW( hWndCtl
, WM_SETFONT
, (WPARAM
)info
->hFont
, 0 );
996 add_authors( hWndCtl
);
997 SendMessageW( hWndCtl
, WM_SETREDRAW
, 1, 0 );
1005 HDC hDC
= BeginPaint( hWnd
, &ps
);
1006 paint_dropline( hDC
, hWnd
);
1007 EndPaint( hWnd
, &ps
);
1012 if (wParam
== IDOK
|| wParam
== IDCANCEL
)
1014 EndDialog(hWnd
, TRUE
);
1017 if (wParam
== IDC_ABOUT_LICENSE
)
1019 MSGBOXPARAMSW params
;
1021 params
.cbSize
= sizeof(params
);
1022 params
.hwndOwner
= hWnd
;
1023 params
.hInstance
= shell32_hInstance
;
1024 params
.lpszText
= MAKEINTRESOURCEW(IDS_LICENSE
);
1025 params
.lpszCaption
= MAKEINTRESOURCEW(IDS_LICENSE_CAPTION
);
1026 params
.dwStyle
= MB_ICONINFORMATION
| MB_OK
;
1027 params
.lpszIcon
= 0;
1028 params
.dwContextHelpId
= 0;
1029 params
.lpfnMsgBoxCallback
= NULL
;
1030 params
.dwLanguageId
= LANG_NEUTRAL
;
1031 MessageBoxIndirectW( ¶ms
);
1035 EndDialog(hWnd
, TRUE
);
1043 /*************************************************************************
1044 * ShellAboutA [SHELL32.288]
1046 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
, HICON hIcon
)
1049 LPWSTR appW
= NULL
, otherW
= NULL
;
1054 len
= MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, NULL
, 0);
1055 appW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1056 MultiByteToWideChar(CP_ACP
, 0, szApp
, -1, appW
, len
);
1060 len
= MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, NULL
, 0);
1061 otherW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1062 MultiByteToWideChar(CP_ACP
, 0, szOtherStuff
, -1, otherW
, len
);
1065 ret
= ShellAboutW(hWnd
, appW
, otherW
, hIcon
);
1067 HeapFree(GetProcessHeap(), 0, otherW
);
1068 HeapFree(GetProcessHeap(), 0, appW
);
1073 /*************************************************************************
1074 * ShellAboutW [SHELL32.289]
1076 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
1082 static const WCHAR wszSHELL_ABOUT_MSGBOX
[] =
1083 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1087 if (!hIcon
) hIcon
= LoadImageW( 0, (LPWSTR
)IDI_WINLOGO
, IMAGE_ICON
, 48, 48, LR_SHARED
);
1089 info
.szOtherStuff
= szOtherStuff
;
1092 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
1093 info
.hFont
= CreateFontIndirectW( &logFont
);
1095 bRet
= DialogBoxParamW( shell32_hInstance
, wszSHELL_ABOUT_MSGBOX
, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
1096 DeleteObject(info
.hFont
);
1100 /*************************************************************************
1101 * FreeIconList (SHELL32.@)
1103 void WINAPI
FreeIconList( DWORD dw
)
1105 FIXME("%x: stub\n",dw
);
1108 /*************************************************************************
1109 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1111 HRESULT WINAPI
SHLoadNonloadedIconOverlayIdentifiers( VOID
)
1117 /***********************************************************************
1118 * DllGetVersion [SHELL32.@]
1120 * Retrieves version information of the 'SHELL32.DLL'
1123 * pdvi [O] pointer to version information structure.
1127 * Failure: E_INVALIDARG
1130 * Returns version of a shell32.dll from IE4.01 SP1.
1133 HRESULT WINAPI
DllGetVersion (DLLVERSIONINFO
*pdvi
)
1135 /* FIXME: shouldn't these values come from the version resource? */
1136 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO
) ||
1137 pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1139 pdvi
->dwMajorVersion
= WINE_FILEVERSION_MAJOR
;
1140 pdvi
->dwMinorVersion
= WINE_FILEVERSION_MINOR
;
1141 pdvi
->dwBuildNumber
= WINE_FILEVERSION_BUILD
;
1142 pdvi
->dwPlatformID
= WINE_FILEVERSION_PLATFORMID
;
1143 if (pdvi
->cbSize
== sizeof(DLLVERSIONINFO2
))
1145 DLLVERSIONINFO2
*pdvi2
= (DLLVERSIONINFO2
*)pdvi
;
1148 pdvi2
->ullVersion
= MAKEDLLVERULL(WINE_FILEVERSION_MAJOR
,
1149 WINE_FILEVERSION_MINOR
,
1150 WINE_FILEVERSION_BUILD
,
1151 WINE_FILEVERSION_PLATFORMID
);
1153 TRACE("%u.%u.%u.%u\n",
1154 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
1155 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
1160 WARN("wrong DLLVERSIONINFO size from app\n");
1161 return E_INVALIDARG
;
1165 /*************************************************************************
1166 * global variables of the shell32.dll
1167 * all are once per process
1170 HINSTANCE shell32_hInstance
= 0;
1171 HIMAGELIST ShellSmallIconList
= 0;
1172 HIMAGELIST ShellBigIconList
= 0;
1175 /*************************************************************************
1179 * calling oleinitialize here breaks sone apps.
1181 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
1183 TRACE("%p 0x%x %p\n", hinstDLL
, fdwReason
, fImpLoad
);
1187 case DLL_PROCESS_ATTACH
:
1188 shell32_hInstance
= hinstDLL
;
1189 DisableThreadLibraryCalls(shell32_hInstance
);
1191 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1192 GetModuleFileNameW(hinstDLL
, swShell32Name
, MAX_PATH
);
1193 swShell32Name
[MAX_PATH
- 1] = '\0';
1195 InitCommonControlsEx(NULL
);
1198 InitChangeNotifications();
1201 case DLL_PROCESS_DETACH
:
1202 shell32_hInstance
= 0;
1204 FreeChangeNotifications();
1210 /*************************************************************************
1211 * DllInstall [SHELL32.@]
1215 * BOOL bInstall - TRUE for install, FALSE for uninstall
1216 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1219 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1221 FIXME("%s %s: stub\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1222 return S_OK
; /* indicate success */
1225 /***********************************************************************
1226 * DllCanUnloadNow (SHELL32.@)
1228 HRESULT WINAPI
DllCanUnloadNow(void)
1233 /***********************************************************************
1234 * ExtractVersionResource16W (SHELL32.@)
1236 BOOL WINAPI
ExtractVersionResource16W(LPWSTR s
, DWORD d
)
1238 FIXME("(%s %x) stub!\n", debugstr_w(s
), d
);
1242 /***********************************************************************
1243 * InitNetworkAddressControl (SHELL32.@)
1245 BOOL WINAPI
InitNetworkAddressControl(void)
1251 /***********************************************************************
1252 * ShellHookProc (SHELL32.@)
1254 LRESULT CALLBACK
ShellHookProc(DWORD a
, DWORD b
, DWORD c
)
1260 HRESULT WINAPI
SHGetLocalizedName(LPCWSTR path
, LPWSTR module
, UINT size
, INT
*res
)
1262 FIXME("%s %p %u %p: stub\n", debugstr_w(path
), module
, size
, res
);