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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43 #include "undocshell.h"
45 #include "shell32_main.h"
48 #include "wine/debug.h"
49 #include "wine/unicode.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(shell);
53 extern const char * const SHELL_Authors[];
56 /*************************************************************************
57 * CommandLineToArgvW [SHELL32.@]
59 * We must interpret the quotes in the command line to rebuild the argv
61 * - arguments are separated by spaces or tabs
62 * - quotes serve as optional argument delimiters
64 * - escaped quotes must be converted back to '"'
66 * - an odd number of '\'s followed by '"' correspond to half that number
67 * of '\' followed by a '"' (extension of the above)
70 * - an even number of '\'s followed by a '"' correspond to half that number
71 * of '\', plus a regular quote serving as an argument delimiter (which
72 * means it does not appear in the result)
73 * 'a\\"b c"' -> 'a\b c'
74 * 'a\\\\"b c"' -> 'a\\b c'
75 * - '\' that are not followed by a '"' are copied literally
85 LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
96 /* Return the path to the executable */
99 hargv=GlobalAlloc(size, 0);
100 argv=GlobalLock(hargv);
102 len = GetModuleFileNameW(0, (LPWSTR)(argv+1), size-sizeof(LPWSTR));
107 if (len < size) break;
109 hargv=GlobalReAlloc(hargv, size, 0);
110 argv=GlobalLock(hargv);
112 argv[0]=(LPWSTR)(argv+1);
119 /* to get a writeable copy */
125 if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) {
128 /* skip the remaining spaces */
129 while (*cs==0x0009 || *cs==0x0020) {
136 } else if (*cs==0x005c) {
137 /* '\', count them */
139 } else if ((*cs==0x0022) && ((bcount & 1)==0)) {
141 in_quotes=!in_quotes;
144 /* a regular character */
149 /* Allocate in a single lump, the string array, and the strings that go with it.
150 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
152 hargv=GlobalAlloc(0, argc*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
153 argv=GlobalLock(hargv);
156 cmdline=(LPWSTR)(argv+argc);
157 strcpyW(cmdline, lpCmdline);
164 if ((*s==0x0009 || *s==0x0020) && !in_quotes) {
165 /* Close the argument and copy it */
169 /* skip the remaining spaces */
172 } while (*s==0x0009 || *s==0x0020);
174 /* Start with a new argument */
177 } else if (*s==0x005c) {
181 } else if (*s==0x0022) {
183 if ((bcount & 1)==0) {
184 /* Preceeded by an even number of '\', this is half that
185 * number of '\', plus a quote which we erase.
188 in_quotes=!in_quotes;
191 /* Preceeded by an odd number of '\', this is half that
192 * number of '\' followed by a '"'
200 /* a regular character */
215 #define SHGFI_KNOWN_FLAGS \
216 (SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
217 SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
218 SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
219 SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
220 SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
222 /*************************************************************************
223 * SHGetFileInfoW [SHELL32.@]
227 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
228 SHFILEINFOW *psfi, UINT sizeofpsfi,
231 WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
233 DWORD ret = TRUE, dwAttributes = 0;
234 IShellFolder * psfParent = NULL;
235 IExtractIconW * pei = NULL;
236 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
238 BOOL IconNotYetLoaded=TRUE;
240 TRACE("%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x\n",
241 (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
242 psfi, psfi->dwAttributes, sizeofpsfi, flags);
244 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
247 /* windows initializes this values regardless of the flags */
249 psfi->szDisplayName[0] = '\0';
250 psfi->szTypeName[0] = '\0';
254 if (!(flags & SHGFI_PIDL)){
255 /* SHGitFileInfo should work with absolute and relative paths */
256 if (PathIsRelativeW(path)){
257 GetCurrentDirectoryW(MAX_PATH, szLocation);
258 PathCombineW(szFullPath, szLocation, path);
260 lstrcpynW(szFullPath, path, MAX_PATH);
264 if (flags & SHGFI_EXETYPE) {
268 IMAGE_DOS_HEADER mz_header;
273 if (flags != SHGFI_EXETYPE) return 0;
275 status = GetBinaryTypeW (szFullPath, &BinaryType);
276 if (!status) return 0;
277 if ((BinaryType == SCS_DOS_BINARY)
278 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
280 hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ,
281 NULL, OPEN_EXISTING, 0, 0 );
282 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
284 /* The next section is adapted from MODULE_GetBinaryType, as we need
285 * to examine the image header to get OS and version information. We
286 * know from calling GetBinaryTypeA that the image is valid and either
287 * an NE or PE, so much error handling can be omitted.
288 * Seek to the start of the file and read the header information.
291 SetFilePointer( hfile, 0, NULL, SEEK_SET );
292 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
294 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
295 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
296 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
298 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
299 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
300 CloseHandle( hfile );
301 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
302 return IMAGE_NT_SIGNATURE
303 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
304 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
306 return IMAGE_NT_SIGNATURE;
308 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
311 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
312 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
313 CloseHandle( hfile );
314 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
315 | (ne.ne_expver << 16);
318 CloseHandle( hfile );
322 /* psfi is NULL normally to query EXE type. If it is NULL, none of the
323 * below makes sense anyway. Windows allows this and just returns FALSE */
324 if (psfi == NULL) return FALSE;
326 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
328 The pidl functions fail on not existing file names */
330 if (flags & SHGFI_PIDL) {
331 pidl = ILClone((LPCITEMIDLIST)path);
332 } else if (!(flags & SHGFI_USEFILEATTRIBUTES)) {
333 hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes);
336 if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES))
338 /* get the parent shellfolder */
340 hr = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&pidlLast);
343 ERR("pidl is null!\n");
348 /* get the attributes of the child */
349 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
351 if (!(flags & SHGFI_ATTR_SPECIFIED))
353 psfi->dwAttributes = 0xffffffff;
355 IShellFolder_GetAttributesOf(psfParent, 1, (LPCITEMIDLIST*)&pidlLast, &(psfi->dwAttributes));
358 /* get the displayname */
359 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
361 if (flags & SHGFI_USEFILEATTRIBUTES)
363 lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath));
368 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
369 StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
373 /* get the type name */
374 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
376 static const WCHAR szFile[] = { 'F','i','l','e',0 };
377 static const WCHAR szDashFile[] = { '-','f','i','l','e',0 };
378 if (!(flags & SHGFI_USEFILEATTRIBUTES))
381 _ILGetFileType(pidlLast, ftype, 80);
382 MultiByteToWideChar(CP_ACP, 0, ftype, -1, psfi->szTypeName, 80 );
386 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
387 strcatW (psfi->szTypeName, szFile);
391 lstrcpyW(sTemp,PathFindExtensionW(szFullPath));
392 if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE)
393 && HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE )))
395 lstrcpynW (psfi->szTypeName, sTemp, 64);
396 strcatW (psfi->szTypeName, szDashFile);
403 if (flags & SHGFI_ADDOVERLAYS)
404 FIXME("SHGFI_ADDOVERLAYS unhandled\n");
406 if (flags & SHGFI_OVERLAYINDEX)
407 FIXME("SHGFI_OVERLAYINDEX unhandled\n");
409 if (flags & SHGFI_LINKOVERLAY)
410 FIXME("set icon to link, stub\n");
412 if (flags & SHGFI_SELECTED)
413 FIXME("set icon to selected, stub\n");
415 if (flags & SHGFI_SHELLICONSIZE)
416 FIXME("set icon to shell size, stub\n");
418 /* get the iconlocation */
419 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
422 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
426 hr = IExtractIconW_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLocation, MAX_PATH, &iIndex, &uFlags);
427 psfi->iIcon = iIndex;
429 if(uFlags != GIL_NOTFILENAME)
430 lstrcpyW (psfi->szDisplayName, szLocation);
434 IExtractIconA_Release(pei);
438 /* get icon index (or load icon)*/
439 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
441 if (flags & SHGFI_USEFILEATTRIBUTES)
443 WCHAR sTemp [MAX_PATH];
447 lstrcpynW(sTemp, szFullPath, MAX_PATH);
449 if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
453 static const WCHAR p1W[] = {'%','1',0};
455 szExt = (LPWSTR) PathFindExtensionW(sTemp);
456 if ( szExt && HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE)
457 && HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &dwNr))
459 if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
460 strcpyW(sTemp, szFullPath);
462 if (flags & SHGFI_SYSICONINDEX)
464 psfi->iIcon = SIC_GetIconIndex(sTemp,dwNr);
465 if (psfi->iIcon == -1) psfi->iIcon = 0;
469 IconNotYetLoaded=FALSE;
470 PrivateExtractIconsW(sTemp,dwNr,(flags & SHGFI_SMALLICON) ?
471 GetSystemMetrics(SM_CXSMICON) : GetSystemMetrics(SM_CXICON),
472 (flags & SHGFI_SMALLICON) ? GetSystemMetrics(SM_CYSMICON) :
473 GetSystemMetrics(SM_CYICON), &psfi->hIcon,0,1,0);
481 if (!(PidlToSicIndex(psfParent, pidlLast, !(flags & SHGFI_SMALLICON),
482 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
489 ret = (DWORD) ((flags & SHGFI_SMALLICON) ? ShellSmallIconList : ShellBigIconList);
494 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
495 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_SMALLICON) ? ShellSmallIconList:ShellBigIconList, psfi->iIcon, ILD_NORMAL);
497 if (flags & ~SHGFI_KNOWN_FLAGS)
498 FIXME("unknown flags %08x\n", flags & ~SHGFI_KNOWN_FLAGS);
501 IShellFolder_Release(psfParent);
506 if(pidlLast) SHFree(pidlLast);
508 TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
509 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret);
514 /*************************************************************************
515 * SHGetFileInfoA [SHELL32.@]
518 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
519 SHFILEINFOA *psfi, UINT sizeofpsfi,
525 SHFILEINFOW temppsfi;
527 if (flags & SHGFI_PIDL) {
528 /* path contains a pidl */
529 temppath = (LPWSTR) path;
531 len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
532 temppath = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
533 MultiByteToWideChar(CP_ACP, 0, path, -1, temppath, len);
536 if(psfi && (flags & SHGFI_ATTR_SPECIFIED))
537 temppsfi.dwAttributes=psfi->dwAttributes;
539 ret = SHGetFileInfoW(temppath, dwFileAttributes, (psfi == NULL)? NULL : &temppsfi, sizeof(temppsfi), flags);
543 if(flags & SHGFI_ICON)
544 psfi->hIcon=temppsfi.hIcon;
545 if(flags & (SHGFI_SYSICONINDEX|SHGFI_ICON|SHGFI_ICONLOCATION))
546 psfi->iIcon=temppsfi.iIcon;
547 if(flags & SHGFI_ATTRIBUTES)
548 psfi->dwAttributes=temppsfi.dwAttributes;
549 if(flags & (SHGFI_DISPLAYNAME|SHGFI_ICONLOCATION))
550 WideCharToMultiByte(CP_ACP, 0, temppsfi.szDisplayName, -1, psfi->szDisplayName, sizeof(psfi->szDisplayName), NULL, NULL);
551 if(flags & SHGFI_TYPENAME)
552 WideCharToMultiByte(CP_ACP, 0, temppsfi.szTypeName, -1, psfi->szTypeName, sizeof(psfi->szTypeName), NULL, NULL);
554 if(!(flags & SHGFI_PIDL)) HeapFree(GetProcessHeap(), 0, temppath);
558 /*************************************************************************
559 * DuplicateIcon [SHELL32.@]
561 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
566 TRACE("(%p, %p)\n", hInstance, hIcon);
568 if(GetIconInfo(hIcon, &IconInfo))
570 hDupIcon = CreateIconIndirect(&IconInfo);
572 /* clean up hbmMask and hbmColor */
573 DeleteObject(IconInfo.hbmMask);
574 DeleteObject(IconInfo.hbmColor);
580 /*************************************************************************
581 * ExtractIconA [SHELL32.@]
583 HICON WINAPI ExtractIconA(HINSTANCE hInstance, LPCSTR lpszFile, UINT nIconIndex)
586 INT len = MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, NULL, 0);
587 LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
589 TRACE("%p %s %d\n", hInstance, lpszFile, nIconIndex);
591 MultiByteToWideChar(CP_ACP, 0, lpszFile, -1, lpwstrFile, len);
592 ret = ExtractIconW(hInstance, lpwstrFile, nIconIndex);
593 HeapFree(GetProcessHeap(), 0, lpwstrFile);
597 /*************************************************************************
598 * ExtractIconW [SHELL32.@]
600 HICON WINAPI ExtractIconW(HINSTANCE hInstance, LPCWSTR lpszFile, UINT nIconIndex)
604 UINT cx = GetSystemMetrics(SM_CXICON), cy = GetSystemMetrics(SM_CYICON);
606 TRACE("%p %s %d\n", hInstance, debugstr_w(lpszFile), nIconIndex);
608 if (nIconIndex == 0xFFFFFFFF) {
609 ret = PrivateExtractIconsW(lpszFile, 0, cx, cy, NULL, NULL, 0, LR_DEFAULTCOLOR);
610 if (ret != 0xFFFFFFFF && ret)
615 ret = PrivateExtractIconsW(lpszFile, nIconIndex, cx, cy, &hIcon, NULL, 1, LR_DEFAULTCOLOR);
617 if (ret == 0xFFFFFFFF)
619 else if (ret > 0 && hIcon)
627 LPCWSTR szOtherStuff;
632 #define IDC_STATIC_TEXT1 100
633 #define IDC_STATIC_TEXT2 101
634 #define IDC_LISTBOX 99
635 #define IDC_WINE_TEXT 98
637 #define DROP_FIELD_TOP (-15)
638 #define DROP_FIELD_HEIGHT 15
640 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
641 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
643 { GetWindowRect( hWndCtl, lprect );
644 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
645 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
651 /*************************************************************************
652 * SHAppBarMessage [SHELL32.@]
654 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
656 int width=data->rc.right - data->rc.left;
657 int height=data->rc.bottom - data->rc.top;
661 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
662 case ABM_GETTASKBARPOS:
663 GetWindowRect(data->hWnd, &rec);
667 SetActiveWindow(data->hWnd);
669 case ABM_GETAUTOHIDEBAR:
670 data->hWnd=GetActiveWindow();
673 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
674 width,height,SWP_SHOWWINDOW);
677 GetWindowRect(data->hWnd, &(data->rc));
680 FIXME("ABM_REMOVE broken\n");
681 /* FIXME: this is wrong; should it be DestroyWindow instead? */
682 /*CloseHandle(data->hWnd);*/
684 case ABM_SETAUTOHIDEBAR:
685 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
686 width,height,SWP_SHOWWINDOW);
689 data->uEdge=(ABE_RIGHT | ABE_LEFT);
690 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
691 width,height,SWP_SHOWWINDOW);
693 case ABM_WINDOWPOSCHANGED:
699 /*************************************************************************
700 * SHHelpShortcuts_RunDLL [SHELL32.@]
703 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
704 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
705 dwArg1, dwArg2, dwArg3, dwArg4);
710 /*************************************************************************
711 * SHLoadInProc [SHELL32.@]
712 * Create an instance of specified object class from within
713 * the shell process and release it immediately
716 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
720 TRACE("%s\n", debugstr_guid(rclsid));
722 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
725 IUnknown * pUnk = ptr;
726 IUnknown_Release(pUnk);
729 return DISP_E_MEMBERNOTFOUND;
732 /*************************************************************************
733 * AboutDlgProc (internal)
735 INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
746 ABOUT_INFO *info = (ABOUT_INFO *)lParam;
747 WCHAR Template[512], AppTitle[512];
751 const char* const *pstr = SHELL_Authors;
752 SendDlgItemMessageW(hWnd, stc1, STM_SETICON,(WPARAM)info->hIcon, 0);
753 GetWindowTextW( hWnd, Template, sizeof(Template)/sizeof(WCHAR) );
754 sprintfW( AppTitle, Template, info->szApp );
755 SetWindowTextW( hWnd, AppTitle );
756 SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT1), info->szApp );
757 SetWindowTextW( GetDlgItem(hWnd, IDC_STATIC_TEXT2), info->szOtherStuff );
758 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
759 SendMessageW( hWndCtl, WM_SETREDRAW, 0, 0 );
760 SendMessageW( hWndCtl, WM_SETFONT, (WPARAM)info->hFont, 0 );
764 /* authors list is in iso-8859-1 format */
765 MultiByteToWideChar( 28591, 0, *pstr, -1, name, sizeof(name)/sizeof(WCHAR) );
766 SendMessageW( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)name );
769 SendMessageW( hWndCtl, WM_SETREDRAW, 1, 0 );
777 HDC hDC = BeginPaint( hWnd, &ps );
779 if( __get_dropline( hWnd, &rect ) ) {
780 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
781 MoveToEx( hDC, rect.left, rect.top, NULL );
782 LineTo( hDC, rect.right, rect.bottom );
784 EndPaint( hWnd, &ps );
789 if (wParam == IDOK || wParam == IDCANCEL)
791 EndDialog(hWnd, TRUE);
796 EndDialog(hWnd, TRUE);
804 /*************************************************************************
805 * ShellAboutA [SHELL32.288]
807 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon )
810 LPWSTR appW = NULL, otherW = NULL;
815 len = MultiByteToWideChar(CP_ACP, 0, szApp, -1, NULL, 0);
816 appW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
817 MultiByteToWideChar(CP_ACP, 0, szApp, -1, appW, len);
821 len = MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, NULL, 0);
822 otherW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
823 MultiByteToWideChar(CP_ACP, 0, szOtherStuff, -1, otherW, len);
826 ret = ShellAboutW(hWnd, appW, otherW, hIcon);
828 HeapFree(GetProcessHeap(), 0, otherW);
829 HeapFree(GetProcessHeap(), 0, appW);
834 /*************************************************************************
835 * ShellAboutW [SHELL32.289]
837 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
845 static const WCHAR wszSHELL_ABOUT_MSGBOX[] =
846 {'S','H','E','L','L','_','A','B','O','U','T','_','M','S','G','B','O','X',0};
850 if(!(hRes = FindResourceW(shell32_hInstance, wszSHELL_ABOUT_MSGBOX, (LPWSTR)RT_DIALOG)))
852 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
855 info.szOtherStuff = szOtherStuff;
856 info.hIcon = hIcon ? hIcon : LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
858 SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
859 info.hFont = CreateFontIndirectW( &logFont );
861 bRet = DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ),
862 template, hWnd, AboutDlgProc, (LPARAM)&info );
863 DeleteObject(info.hFont);
867 /*************************************************************************
868 * FreeIconList (SHELL32.@)
870 void WINAPI FreeIconList( DWORD dw )
871 { FIXME("(%lx): stub\n",dw);
875 /*************************************************************************
876 * ShellDDEInit (SHELL32.@)
878 void WINAPI ShellDDEInit(BOOL start)
880 FIXME("stub: %d\n", start);
883 /***********************************************************************
884 * DllGetVersion [SHELL32.@]
886 * Retrieves version information of the 'SHELL32.DLL'
889 * pdvi [O] pointer to version information structure.
893 * Failure: E_INVALIDARG
896 * Returns version of a shell32.dll from IE4.01 SP1.
899 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
901 /* FIXME: shouldn't these values come from the version resource? */
902 if (pdvi->cbSize == sizeof(DLLVERSIONINFO) ||
903 pdvi->cbSize == sizeof(DLLVERSIONINFO2))
905 pdvi->dwMajorVersion = WINE_FILEVERSION_MAJOR;
906 pdvi->dwMinorVersion = WINE_FILEVERSION_MINOR;
907 pdvi->dwBuildNumber = WINE_FILEVERSION_BUILD;
908 pdvi->dwPlatformID = WINE_FILEVERSION_PLATFORMID;
909 if (pdvi->cbSize == sizeof(DLLVERSIONINFO2))
911 DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi;
914 pdvi2->ullVersion = MAKEDLLVERULL(WINE_FILEVERSION_MAJOR,
915 WINE_FILEVERSION_MINOR,
916 WINE_FILEVERSION_BUILD,
917 WINE_FILEVERSION_PLATFORMID);
919 TRACE("%lu.%lu.%lu.%lu\n",
920 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
921 pdvi->dwBuildNumber, pdvi->dwPlatformID);
926 WARN("wrong DLLVERSIONINFO size from app\n");
930 /*************************************************************************
931 * global variables of the shell32.dll
932 * all are once per process
935 HINSTANCE shell32_hInstance = 0;
936 HIMAGELIST ShellSmallIconList = 0;
937 HIMAGELIST ShellBigIconList = 0;
940 /*************************************************************************
944 * calling oleinitialize here breaks sone apps.
947 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
949 TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
953 case DLL_PROCESS_ATTACH:
954 shell32_hInstance = hinstDLL;
955 DisableThreadLibraryCalls(shell32_hInstance);
957 /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
958 GetModuleFileNameW(hinstDLL, swShell32Name, MAX_PATH);
959 swShell32Name[MAX_PATH - 1] = '\0';
961 InitCommonControlsEx(NULL);
965 InitChangeNotifications();
968 case DLL_PROCESS_DETACH:
969 shell32_hInstance = 0;
971 FreeChangeNotifications();
977 /*************************************************************************
978 * DllInstall [SHELL32.@]
982 * BOOL bInstall - TRUE for install, FALSE for uninstall
983 * LPCWSTR pszCmdLine - command line (unused by shell32?)
986 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
988 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
990 return S_OK; /* indicate success */
993 /***********************************************************************
994 * DllCanUnloadNow (SHELL32.@)
996 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
998 FIXME("(void): stub\n");