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 SetLastError(ERROR_INVALID_PARAMETER);
103 /* Return the path to the executable */
104 DWORD len, deslen=MAX_PATH, size;
106 size = sizeof(LPWSTR) + deslen*sizeof(WCHAR) + sizeof(LPWSTR);
109 if (!(argv = LocalAlloc(LMEM_FIXED, size))) return NULL;
110 len = GetModuleFileNameW(0, (LPWSTR)(argv+1), deslen);
116 if (len < deslen) break;
118 size = sizeof(LPWSTR) + deslen*sizeof(WCHAR) + sizeof(LPWSTR);
121 argv[0]=(LPWSTR)(argv+1);
127 /* to get a writable copy */
134 if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes))
138 /* skip the remaining spaces */
139 while (*cs==0x0009 || *cs==0x0020) {
147 else if (*cs==0x005c)
149 /* '\', count them */
152 else if ((*cs==0x0022) && ((bcount & 1)==0))
155 in_quotes=!in_quotes;
160 /* a regular character */
165 /* Allocate in a single lump, the string array, and the strings that go with it.
166 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
168 argv=LocalAlloc(LMEM_FIXED, argc*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
171 cmdline=(LPWSTR)(argv+argc);
172 strcpyW(cmdline, lpCmdline);
180 if ((*s==0x0009 || *s==0x0020) && !in_quotes)
182 /* Close the argument and copy it */
186 /* skip the remaining spaces */
189 } while (*s==0x0009 || *s==0x0020);
191 /* Start with a new argument */
206 /* Preceded by an even number of '\', this is half that
207 * number of '\', plus a quote which we erase.
210 in_quotes=!in_quotes;
215 /* Preceded by an odd number of '\', this is half that
216 * number of '\' followed by a '"'
226 /* a regular character */
241 static DWORD shgfi_get_exe_type(LPCWSTR szFullPath)
246 IMAGE_DOS_HEADER mz_header;
251 status = GetBinaryTypeW (szFullPath, &BinaryType);
254 if (BinaryType == SCS_DOS_BINARY || BinaryType == SCS_PIF_BINARY)
257 hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ,
258 NULL, OPEN_EXISTING, 0, 0 );
259 if ( hfile == INVALID_HANDLE_VALUE )
263 * The next section is adapted from MODULE_GetBinaryType, as we need
264 * to examine the image header to get OS and version information. We
265 * know from calling GetBinaryTypeA that the image is valid and either
266 * an NE or PE, so much error handling can be omitted.
267 * Seek to the start of the file and read the header information.
270 SetFilePointer( hfile, 0, NULL, SEEK_SET );
271 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
273 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
274 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
275 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
277 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
278 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
279 CloseHandle( hfile );
280 /* DLL files are not executable and should return 0 */
281 if (nt.FileHeader.Characteristics & IMAGE_FILE_DLL)
283 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI)
285 return IMAGE_NT_SIGNATURE |
286 (nt.OptionalHeader.MajorSubsystemVersion << 24) |
287 (nt.OptionalHeader.MinorSubsystemVersion << 16);
289 return IMAGE_NT_SIGNATURE;
291 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
294 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
295 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
296 CloseHandle( hfile );
297 if (ne.ne_exetyp == 2)
298 return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16);
301 CloseHandle( hfile );
305 /*************************************************************************
306 * SHELL_IsShortcut [internal]
308 * Decide if an item id list points to a shell shortcut
310 BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast)
312 char szTemp[MAX_PATH];
316 if (_ILGetExtension(pidlLast, szTemp, MAX_PATH) &&
317 HCR_MapTypeToValueA(szTemp, szTemp, MAX_PATH, TRUE))
319 if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_QUERY_VALUE, &keyCls))
321 if (ERROR_SUCCESS == RegQueryValueExA(keyCls, "IsShortcut", NULL, NULL, NULL, NULL))
331 #define SHGFI_KNOWN_FLAGS \
332 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
333 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
334 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
335 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
336 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
338 /*************************************************************************
339 * SHGetFileInfoW [SHELL32.@]
342 DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
343 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
345 WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
347 DWORD_PTR ret = TRUE;
348 DWORD dwAttributes = 0;
349 IShellFolder * psfParent = NULL;
350 IExtractIconW * pei = NULL;
351 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
353 BOOL IconNotYetLoaded=TRUE;
356 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
357 (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
358 psfi, psfi->dwAttributes, sizeofpsfi, flags);
363 /* windows initializes these values regardless of the flags */
366 psfi->szDisplayName[0] = '\0';
367 psfi->szTypeName[0] = '\0';
371 if (!(flags & SHGFI_PIDL))
373 /* SHGetFileInfo should work with absolute and relative paths */
374 if (PathIsRelativeW(path))
376 GetCurrentDirectoryW(MAX_PATH, szLocation);
377 PathCombineW(szFullPath, szLocation, path);
381 lstrcpynW(szFullPath, path, MAX_PATH);
385 if (flags & SHGFI_EXETYPE)
387 if (flags != SHGFI_EXETYPE)
389 return shgfi_get_exe_type(szFullPath);
393 * psfi is NULL normally to query EXE type. If it is NULL, none of the
394 * below makes sense anyway. Windows allows this and just returns FALSE
400 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
402 * The pidl functions fail on not existing file names
405 if (flags & SHGFI_PIDL)
407 pidl = ILClone((LPCITEMIDLIST)path);
409 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
411 hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
414 if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
416 /* get the parent shellfolder */
419 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent,
420 (LPCITEMIDLIST*)&pidlLast );
422 pidlLast = ILClone(pidlLast);
427 ERR("pidl is null!\n");
432 /* get the attributes of the child */
433 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
435 if (!(flags & SHGFI_ATTR_SPECIFIED))
437 psfi->dwAttributes = 0xffffffff;
440 IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
441 &(psfi->dwAttributes) );
444 /* get the displayname */
445 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
447 if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
449 lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
454 hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast,
455 SHGDN_INFOLDER, &str);
456 StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
460 /* get the type name */
461 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
463 static const WCHAR szFile[] = { 'F','i','l','e',0 };
464 static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
466 if (!(flags & SHGFI_USEFILEATTRIBUTES) || (flags & SHGFI_PIDL))
470 _ILGetFileType(pidlLast, ftype, 80);
471 MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
475 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
476 strcatW (psfi->szTypeName, szFile);
481 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
482 if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
483 HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
485 lstrcpynW (psfi->szTypeName, sTemp, 64);
486 strcatW (psfi->szTypeName, szDashFile);
493 if (flags & SHGFI_OPENICON)
494 uGilFlags |= GIL_OPENICON;
496 if (flags & SHGFI_LINKOVERLAY)
497 uGilFlags |= GIL_FORSHORTCUT;
498 else if ((flags&SHGFI_ADDOVERLAYS) ||
499 (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON)
501 if (SHELL_IsShortcut(pidlLast))
502 uGilFlags |= GIL_FORSHORTCUT;
505 if (flags & SHGFI_OVERLAYINDEX)
506 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
508 if (flags & SHGFI_SELECTED)
509 FIXME("set icon to selected, stub\n");
511 if (flags & SHGFI_SHELLICONSIZE)
512 FIXME("set icon to shell size, stub\n");
514 /* get the iconlocation */
515 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
519 if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
521 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
523 lstrcpyW(psfi->szDisplayName, swShell32Name);
524 psfi->iIcon = -IDI_SHELL_FOLDER;
529 static const WCHAR p1W[] = {'%','1',0};
530 WCHAR sTemp [MAX_PATH];
532 szExt = PathFindExtensionW(szFullPath);
533 TRACE("szExt=%s\n", debugstr_w(szExt));
535 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
536 HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &psfi->iIcon))
538 if (lstrcmpW(p1W, sTemp))
539 strcpyW(psfi->szDisplayName, sTemp);
542 /* the icon is in the file */
543 strcpyW(psfi->szDisplayName, szFullPath);
552 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
553 (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
554 &uDummy, (LPVOID*)&pei);
557 hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
558 szLocation, MAX_PATH, &iIndex, &uFlags);
560 if (uFlags & GIL_NOTFILENAME)
564 lstrcpyW (psfi->szDisplayName, szLocation);
565 psfi->iIcon = iIndex;
567 IExtractIconW_Release(pei);
572 /* get icon index (or load icon)*/
573 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
575 if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL))
577 WCHAR sTemp [MAX_PATH];
581 lstrcpynW(sTemp, szFullPath, MAX_PATH);
583 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
584 psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0);
587 static const WCHAR p1W[] = {'%','1',0};
590 szExt = PathFindExtensionW(sTemp);
592 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
593 HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &icon_idx))
595 if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
596 strcpyW(sTemp, szFullPath);
598 if (flags & SHGFI_SYSICONINDEX)
600 psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
601 if (psfi->iIcon == -1)
607 if (flags & SHGFI_SMALLICON)
608 ret = PrivateExtractIconsW( sTemp,icon_idx,
609 GetSystemMetrics( SM_CXSMICON ),
610 GetSystemMetrics( SM_CYSMICON ),
611 &psfi->hIcon, 0, 1, 0);
613 ret = PrivateExtractIconsW( sTemp, icon_idx,
614 GetSystemMetrics( SM_CXICON),
615 GetSystemMetrics( SM_CYICON),
616 &psfi->hIcon, 0, 1, 0);
617 if (ret != 0 && ret != (UINT)-1)
619 IconNotYetLoaded=FALSE;
620 psfi->iIcon = icon_idx;
628 if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
629 uGilFlags, &(psfi->iIcon))))
634 if (ret && (flags & SHGFI_SYSICONINDEX))
636 if (flags & SHGFI_SMALLICON)
637 ret = (DWORD_PTR) ShellSmallIconList;
639 ret = (DWORD_PTR) ShellBigIconList;
644 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
646 if (flags & SHGFI_SMALLICON)
647 psfi->hIcon = ImageList_GetIcon( ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
649 psfi->hIcon = ImageList_GetIcon( ShellBigIconList, psfi->iIcon, ILD_NORMAL);
652 if (flags & ~SHGFI_KNOWN_FLAGS)
653 FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
656 IShellFolder_Release(psfParent);
663 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
664 psfi->hIcon, psfi->iIcon, psfi->dwAttributes,
665 debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
670 /*************************************************************************
671 * SHGetFileInfoA [SHELL32.@]
674 * MSVBVM60.__vbaNew2 expects this function to return a value in range
675 * 1 .. 0x7fff when the function succeeds and flags does not contain
676 * SHGFI_EXETYPE or SHGFI_SYSICONINDEX (see bug 7701)
678 DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
679 SHFILEINFOA *psfi, UINT sizeofpsfi,
683 LPWSTR temppath = NULL;
686 SHFILEINFOW temppsfi;
688 if (flags & SHGFI_PIDL)
690 /* path contains a pidl */
691 pathW = (LPCWSTR)path;
695 len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
696 temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
697 MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
701 if (psfi && (flags & SHGFI_ATTR_SPECIFIED))
702 temppsfi.dwAttributes=psfi->dwAttributes;
705 ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, sizeof(temppsfi), flags);
707 ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
711 if(flags & SHGFI_ICON)
712 psfi->hIcon=temppsfi.hIcon;
713 if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
714 psfi->iIcon=temppsfi.iIcon;
715 if(flags & SHGFI_ATTRIBUTES)
716 psfi->dwAttributes=temppsfi.dwAttributes;
717 if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
719 WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
720 psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
722 if(flags & SHGFI_TYPENAME)
724 WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
725 psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
729 HeapFree(GetProcessHeap(), 0, temppath);
734 /*************************************************************************
735 * DuplicateIcon [SHELL32.@]
737 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
742 TRACE("%p %p\n", hInstance, hIcon);
744 if (GetIconInfo(hIcon, &IconInfo))
746 hDupIcon = CreateIconIndirect(&IconInfo);
748 /* clean up hbmMask and hbmColor */
749 DeleteObject(IconInfo.hbmMask);
750 DeleteObject(IconInfo.hbmColor);
756 /*************************************************************************
757 * ExtractIconA [SHELL32.@]
759 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
762 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
763 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
765 TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
767 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
768 ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
769 HeapFree(GetProcessHeap(), 0, lpwstrFile);
774 /*************************************************************************
775 * ExtractIconW [SHELL32.@]
777 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
781 UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
783 TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
785 if (nIconIndex == (UINT)-1)
787 ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
788 if (ret != (UINT)-1 && ret)
789 return (HICON)(UINT_PTR)ret;
793 ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
797 else if (ret > 0 && hIcon)
803 HRESULT WINAPI SHCreateFileExtractIconW(LPCWSTR file, DWORD attribs, REFIID riid, void **ppv)
805 FIXME("%s, %x, %s, %p\n", debugstr_w(file), attribs, debugstr_guid(riid), ppv);
810 /*************************************************************************
811 * Printer_LoadIconsW [SHELL32.205]
813 VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
815 INT iconindex=IDI_SHELL_PRINTER;
817 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);
819 /* We should check if wsPrinterName is
820 1. the Default Printer or not
822 3. a Local Printer or a Network-Printer
823 and use different Icons
825 if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
827 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
830 if(pLargeIcon != NULL)
831 *pLargeIcon = LoadImageW(shell32_hInstance,
832 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
833 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
835 if(pSmallIcon != NULL)
836 *pSmallIcon = LoadImageW(shell32_hInstance,
837 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
838 16, 16, LR_DEFAULTCOLOR);
841 /*************************************************************************
842 * Printers_RegisterWindowW [SHELL32.213]
843 * used by "printui.dll":
844 * find the Window of the given Type for the specific Printer and
845 * return the already existent hwnd or open a new window
847 BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType,
848 HANDLE * phClassPidl, HWND * phwnd)
850 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType,
851 phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL,
852 phwnd, (phwnd != NULL) ? *(phwnd) : NULL);
857 /*************************************************************************
858 * Printers_UnregisterWindow [SHELL32.214]
860 VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd)
862 FIXME("(%p, %p) stub!\n", hClassPidl, hwnd);
865 /*************************************************************************
866 * SHGetPropertyStoreFromParsingName [SHELL32.@]
868 HRESULT WINAPI SHGetPropertyStoreFromParsingName(PCWSTR pszPath, IBindCtx *pbc, GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv)
870 FIXME("(%s %p %u %p %p) stub!\n", debugstr_w(pszPath), pbc, flags, riid, ppv);
874 /*************************************************************************/
879 LPCWSTR szOtherStuff;
884 #define DROP_FIELD_TOP (-12)
886 static void paint_dropline( HDC hdc, HWND hWnd )
888 HWND hWndCtl = GetDlgItem(hWnd, IDC_ABOUT_WINE_TEXT);
891 if (!hWndCtl) return;
892 GetWindowRect( hWndCtl, &rect );
893 MapWindowPoints( 0, hWnd, (LPPOINT)&rect, 2 );
894 rect.top += DROP_FIELD_TOP;
895 rect.bottom = rect.top + 2;
896 DrawEdge( hdc, &rect, BDR_SUNKENOUTER, BF_RECT );
899 /*************************************************************************
900 * SHHelpShortcuts_RunDLLA [SHELL32.@]
903 DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
905 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
909 /*************************************************************************
910 * SHHelpShortcuts_RunDLLA [SHELL32.@]
913 DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
915 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
919 /*************************************************************************
920 * SHLoadInProc [SHELL32.@]
921 * Create an instance of specified object class from within
922 * the shell process and release it immediately
924 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
928 TRACE("%s\n", debugstr_guid(rclsid));
930 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
933 IUnknown * pUnk = ptr;
934 IUnknown_Release(pUnk);
937 return DISP_E_MEMBERNOTFOUND;
940 static void add_authors( HWND list )
942 static const WCHAR eol[] = {'\r','\n',0};
943 static const WCHAR authors[] = {'A','U','T','H','O','R','S',0};
944 WCHAR *strW, *start, *end;
945 HRSRC rsrc = FindResourceW( shell32_hInstance, authors, (LPCWSTR)RT_RCDATA );
946 char *strA = LockResource( LoadResource( shell32_hInstance, rsrc ));
947 DWORD sizeW, sizeA = SizeofResource( shell32_hInstance, rsrc );
950 sizeW = MultiByteToWideChar( CP_UTF8, 0, strA, sizeA, NULL, 0 ) + 1;
951 if (!(strW = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) ))) return;
952 MultiByteToWideChar( CP_UTF8, 0, strA, sizeA, strW, sizeW );
955 start = strpbrkW( strW, eol ); /* skip the header line */
958 while (*start && strchrW( eol, *start )) start++;
960 end = strpbrkW( start, eol );
962 SendMessageW( list, LB_ADDSTRING, -1, (LPARAM)start );
965 HeapFree( GetProcessHeap(), 0, strW );
968 /*************************************************************************
969 * AboutDlgProc (internal)
971 static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
982 ABOUT_INFO *info = (ABOUT_INFO *)lParam;
983 WCHAR template[512], buffer[512], version[64];
984 extern const char *wine_get_build_id(void);
988 SendDlgItemMessageW(hWnd, stc1, STM_SETICON,(WPARAM)info->hIcon, 0);
989 GetWindowTextW( hWnd, template, sizeof(template)/sizeof(WCHAR) );
990 sprintfW( buffer, template, info->szApp );
991 SetWindowTextW( hWnd, buffer );
992 SetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT1), info->szApp );
993 SetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT2), info->szOtherStuff );
994 GetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT3),
995 template, sizeof(template)/sizeof(WCHAR) );
996 MultiByteToWideChar( CP_UTF8, 0, wine_get_build_id(), -1,
997 version, sizeof(version)/sizeof(WCHAR) );
998 sprintfW( buffer, template, version );
999 SetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT3), buffer );
1000 hWndCtl = GetDlgItem(hWnd, IDC_ABOUT_LISTBOX);
1001 SendMessageW( hWndCtl, WM_SETREDRAW, 0, 0 );
1002 SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)info->hFont, 0 );
1003 add_authors( hWndCtl );
1004 SendMessageW( hWndCtl, WM_SETREDRAW, 1, 0 );
1012 HDC hDC = BeginPaint( hWnd, &ps );
1013 paint_dropline( hDC, hWnd );
1014 EndPaint( hWnd, &ps );
1019 if (wParam == IDOK || wParam == IDCANCEL)
1021 EndDialog(hWnd, TRUE);
1024 if (wParam == IDC_ABOUT_LICENSE)
1026 MSGBOXPARAMSW params;
1028 params.cbSize = sizeof(params);
1029 params.hwndOwner = hWnd;
1030 params.hInstance = shell32_hInstance;
1031 params.lpszText = MAKEINTRESOURCEW(IDS_LICENSE);
1032 params.lpszCaption = MAKEINTRESOURCEW(IDS_LICENSE_CAPTION);
1033 params.dwStyle = MB_ICONINFORMATION | MB_OK;
1034 params.lpszIcon = 0;
1035 params.dwContextHelpId = 0;
1036 params.lpfnMsgBoxCallback = NULL;
1037 params.dwLanguageId = LANG_NEUTRAL;
1038 MessageBoxIndirectW( ¶ms );
1042 EndDialog(hWnd, TRUE);
1050 /*************************************************************************
1051 * ShellAboutA [SHELL32.288]
1053 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon )
1056 LPWSTR appW = NULL, otherW = NULL;
1061 len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0);
1062 appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1063 MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len);
1067 len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0);
1068 otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1069 MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len);
1072 ret = ShellAboutW(hWnd, appW, otherW, hIcon);
1074 HeapFree(GetProcessHeap(), 0, otherW);
1075 HeapFree(GetProcessHeap(), 0, appW);
1080 /*************************************************************************
1081 * ShellAboutW [SHELL32.289]
1083 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
1089 static const WCHAR wszSHELL_ABOUT_MSGBOX[] =
1090 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1094 if (!hIcon) hIcon = LoadImageW( 0, (LPWSTR)IDI_WINLOGO, IMAGE_ICON, 48, 48, LR_SHARED );
1096 info.szOtherStuff = szOtherStuff;
1099 SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
1100 info.hFont = CreateFontIndirectW( &logFont );
1102 bRet = DialogBoxParamW( shell32_hInstance, wszSHELL_ABOUT_MSGBOX, hWnd, AboutDlgProc, (LPARAM)&info );
1103 DeleteObject(info.hFont);
1107 /*************************************************************************
1108 * FreeIconList (SHELL32.@)
1110 void WINAPI FreeIconList( DWORD dw )
1112 FIXME("%x: stub\n",dw);
1115 /*************************************************************************
1116 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1118 HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID )
1124 /***********************************************************************
1125 * DllGetVersion [SHELL32.@]
1127 * Retrieves version information of the 'SHELL32.DLL'
1130 * pdvi [O] pointer to version information structure.
1134 * Failure: E_INVALIDARG
1137 * Returns version of a shell32.dll from IE4.01 SP1.
1140 HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
1142 /* FIXME: shouldn't these values come from the version resource? */
1143 if (pdvi->cbSize == sizeof(DLLVERSIONINFO) ||
1144 pdvi->cbSize == sizeof(DLLVERSIONINFO2))
1146 pdvi->dwMajorVersion = WINE_FILEVERSION_MAJOR;
1147 pdvi->dwMinorVersion = WINE_FILEVERSION_MINOR;
1148 pdvi->dwBuildNumber = WINE_FILEVERSION_BUILD;
1149 pdvi->dwPlatformID = WINE_FILEVERSION_PLATFORMID;
1150 if (pdvi->cbSize == sizeof(DLLVERSIONINFO2))
1152 DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi;
1155 pdvi2->ullVersion = MAKEDLLVERULL(WINE_FILEVERSION_MAJOR,
1156 WINE_FILEVERSION_MINOR,
1157 WINE_FILEVERSION_BUILD,
1158 WINE_FILEVERSION_PLATFORMID);
1160 TRACE("%u.%u.%u.%u\n",
1161 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
1162 pdvi->dwBuildNumber, pdvi->dwPlatformID);
1167 WARN("wrong DLLVERSIONINFO size from app\n");
1168 return E_INVALIDARG;
1172 /*************************************************************************
1173 * global variables of the shell32.dll
1174 * all are once per process
1177 HINSTANCE shell32_hInstance = 0;
1178 HIMAGELIST ShellSmallIconList = 0;
1179 HIMAGELIST ShellBigIconList = 0;
1182 /*************************************************************************
1186 * calling oleinitialize here breaks some apps.
1188 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
1190 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
1194 case DLL_PROCESS_ATTACH:
1195 shell32_hInstance = hinstDLL;
1196 DisableThreadLibraryCalls(shell32_hInstance);
1198 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1199 GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH);
1200 swShell32Name[MAX_PATH - 1] = '\0';
1202 InitCommonControlsEx(NULL);
1205 InitChangeNotifications();
1208 case DLL_PROCESS_DETACH:
1209 shell32_hInstance = 0;
1211 FreeChangeNotifications();
1217 /*************************************************************************
1218 * DllInstall [SHELL32.@]
1222 * BOOL bInstall - TRUE for install, FALSE for uninstall
1223 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1226 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
1228 FIXME("%s %s: stub\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1229 return S_OK; /* indicate success */
1232 /***********************************************************************
1233 * DllCanUnloadNow (SHELL32.@)
1235 HRESULT WINAPI DllCanUnloadNow(void)
1240 /***********************************************************************
1241 * DllRegisterServer (SHELL32.@)
1243 HRESULT WINAPI DllRegisterServer(void)
1245 HRESULT hr = __wine_register_resources( shell32_hInstance );
1246 if (SUCCEEDED(hr)) hr = SHELL_RegisterShellFolders();
1250 /***********************************************************************
1251 * DllUnregisterServer (SHELL32.@)
1253 HRESULT WINAPI DllUnregisterServer(void)
1255 return __wine_unregister_resources( shell32_hInstance );
1258 /***********************************************************************
1259 * ExtractVersionResource16W (SHELL32.@)
1261 BOOL WINAPI ExtractVersionResource16W(LPWSTR s, DWORD d)
1263 FIXME("(%s %x) stub!\n", debugstr_w(s), d);
1267 /***********************************************************************
1268 * InitNetworkAddressControl (SHELL32.@)
1270 BOOL WINAPI InitNetworkAddressControl(void)
1276 /***********************************************************************
1277 * ShellHookProc (SHELL32.@)
1279 LRESULT CALLBACK ShellHookProc(DWORD a, DWORD b, DWORD c)
1285 /***********************************************************************
1286 * SHGetLocalizedName (SHELL32.@)
1288 HRESULT WINAPI SHGetLocalizedName(LPCWSTR path, LPWSTR module, UINT size, INT *res)
1290 FIXME("%s %p %u %p: stub\n", debugstr_w(path), module, size, res);
1294 /***********************************************************************
1295 * SetCurrentProcessExplicitAppUserModelID (SHELL32.@)
1297 HRESULT WINAPI SetCurrentProcessExplicitAppUserModelID(PCWSTR appid)
1299 FIXME("%s: stub\n", debugstr_w(appid));
1303 /***********************************************************************
1304 * SHSetUnreadMailCountW (SHELL32.@)
1306 HRESULT WINAPI SHSetUnreadMailCountW(LPCWSTR mailaddress, DWORD count, LPCWSTR executecommand)
1308 FIXME("%s %x %s: stub\n", debugstr_w(mailaddress), count, debugstr_w(executecommand));