4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
43 #include "undocshell.h"
45 #include "shell32_main.h"
49 #include "wine/debug.h"
50 #include "wine/unicode.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(shell);
54 extern const char * const SHELL_Authors[];
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)
98 /* Return the path to the executable */
101 hargv=GlobalAlloc(size, 0);
102 argv=GlobalLock(hargv);
105 len = GetModuleFileNameW(0, (LPWSTR)(argv+1), size-sizeof(LPWSTR));
111 if (len < size) break;
113 hargv=GlobalReAlloc(hargv, size, 0);
114 argv=GlobalLock(hargv);
116 argv[0]=(LPWSTR)(argv+1);
123 /* to get a writable copy */
130 if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes))
134 /* skip the remaining spaces */
135 while (*cs==0x0009 || *cs==0x0020) {
143 else if (*cs==0x005c)
145 /* '\', count them */
148 else if ((*cs==0x0022) && ((bcount & 1)==0))
151 in_quotes=!in_quotes;
156 /* a regular character */
161 /* Allocate in a single lump, the string array, and the strings that go with it.
162 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
164 hargv=GlobalAlloc(0, argc*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
165 argv=GlobalLock(hargv);
168 cmdline=(LPWSTR)(argv+argc);
169 strcpyW(cmdline, lpCmdline);
177 if ((*s==0x0009 || *s==0x0020) && !in_quotes)
179 /* Close the argument and copy it */
183 /* skip the remaining spaces */
186 } while (*s==0x0009 || *s==0x0020);
188 /* Start with a new argument */
203 /* Preceded by an even number of '\', this is half that
204 * number of '\', plus a quote which we erase.
207 in_quotes=!in_quotes;
212 /* Preceded by an odd number of '\', this is half that
213 * number of '\' followed by a '"'
223 /* a regular character */
239 static DWORD shgfi_get_exe_type(LPCWSTR szFullPath)
244 IMAGE_DOS_HEADER mz_header;
249 status = GetBinaryTypeW (szFullPath, &BinaryType);
252 if (BinaryType == SCS_DOS_BINARY || BinaryType == SCS_PIF_BINARY)
255 hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ,
256 NULL, OPEN_EXISTING, 0, 0 );
257 if ( hfile == INVALID_HANDLE_VALUE )
261 * The next section is adapted from MODULE_GetBinaryType, as we need
262 * to examine the image header to get OS and version information. We
263 * know from calling GetBinaryTypeA that the image is valid and either
264 * an NE or PE, so much error handling can be omitted.
265 * Seek to the start of the file and read the header information.
268 SetFilePointer( hfile, 0, NULL, SEEK_SET );
269 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
271 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
272 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
273 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
275 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
276 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
277 CloseHandle( hfile );
278 /* DLL files are not executable and should return 0 */
279 if (nt.FileHeader.Characteristics & IMAGE_FILE_DLL)
281 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI)
283 return IMAGE_NT_SIGNATURE |
284 (nt.OptionalHeader.MajorSubsystemVersion << 24) |
285 (nt.OptionalHeader.MinorSubsystemVersion << 16);
287 return IMAGE_NT_SIGNATURE;
289 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
292 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
293 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
294 CloseHandle( hfile );
295 if (ne.ne_exetyp == 2)
296 return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16);
299 CloseHandle( hfile );
303 /*************************************************************************
304 * SHELL_IsShortcut [internal]
306 * Decide if an item id list points to a shell shortcut
308 BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast)
310 char szTemp[MAX_PATH];
314 if (_ILGetExtension(pidlLast, szTemp, MAX_PATH) &&
315 HCR_MapTypeToValueA(szTemp, szTemp, MAX_PATH, TRUE))
317 if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_QUERY_VALUE, &keyCls))
319 if (ERROR_SUCCESS == RegQueryValueExA(keyCls, "IsShortcut", NULL, NULL, NULL, NULL))
329 #define SHGFI_KNOWN_FLAGS \
330 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
331 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
332 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
333 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
334 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
336 /*************************************************************************
337 * SHGetFileInfoW [SHELL32.@]
340 DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
341 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
343 WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
345 DWORD_PTR ret = TRUE;
346 DWORD dwAttributes = 0;
347 IShellFolder * psfParent = NULL;
348 IExtractIconW * pei = NULL;
349 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
351 BOOL IconNotYetLoaded=TRUE;
354 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
355 (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
356 psfi, psfi->dwAttributes, sizeofpsfi, flags);
358 if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
359 (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
362 /* windows initializes these values regardless of the flags */
365 psfi->szDisplayName[0] = '\0';
366 psfi->szTypeName[0] = '\0';
370 if (!(flags & SHGFI_PIDL))
372 /* SHGetFileInfo should work with absolute and relative paths */
373 if (PathIsRelativeW(path))
375 GetCurrentDirectoryW(MAX_PATH, szLocation);
376 PathCombineW(szFullPath, szLocation, path);
380 lstrcpynW(szFullPath, path, MAX_PATH);
384 if (flags & SHGFI_EXETYPE)
386 if (flags != SHGFI_EXETYPE)
388 return shgfi_get_exe_type(szFullPath);
392 * psfi is NULL normally to query EXE type. If it is NULL, none of the
393 * below makes sense anyway. Windows allows this and just returns FALSE
399 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
401 * The pidl functions fail on not existing file names
404 if (flags & SHGFI_PIDL)
406 pidl = ILClone((LPCITEMIDLIST)path);
408 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
410 hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
413 if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
415 /* get the parent shellfolder */
418 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent,
419 (LPCITEMIDLIST*)&pidlLast );
421 pidlLast = ILClone(pidlLast);
426 ERR("pidl is null!\n");
431 /* get the attributes of the child */
432 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
434 if (!(flags & SHGFI_ATTR_SPECIFIED))
436 psfi->dwAttributes = 0xffffffff;
438 IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
439 &(psfi->dwAttributes) );
442 /* get the displayname */
443 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
445 if (flags & SHGFI_USEFILEATTRIBUTES)
447 lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
452 hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast,
453 SHGDN_INFOLDER, &str);
454 StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
458 /* get the type name */
459 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
461 static const WCHAR szFile[] = { 'F','i','l','e',0 };
462 static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
464 if (!(flags & SHGFI_USEFILEATTRIBUTES))
468 _ILGetFileType(pidlLast, ftype, 80);
469 MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
473 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
474 strcatW (psfi->szTypeName, szFile);
479 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
480 if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
481 HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
483 lstrcpynW (psfi->szTypeName, sTemp, 64);
484 strcatW (psfi->szTypeName, szDashFile);
491 if (flags & SHGFI_OPENICON)
492 uGilFlags |= GIL_OPENICON;
494 if (flags & SHGFI_LINKOVERLAY)
495 uGilFlags |= GIL_FORSHORTCUT;
496 else if ((flags&SHGFI_ADDOVERLAYS) ||
497 (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON)
499 if (SHELL_IsShortcut(pidlLast))
500 uGilFlags |= GIL_FORSHORTCUT;
503 if (flags & SHGFI_OVERLAYINDEX)
504 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
506 if (flags & SHGFI_SELECTED)
507 FIXME("set icon to selected, stub\n");
509 if (flags & SHGFI_SHELLICONSIZE)
510 FIXME("set icon to shell size, stub\n");
512 /* get the iconlocation */
513 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
517 if (flags & SHGFI_USEFILEATTRIBUTES)
519 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
521 lstrcpyW(psfi->szDisplayName, swShell32Name);
522 psfi->iIcon = -IDI_SHELL_FOLDER;
527 static const WCHAR p1W[] = {'%','1',0};
528 WCHAR sTemp [MAX_PATH];
530 szExt = (LPWSTR) PathFindExtensionW(szFullPath);
531 TRACE("szExt=%s\n", debugstr_w(szExt));
533 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
534 HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &psfi->iIcon))
536 if (lstrcmpW(p1W, sTemp))
537 strcpyW(psfi->szDisplayName, sTemp);
540 /* the icon is in the file */
541 strcpyW(psfi->szDisplayName, szFullPath);
550 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
551 (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
552 &uDummy, (LPVOID*)&pei);
555 hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
556 szLocation, MAX_PATH, &iIndex, &uFlags);
558 if (uFlags & GIL_NOTFILENAME)
562 lstrcpyW (psfi->szDisplayName, szLocation);
563 psfi->iIcon = iIndex;
565 IExtractIconW_Release(pei);
570 /* get icon index (or load icon)*/
571 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
573 if (flags & SHGFI_USEFILEATTRIBUTES)
575 WCHAR sTemp [MAX_PATH];
579 lstrcpynW(sTemp, szFullPath, MAX_PATH);
581 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
582 psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0);
585 static const WCHAR p1W[] = {'%','1',0};
588 szExt = (LPWSTR) PathFindExtensionW(sTemp);
590 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
591 HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &icon_idx))
593 if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
594 strcpyW(sTemp, szFullPath);
596 if (flags & SHGFI_SYSICONINDEX)
598 psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
599 if (psfi->iIcon == -1)
604 IconNotYetLoaded=FALSE;
605 if (flags & SHGFI_SMALLICON)
606 PrivateExtractIconsW( sTemp,icon_idx,
607 GetSystemMetrics( SM_CXSMICON ),
608 GetSystemMetrics( SM_CYSMICON ),
609 &psfi->hIcon, 0, 1, 0);
611 PrivateExtractIconsW( sTemp, icon_idx,
612 GetSystemMetrics( SM_CXICON),
613 GetSystemMetrics( SM_CYICON),
614 &psfi->hIcon, 0, 1, 0);
615 psfi->iIcon = icon_idx;
622 if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
623 uGilFlags, &(psfi->iIcon))))
630 if (flags & SHGFI_SMALLICON)
631 ret = (DWORD_PTR) ShellSmallIconList;
633 ret = (DWORD_PTR) ShellBigIconList;
638 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
640 if (flags & SHGFI_SMALLICON)
641 psfi->hIcon = ImageList_GetIcon( ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
643 psfi->hIcon = ImageList_GetIcon( ShellBigIconList, psfi->iIcon, ILD_NORMAL);
646 if (flags & ~SHGFI_KNOWN_FLAGS)
647 FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
650 IShellFolder_Release(psfParent);
658 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
659 psfi->hIcon, psfi->iIcon, psfi->dwAttributes,
660 debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
666 /*************************************************************************
667 * SHGetFileInfoA [SHELL32.@]
669 DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
670 SHFILEINFOA *psfi, UINT sizeofpsfi,
674 LPWSTR temppath = NULL;
677 SHFILEINFOW temppsfi;
679 if (flags & SHGFI_PIDL)
681 /* path contains a pidl */
682 pathW = (LPCWSTR)path;
686 len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
687 temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
688 MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
692 if (psfi && (flags & SHGFI_ATTR_SPECIFIED))
693 temppsfi.dwAttributes=psfi->dwAttributes;
696 ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, sizeof(temppsfi), flags);
698 ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
702 if(flags & SHGFI_ICON)
703 psfi->hIcon=temppsfi.hIcon;
704 if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
705 psfi->iIcon=temppsfi.iIcon;
706 if(flags & SHGFI_ATTRIBUTES)
707 psfi->dwAttributes=temppsfi.dwAttributes;
708 if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
710 WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
711 psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
713 if(flags & SHGFI_TYPENAME)
715 WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
716 psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
720 HeapFree(GetProcessHeap(), 0, temppath);
725 /*************************************************************************
726 * DuplicateIcon [SHELL32.@]
728 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
733 TRACE("%p %p\n", hInstance, hIcon);
735 if (GetIconInfo(hIcon, &IconInfo))
737 hDupIcon = CreateIconIndirect(&IconInfo);
739 /* clean up hbmMask and hbmColor */
740 DeleteObject(IconInfo.hbmMask);
741 DeleteObject(IconInfo.hbmColor);
747 /*************************************************************************
748 * ExtractIconA [SHELL32.@]
750 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
753 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
754 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
756 TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
758 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
759 ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
760 HeapFree(GetProcessHeap(), 0, lpwstrFile);
765 /*************************************************************************
766 * ExtractIconW [SHELL32.@]
768 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
772 UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
774 TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
776 if (nIconIndex == 0xFFFFFFFF)
778 ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
779 if (ret != 0xFFFFFFFF && ret)
780 return (HICON)(UINT_PTR)ret;
784 ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
786 if (ret == 0xFFFFFFFF)
788 else if (ret > 0 && hIcon)
794 /*************************************************************************
795 * Printer_LoadIconsW [SHELL32.205]
797 VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
799 INT iconindex=IDI_SHELL_PRINTER;
801 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);
803 /* We should check if wsPrinterName is
804 1. the Default Printer or not
806 3. a Local Printer or a Network-Printer
807 and use different Icons
809 if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
811 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
814 if(pLargeIcon != NULL)
815 *pLargeIcon = LoadImageW(shell32_hInstance,
816 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
817 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
819 if(pSmallIcon != NULL)
820 *pSmallIcon = LoadImageW(shell32_hInstance,
821 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
822 16, 16, LR_DEFAULTCOLOR);
825 /*************************************************************************
826 * Printers_RegisterWindowW [SHELL32.213]
827 * used by "printui.dll":
828 * find the Window of the given Type for the specific Printer and
829 * return the already existent hwnd or open a new window
831 BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType,
832 HANDLE * phClassPidl, HWND * phwnd)
834 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType,
835 phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL,
836 phwnd, (phwnd != NULL) ? *(phwnd) : NULL);
841 /*************************************************************************
842 * Printers_UnregisterWindow [SHELL32.214]
844 VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd)
846 FIXME("(%p, %p) stub!\n", hClassPidl, hwnd);
849 /*************************************************************************/
854 LPCWSTR szOtherStuff;
859 #define IDC_STATIC_TEXT1 100
860 #define IDC_STATIC_TEXT2 101
861 #define IDC_LISTBOX 99
862 #define IDC_WINE_TEXT 98
864 #define DROP_FIELD_TOP (-15)
865 #define DROP_FIELD_HEIGHT 15
867 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
869 HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
873 GetWindowRect( hWndCtl, lprect );
874 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
875 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
881 /*************************************************************************
882 * SHAppBarMessage [SHELL32.@]
884 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
886 int width=data->rc.right - data->rc.left;
887 int height=data->rc.bottom - data->rc.top;
893 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
894 case ABM_GETTASKBARPOS:
895 GetWindowRect(data->hWnd, &rec);
899 SetActiveWindow(data->hWnd);
901 case ABM_GETAUTOHIDEBAR:
902 data->hWnd=GetActiveWindow();
905 /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */
906 SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
909 GetWindowRect(data->hWnd, &(data->rc));
912 FIXME("ABM_REMOVE broken\n");
913 /* FIXME: this is wrong; should it be DestroyWindow instead? */
914 /*CloseHandle(data->hWnd);*/
916 case ABM_SETAUTOHIDEBAR:
917 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
918 width,height,SWP_SHOWWINDOW);
921 data->uEdge=(ABE_RIGHT | ABE_LEFT);
922 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
923 width,height,SWP_SHOWWINDOW);
925 case ABM_WINDOWPOSCHANGED:
931 /*************************************************************************
932 * SHHelpShortcuts_RunDLLA [SHELL32.@]
935 DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
937 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
941 /*************************************************************************
942 * SHHelpShortcuts_RunDLLA [SHELL32.@]
945 DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
947 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
951 /*************************************************************************
952 * SHLoadInProc [SHELL32.@]
953 * Create an instance of specified object class from within
954 * the shell process and release it immediately
956 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
960 TRACE("%s\n", debugstr_guid(rclsid));
962 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
965 IUnknown * pUnk = ptr;
966 IUnknown_Release(pUnk);
969 return DISP_E_MEMBERNOTFOUND;
972 /*************************************************************************
973 * AboutDlgProc (internal)
975 INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
986 ABOUT_INFO *info = (ABOUT_INFO *)lParam;
987 WCHAR Template[512], AppTitle[512];
991 const char* const *pstr = SHELL_Authors;
992 SendDlgItemMessageW(hWnd, stc1, STM_SETICON,(WPARAM)info->hIcon, 0);
993 GetWindowTextW( hWnd, Template, sizeof(Template)/sizeof(WCHAR) );
994 sprintfW( AppTitle, Template, info->szApp );
995 SetWindowTextW( hWnd, AppTitle );
996 SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT1), info->szApp );
997 SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT2), info->szOtherStuff );
998 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
999 SendMessageW( hWndCtl, WM_SETREDRAW, 0, 0 );
1000 SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)info->hFont, 0 );
1004 /* authors list is in utf-8 format */
1005 MultiByteToWideChar( CP_UTF8, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) );
1006 SendMessageW( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name );
1009 SendMessageW( hWndCtl, WM_SETREDRAW, 1, 0 );
1018 HDC hDC = BeginPaint( hWnd, &ps );
1020 if (__get_dropline( hWnd, &rect ))
1022 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
1023 MoveToEx( hDC, rect.left, rect.top, NULL );
1024 LineTo( hDC, rect.right, rect.bottom );
1026 EndPaint( hWnd, &ps );
1031 if (wParam == IDOK || wParam == IDCANCEL)
1033 EndDialog(hWnd, TRUE);
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,
1087 static const WCHAR wszSHELL_ABOUT_MSGBOX[] =
1088 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1092 if(!(hRes = FindResourceW(shell32_hInstance, wszSHELL_ABOUT_MSGBOX, (LPWSTR)RT_DIALOG)))
1094 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
1097 info.szOtherStuff = szOtherStuff;
1098 info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
1100 SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
1101 info.hFont = CreateFontIndirectW( &logFont );
1103 bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
1104 template, hWnd, AboutDlgProc, (LPARAM)&info );
1105 DeleteObject(info.hFont);
1109 /*************************************************************************
1110 * FreeIconList (SHELL32.@)
1112 void WINAPI FreeIconList( DWORD dw )
1114 FIXME("%x: stub\n",dw);
1117 /*************************************************************************
1118 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1120 HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID )
1126 /***********************************************************************
1127 * DllGetVersion [SHELL32.@]
1129 * Retrieves version information of the 'SHELL32.DLL'
1132 * pdvi [O] pointer to version information structure.
1136 * Failure: E_INVALIDARG
1139 * Returns version of a shell32.dll from IE4.01 SP1.
1142 HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
1144 /* FIXME: shouldn't these values come from the version resource? */
1145 if (pdvi->cbSize == sizeof(DLLVERSIONINFO) ||
1146 pdvi->cbSize == sizeof(DLLVERSIONINFO2))
1148 pdvi->dwMajorVersion = WINE_FILEVERSION_MAJOR;
1149 pdvi->dwMinorVersion = WINE_FILEVERSION_MINOR;
1150 pdvi->dwBuildNumber = WINE_FILEVERSION_BUILD;
1151 pdvi->dwPlatformID = WINE_FILEVERSION_PLATFORMID;
1152 if (pdvi->cbSize == sizeof(DLLVERSIONINFO2))
1154 DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi;
1157 pdvi2->ullVersion = MAKEDLLVERULL(WINE_FILEVERSION_MAJOR,
1158 WINE_FILEVERSION_MINOR,
1159 WINE_FILEVERSION_BUILD,
1160 WINE_FILEVERSION_PLATFORMID);
1162 TRACE("%u.%u.%u.%u\n",
1163 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
1164 pdvi->dwBuildNumber, pdvi->dwPlatformID);
1169 WARN("wrong DLLVERSIONINFO size from app\n");
1170 return E_INVALIDARG;
1174 /*************************************************************************
1175 * global variables of the shell32.dll
1176 * all are once per process
1179 HINSTANCE shell32_hInstance = 0;
1180 HIMAGELIST ShellSmallIconList = 0;
1181 HIMAGELIST ShellBigIconList = 0;
1184 /*************************************************************************
1188 * calling oleinitialize here breaks sone apps.
1190 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
1192 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
1196 case DLL_PROCESS_ATTACH:
1197 shell32_hInstance = hinstDLL;
1198 DisableThreadLibraryCalls(shell32_hInstance);
1200 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1201 GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH);
1202 swShell32Name[MAX_PATH - 1] = '\0';
1204 InitCommonControlsEx(NULL);
1207 InitChangeNotifications();
1210 case DLL_PROCESS_DETACH:
1211 shell32_hInstance = 0;
1213 FreeChangeNotifications();
1219 /*************************************************************************
1220 * DllInstall [SHELL32.@]
1224 * BOOL bInstall - TRUE for install, FALSE for uninstall
1225 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1228 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
1230 FIXME("%s %s: stub\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1231 return S_OK; /* indicate success */
1234 /***********************************************************************
1235 * DllCanUnloadNow (SHELL32.@)
1237 HRESULT WINAPI DllCanUnloadNow(void)
1243 /***********************************************************************
1244 * SHPathPrepareForWriteA (SHELL32.@)
1246 HRESULT WINAPI SHPathPrepareForWriteA(HWND hwnd, IUnknown *modless, LPCSTR path, DWORD flags)
1248 FIXME("%p %p %s 0x%08x\n", hwnd, modless, debugstr_a(path), flags);
1252 /***********************************************************************
1253 * SHPathPrepareForWriteA (SHELL32.@)
1255 HRESULT WINAPI SHPathPrepareForWriteW(HWND hwnd, IUnknown *modless, LPCWSTR path, DWORD flags)
1257 FIXME("%p %p %s 0x%08x\n", hwnd, modless, debugstr_w(path), flags);