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 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI)
280 return IMAGE_NT_SIGNATURE |
281 (nt.OptionalHeader.MajorSubsystemVersion << 24) |
282 (nt.OptionalHeader.MinorSubsystemVersion << 16);
284 return IMAGE_NT_SIGNATURE;
286 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
289 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
290 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
291 CloseHandle( hfile );
292 if (ne.ne_exetyp == 2)
293 return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16);
296 CloseHandle( hfile );
300 /*************************************************************************
301 * SHELL_IsShortcut [internal]
303 * Decide if an item id list points to a shell shortcut
305 BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast)
307 char szTemp[MAX_PATH];
311 if (_ILGetExtension(pidlLast, szTemp, MAX_PATH) &&
312 HCR_MapTypeToValueA(szTemp, szTemp, MAX_PATH, TRUE))
314 if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_QUERY_VALUE, &keyCls))
316 if (ERROR_SUCCESS == RegQueryValueExA(keyCls, "IsShortcut", NULL, NULL, NULL, NULL))
326 #define SHGFI_KNOWN_FLAGS \
327 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
328 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
329 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
330 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
331 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
333 /*************************************************************************
334 * SHGetFileInfoW [SHELL32.@]
337 DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
338 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
340 WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
342 DWORD_PTR ret = TRUE;
343 DWORD dwAttributes = 0;
344 IShellFolder * psfParent = NULL;
345 IExtractIconW * pei = NULL;
346 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
348 BOOL IconNotYetLoaded=TRUE;
351 TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n",
352 (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
353 psfi, psfi->dwAttributes, sizeofpsfi, flags);
355 if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
356 (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
359 if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
360 (flags & (SHGFI_ICONLOCATION | SHGFI_ICON | SHGFI_SYSICONINDEX)) )
362 FIXME("This combination of flags is not supported yet\n");
363 /* And it would cause a crash, so return false instead */
367 /* windows initializes these values regardless of the flags */
370 psfi->szDisplayName[0] = '\0';
371 psfi->szTypeName[0] = '\0';
375 if (!(flags & SHGFI_PIDL))
377 /* SHGetFileInfo should work with absolute and relative paths */
378 if (PathIsRelativeW(path))
380 GetCurrentDirectoryW(MAX_PATH, szLocation);
381 PathCombineW(szFullPath, szLocation, path);
385 lstrcpynW(szFullPath, path, MAX_PATH);
389 if (flags & SHGFI_EXETYPE)
391 if (flags != SHGFI_EXETYPE)
393 return shgfi_get_exe_type(szFullPath);
397 * psfi is NULL normally to query EXE type. If it is NULL, none of the
398 * below makes sense anyway. Windows allows this and just returns FALSE
404 * translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
406 * The pidl functions fail on not existing file names
409 if (flags & SHGFI_PIDL)
411 pidl = ILClone((LPCITEMIDLIST)path);
413 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
415 hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
418 if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
420 /* get the parent shellfolder */
423 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent,
424 (LPCITEMIDLIST*)&pidlLast );
426 pidlLast = ILClone(pidlLast);
431 ERR("pidl is null!\n");
436 /* get the attributes of the child */
437 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
439 if (!(flags & SHGFI_ATTR_SPECIFIED))
441 psfi->dwAttributes = 0xffffffff;
443 IShellFolder_GetAttributesOf( psfParent, 1, (LPCITEMIDLIST*)&pidlLast,
444 &(psfi->dwAttributes) );
447 /* get the displayname */
448 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
450 if (flags & SHGFI_USEFILEATTRIBUTES)
452 lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
457 hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast,
458 SHGDN_INFOLDER, &str);
459 StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
463 /* get the type name */
464 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
466 static const WCHAR szFile[] = { 'F','i','l','e',0 };
467 static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
469 if (!(flags & SHGFI_USEFILEATTRIBUTES))
473 _ILGetFileType(pidlLast, ftype, 80);
474 MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
478 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
479 strcatW (psfi->szTypeName, szFile);
484 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
485 if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) &&
486 HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
488 lstrcpynW (psfi->szTypeName, sTemp, 64);
489 strcatW (psfi->szTypeName, szDashFile);
496 if (flags & SHGFI_OPENICON)
497 uGilFlags |= GIL_OPENICON;
499 if (flags & SHGFI_LINKOVERLAY)
500 uGilFlags |= GIL_FORSHORTCUT;
501 else if ((flags&SHGFI_ADDOVERLAYS) ||
502 (flags&(SHGFI_ICON|SHGFI_SMALLICON))==SHGFI_ICON)
504 if (SHELL_IsShortcut(pidlLast))
505 uGilFlags |= GIL_FORSHORTCUT;
508 if (flags & SHGFI_OVERLAYINDEX)
509 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
511 if (flags & SHGFI_SELECTED)
512 FIXME("set icon to selected, stub\n");
514 if (flags & SHGFI_SHELLICONSIZE)
515 FIXME("set icon to shell size, stub\n");
517 /* get the iconlocation */
518 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
522 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1,
523 (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconW,
524 &uDummy, (LPVOID*)&pei);
527 hr = IExtractIconW_GetIconLocation(pei, uGilFlags,
528 szLocation, MAX_PATH, &iIndex, &uFlags);
529 psfi->iIcon = iIndex;
531 if (!(uFlags & GIL_NOTFILENAME))
532 lstrcpyW (psfi->szDisplayName, szLocation);
536 IExtractIconW_Release(pei);
540 /* get icon index (or load icon)*/
541 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
543 if (flags & SHGFI_USEFILEATTRIBUTES)
545 WCHAR sTemp [MAX_PATH];
549 lstrcpynW(sTemp, szFullPath, MAX_PATH);
551 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
552 psfi->iIcon = SIC_GetIconIndex(swShell32Name, -IDI_SHELL_FOLDER, 0);
555 static const WCHAR p1W[] = {'%','1',0};
558 szExt = (LPWSTR) PathFindExtensionW(sTemp);
560 HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
561 HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &icon_idx))
563 if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
564 strcpyW(sTemp, szFullPath);
566 if (flags & SHGFI_SYSICONINDEX)
568 psfi->iIcon = SIC_GetIconIndex(sTemp,icon_idx,0);
569 if (psfi->iIcon == -1)
574 IconNotYetLoaded=FALSE;
575 if (flags & SHGFI_SMALLICON)
576 PrivateExtractIconsW( sTemp,icon_idx,
577 GetSystemMetrics( SM_CXSMICON ),
578 GetSystemMetrics( SM_CYSMICON ),
579 &psfi->hIcon, 0, 1, 0);
581 PrivateExtractIconsW( sTemp, icon_idx,
582 GetSystemMetrics( SM_CXICON),
583 GetSystemMetrics( SM_CYICON),
584 &psfi->hIcon, 0, 1, 0);
585 psfi->iIcon = icon_idx;
592 if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
593 uGilFlags, &(psfi->iIcon))))
600 if (flags & SHGFI_SMALLICON)
601 ret = (DWORD_PTR) ShellSmallIconList;
603 ret = (DWORD_PTR) ShellBigIconList;
608 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
610 if (flags & SHGFI_SMALLICON)
611 psfi->hIcon = ImageList_GetIcon( ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
613 psfi->hIcon = ImageList_GetIcon( ShellBigIconList, psfi->iIcon, ILD_NORMAL);
616 if (flags & ~SHGFI_KNOWN_FLAGS)
617 FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
620 IShellFolder_Release(psfParent);
628 TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n",
629 psfi->hIcon, psfi->iIcon, psfi->dwAttributes,
630 debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
636 /*************************************************************************
637 * SHGetFileInfoA [SHELL32.@]
639 DWORD_PTR WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
640 SHFILEINFOA *psfi, UINT sizeofpsfi,
644 LPWSTR temppath = NULL;
647 SHFILEINFOW temppsfi;
649 if (flags & SHGFI_PIDL)
651 /* path contains a pidl */
652 pathW = (LPCWSTR)path;
656 len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
657 temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
658 MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
662 if (psfi && (flags & SHGFI_ATTR_SPECIFIED))
663 temppsfi.dwAttributes=psfi->dwAttributes;
666 ret = SHGetFileInfoW(pathW, dwFileAttributes, NULL, sizeof(temppsfi), flags);
668 ret = SHGetFileInfoW(pathW, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
672 if(flags & SHGFI_ICON)
673 psfi->hIcon=temppsfi.hIcon;
674 if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
675 psfi->iIcon=temppsfi.iIcon;
676 if(flags & SHGFI_ATTRIBUTES)
677 psfi->dwAttributes=temppsfi.dwAttributes;
678 if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
680 WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1,
681 psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
683 if(flags & SHGFI_TYPENAME)
685 WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1,
686 psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
690 HeapFree(GetProcessHeap(), 0, temppath);
695 /*************************************************************************
696 * DuplicateIcon [SHELL32.@]
698 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
703 TRACE("%p %p\n", hInstance, hIcon);
705 if (GetIconInfo(hIcon, &IconInfo))
707 hDupIcon = CreateIconIndirect(&IconInfo);
709 /* clean up hbmMask and hbmColor */
710 DeleteObject(IconInfo.hbmMask);
711 DeleteObject(IconInfo.hbmColor);
717 /*************************************************************************
718 * ExtractIconA [SHELL32.@]
720 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
723 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
724 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
726 TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
728 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
729 ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
730 HeapFree(GetProcessHeap(), 0, lpwstrFile);
735 /*************************************************************************
736 * ExtractIconW [SHELL32.@]
738 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
742 UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
744 TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
746 if (nIconIndex == 0xFFFFFFFF)
748 ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
749 if (ret != 0xFFFFFFFF && ret)
750 return (HICON)(UINT_PTR)ret;
754 ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
756 if (ret == 0xFFFFFFFF)
758 else if (ret > 0 && hIcon)
764 /*************************************************************************
765 * Printer_LoadIconsW [SHELL32.205]
767 VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
769 INT iconindex=IDI_SHELL_PRINTER;
771 TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);
773 /* We should check if wsPrinterName is
774 1. the Default Printer or not
776 3. a Local Printer or a Network-Printer
777 and use different Icons
779 if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
781 FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
784 if(pLargeIcon != NULL)
785 *pLargeIcon = LoadImageW(shell32_hInstance,
786 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
787 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);
789 if(pSmallIcon != NULL)
790 *pSmallIcon = LoadImageW(shell32_hInstance,
791 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
792 16, 16, LR_DEFAULTCOLOR);
795 /*************************************************************************
796 * Printers_RegisterWindowW [SHELL32.213]
797 * used by "printui.dll":
798 * find the Window of the given Type for the specific Printer and
799 * return the already existent hwnd or open a new window
801 BOOL WINAPI Printers_RegisterWindowW(LPCWSTR wsPrinter, DWORD dwType,
802 HANDLE * phClassPidl, HWND * phwnd)
804 FIXME("(%s, %x, %p (%p), %p (%p)) stub!\n", debugstr_w(wsPrinter), dwType,
805 phClassPidl, (phClassPidl != NULL) ? *(phClassPidl) : NULL,
806 phwnd, (phwnd != NULL) ? *(phwnd) : NULL);
811 /*************************************************************************
812 * Printers_UnregisterWindow [SHELL32.214]
814 VOID WINAPI Printers_UnregisterWindow(HANDLE hClassPidl, HWND hwnd)
816 FIXME("(%p, %p) stub!\n", hClassPidl, hwnd);
819 /*************************************************************************/
824 LPCWSTR szOtherStuff;
829 #define IDC_STATIC_TEXT1 100
830 #define IDC_STATIC_TEXT2 101
831 #define IDC_LISTBOX 99
832 #define IDC_WINE_TEXT 98
834 #define DROP_FIELD_TOP (-15)
835 #define DROP_FIELD_HEIGHT 15
837 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
839 HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
843 GetWindowRect( hWndCtl, lprect );
844 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
845 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
851 /*************************************************************************
852 * SHAppBarMessage [SHELL32.@]
854 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
856 int width=data->rc.right - data->rc.left;
857 int height=data->rc.bottom - data->rc.top;
863 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
864 case ABM_GETTASKBARPOS:
865 GetWindowRect(data->hWnd, &rec);
869 SetActiveWindow(data->hWnd);
871 case ABM_GETAUTOHIDEBAR:
872 data->hWnd=GetActiveWindow();
875 /* cbSize, hWnd, and uCallbackMessage are used. All other ignored */
876 SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
879 GetWindowRect(data->hWnd, &(data->rc));
882 FIXME("ABM_REMOVE broken\n");
883 /* FIXME: this is wrong; should it be DestroyWindow instead? */
884 /*CloseHandle(data->hWnd);*/
886 case ABM_SETAUTOHIDEBAR:
887 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
888 width,height,SWP_SHOWWINDOW);
891 data->uEdge=(ABE_RIGHT | ABE_LEFT);
892 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
893 width,height,SWP_SHOWWINDOW);
895 case ABM_WINDOWPOSCHANGED:
901 /*************************************************************************
902 * SHHelpShortcuts_RunDLLA [SHELL32.@]
905 DWORD WINAPI SHHelpShortcuts_RunDLLA(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
907 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
911 /*************************************************************************
912 * SHHelpShortcuts_RunDLLA [SHELL32.@]
915 DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
917 FIXME("(%x, %x, %x, %x) stub!\n", dwArg1, dwArg2, dwArg3, dwArg4);
921 /*************************************************************************
922 * SHLoadInProc [SHELL32.@]
923 * Create an instance of specified object class from within
924 * the shell process and release it immediately
926 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
930 TRACE("%s\n", debugstr_guid(rclsid));
932 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
935 IUnknown * pUnk = ptr;
936 IUnknown_Release(pUnk);
939 return DISP_E_MEMBERNOTFOUND;
942 /*************************************************************************
943 * AboutDlgProc (internal)
945 INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
956 ABOUT_INFO *info = (ABOUT_INFO *)lParam;
957 WCHAR Template[512], AppTitle[512];
961 const char* const *pstr = SHELL_Authors;
962 SendDlgItemMessageW(hWnd, stc1, STM_SETICON,(WPARAM)info->hIcon, 0);
963 GetWindowTextW( hWnd, Template, sizeof(Template)/sizeof(WCHAR) );
964 sprintfW( AppTitle, Template, info->szApp );
965 SetWindowTextW( hWnd, AppTitle );
966 SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT1), info->szApp );
967 SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT2), info->szOtherStuff );
968 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
969 SendMessageW( hWndCtl, WM_SETREDRAW, 0, 0 );
970 SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)info->hFont, 0 );
974 /* authors list is in utf-8 format */
975 MultiByteToWideChar( CP_UTF8, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) );
976 SendMessageW( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name );
979 SendMessageW( hWndCtl, WM_SETREDRAW, 1, 0 );
988 HDC hDC = BeginPaint( hWnd, &ps );
990 if (__get_dropline( hWnd, &rect ))
992 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
993 MoveToEx( hDC, rect.left, rect.top, NULL );
994 LineTo( hDC, rect.right, rect.bottom );
996 EndPaint( hWnd, &ps );
1001 if (wParam == IDOK || wParam == IDCANCEL)
1003 EndDialog(hWnd, TRUE);
1008 EndDialog(hWnd, TRUE);
1016 /*************************************************************************
1017 * ShellAboutA [SHELL32.288]
1019 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon )
1022 LPWSTR appW = NULL, otherW = NULL;
1027 len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0);
1028 appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1029 MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len);
1033 len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0);
1034 otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1035 MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len);
1038 ret = ShellAboutW(hWnd, appW, otherW, hIcon);
1040 HeapFree(GetProcessHeap(), 0, otherW);
1041 HeapFree(GetProcessHeap(), 0, appW);
1046 /*************************************************************************
1047 * ShellAboutW [SHELL32.289]
1049 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
1057 static const WCHAR wszSHELL_ABOUT_MSGBOX[] =
1058 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
1062 if(!(hRes = FindResourceW(shell32_hInstance, wszSHELL_ABOUT_MSGBOX, (LPWSTR)RT_DIALOG)))
1064 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
1067 info.szOtherStuff = szOtherStuff;
1068 info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
1070 SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
1071 info.hFont = CreateFontIndirectW( &logFont );
1073 bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
1074 template, hWnd, AboutDlgProc, (LPARAM)&info );
1075 DeleteObject(info.hFont);
1079 /*************************************************************************
1080 * FreeIconList (SHELL32.@)
1082 void WINAPI FreeIconList( DWORD dw )
1084 FIXME("%x: stub\n",dw);
1087 /*************************************************************************
1088 * SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
1090 HRESULT SHLoadNonloadedIconOverlayIdentifiers( VOID )
1096 /***********************************************************************
1097 * DllGetVersion [SHELL32.@]
1099 * Retrieves version information of the 'SHELL32.DLL'
1102 * pdvi [O] pointer to version information structure.
1106 * Failure: E_INVALIDARG
1109 * Returns version of a shell32.dll from IE4.01 SP1.
1112 HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
1114 /* FIXME: shouldn't these values come from the version resource? */
1115 if (pdvi->cbSize == sizeof(DLLVERSIONINFO) ||
1116 pdvi->cbSize == sizeof(DLLVERSIONINFO2))
1118 pdvi->dwMajorVersion = WINE_FILEVERSION_MAJOR;
1119 pdvi->dwMinorVersion = WINE_FILEVERSION_MINOR;
1120 pdvi->dwBuildNumber = WINE_FILEVERSION_BUILD;
1121 pdvi->dwPlatformID = WINE_FILEVERSION_PLATFORMID;
1122 if (pdvi->cbSize == sizeof(DLLVERSIONINFO2))
1124 DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi;
1127 pdvi2->ullVersion = MAKEDLLVERULL(WINE_FILEVERSION_MAJOR,
1128 WINE_FILEVERSION_MINOR,
1129 WINE_FILEVERSION_BUILD,
1130 WINE_FILEVERSION_PLATFORMID);
1132 TRACE("%u.%u.%u.%u\n",
1133 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
1134 pdvi->dwBuildNumber, pdvi->dwPlatformID);
1139 WARN("wrong DLLVERSIONINFO size from app\n");
1140 return E_INVALIDARG;
1144 /*************************************************************************
1145 * global variables of the shell32.dll
1146 * all are once per process
1149 HINSTANCE shell32_hInstance = 0;
1150 HIMAGELIST ShellSmallIconList = 0;
1151 HIMAGELIST ShellBigIconList = 0;
1154 /*************************************************************************
1158 * calling oleinitialize here breaks sone apps.
1160 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
1162 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
1166 case DLL_PROCESS_ATTACH:
1167 shell32_hInstance = hinstDLL;
1168 DisableThreadLibraryCalls(shell32_hInstance);
1170 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
1171 GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH);
1172 swShell32Name[MAX_PATH - 1] = '\0';
1174 InitCommonControlsEx(NULL);
1177 InitChangeNotifications();
1180 case DLL_PROCESS_DETACH:
1181 shell32_hInstance = 0;
1183 FreeChangeNotifications();
1189 /*************************************************************************
1190 * DllInstall [SHELL32.@]
1194 * BOOL bInstall - TRUE for install, FALSE for uninstall
1195 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1198 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
1200 FIXME("%s %s: stub\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1201 return S_OK; /* indicate success */
1204 /***********************************************************************
1205 * DllCanUnloadNow (SHELL32.@)
1207 HRESULT WINAPI DllCanUnloadNow(void)