5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
23 #include "undocshell.h"
24 #include "wine/winuser16.h"
28 #include "shell32_main.h"
30 #include "debugtools.h"
32 DEFAULT_DEBUG_CHANNEL(shell);
35 /*************************************************************************
36 * CommandLineToArgvW [SHELL32.@]
38 * We must interpret the quotes in the command line to rebuild the argv
40 * - arguments are separated by spaces or tabs
41 * - quotes serve as optional argument delimiters
43 * - escaped quotes must be converted back to '"'
45 * - an odd number of '\'s followed by '"' correspond to half that number
46 * of '\' followed by a '"' (extension of the above)
49 * - an even number of '\'s followed by a '"' correspond to half that number
50 * of '\', plus a regular quote serving as an argument delimiter (which
51 * means it does not appear in the result)
52 * 'a\\"b c"' -> 'a\b c'
53 * 'a\\\\"b c"' -> 'a\\b c'
54 * - '\' that are not followed by a '"' are copied literally
64 LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
75 /* Return the path to the executable */
82 hargv=GlobalReAlloc(hargv, size, 0);
83 argv=GlobalLock(hargv);
84 } while (GetModuleFileNameW((HMODULE)0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)) == 0);
85 argv[0]=(LPWSTR)(argv+1);
92 /* to get a writeable copy */
98 if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) {
101 /* skip the remaining spaces */
102 while (*cs==0x0009 || *cs==0x0020) {
109 } else if (*cs==0x005c) {
110 /* '\', count them */
112 } else if ((*cs==0x0022) && ((bcount & 1)==0)) {
114 in_quotes=!in_quotes;
117 /* a regular character */
122 /* Allocate in a single lump, the string array, and the strings that go with it.
123 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
125 hargv=GlobalAlloc(0, argc*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
126 argv=GlobalLock(hargv);
129 cmdline=(LPWSTR)(argv+argc);
130 strcpyW(cmdline, lpCmdline);
137 if ((*s==0x0009 || *s==0x0020) && !in_quotes) {
138 /* Close the argument and copy it */
142 /* skip the remaining spaces */
145 } while (*s==0x0009 || *s==0x0020);
147 /* Start with a new argument */
150 } else if (*s==0x005c) {
154 } else if (*s==0x0022) {
156 if ((bcount & 1)==0) {
157 /* Preceeded by an even number of '\', this is half that
158 * number of '\', plus a quote which we erase.
161 in_quotes=!in_quotes;
164 /* Preceeded by an odd number of '\', this is half that
165 * number of '\' followed by a '"'
173 /* a regular character */
188 /*************************************************************************
189 * SHGetFileInfoA [SHELL32.@]
193 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
194 SHFILEINFOA *psfi, UINT sizeofpsfi,
197 char szLoaction[MAX_PATH];
199 DWORD ret = TRUE, dwAttributes = 0;
200 IShellFolder * psfParent = NULL;
201 IExtractIconA * pei = NULL;
202 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
204 BOOL IconNotYetLoaded=TRUE;
206 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
207 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
209 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
212 /* windows initializes this values regardless of the flags */
213 psfi->szDisplayName[0] = '\0';
214 psfi->szTypeName[0] = '\0';
217 if (flags & SHGFI_EXETYPE) {
221 IMAGE_DOS_HEADER mz_header;
226 if (flags != SHGFI_EXETYPE) return 0;
228 status = GetBinaryTypeA (path, &BinaryType);
229 if (!status) return 0;
230 if ((BinaryType == SCS_DOS_BINARY)
231 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
233 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
234 NULL, OPEN_EXISTING, 0, 0 );
235 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
237 /* The next section is adapted from MODULE_GetBinaryType, as we need
238 * to examine the image header to get OS and version information. We
239 * know from calling GetBinaryTypeA that the image is valid and either
240 * an NE or PE, so much error handling can be omitted.
241 * Seek to the start of the file and read the header information.
244 SetFilePointer( hfile, 0, NULL, SEEK_SET );
245 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
247 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
248 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
249 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
251 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
252 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
253 CloseHandle( hfile );
254 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
255 return IMAGE_NT_SIGNATURE
256 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
257 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
259 return IMAGE_NT_SIGNATURE;
261 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
264 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
265 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
266 CloseHandle( hfile );
267 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
268 | (ne.ne_expver << 16);
271 CloseHandle( hfile );
276 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
277 the pidl functions fail on not existing file names */
278 if (flags & SHGFI_PIDL)
280 pidl = (LPCITEMIDLIST) path;
283 ERR("pidl is null!\n");
287 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
289 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
290 /* note: the attributes in ISF::ParseDisplayName are not implemented */
293 /* get the parent shellfolder */
296 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
299 /* get the attributes of the child */
300 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
302 if (!(flags & SHGFI_ATTR_SPECIFIED))
304 psfi->dwAttributes = 0xffffffff;
306 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
309 /* get the displayname */
310 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
312 if (flags & SHGFI_USEFILEATTRIBUTES)
314 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
319 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
320 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
324 /* get the type name */
325 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
327 if (!(flags & SHGFI_USEFILEATTRIBUTES))
328 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
332 strcpy(sTemp,PathFindExtensionA(path));
333 if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
334 && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
336 lstrcpynA (psfi->szTypeName, sTemp, 80 - 6);
337 strcat (psfi->szTypeName, "-file");
343 if (flags & SHGFI_LINKOVERLAY)
344 FIXME("set icon to link, stub\n");
346 if (flags & SHGFI_SELECTED)
347 FIXME("set icon to selected, stub\n");
349 if (flags & SHGFI_SHELLICONSIZE)
350 FIXME("set icon to shell size, stub\n");
352 /* get the iconlocation */
353 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
356 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
360 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
361 /* FIXME what to do with the index? */
363 if(uFlags != GIL_NOTFILENAME)
364 strcpy (psfi->szDisplayName, szLoaction);
368 IExtractIconA_Release(pei);
372 /* get icon index (or load icon)*/
373 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
376 if (flags & SHGFI_USEFILEATTRIBUTES)
378 char sTemp [MAX_PATH];
382 lstrcpynA(sTemp, path, MAX_PATH);
383 szExt = (LPSTR) PathFindExtensionA(sTemp);
384 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
385 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
387 if (!strcmp("%1",sTemp)) /* icon is in the file */
391 IconNotYetLoaded=FALSE;
394 PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXICON),
395 GetSystemMetrics(SM_CYICON),
398 PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXSMICON),
399 GetSystemMetrics(SM_CYSMICON),
402 else /* default icon */
409 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
410 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
417 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
422 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
423 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
425 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
426 FIXME("unknown attribute!\n");
429 IShellFolder_Release(psfParent);
434 if(pidlLast) SHFree(pidlLast);
436 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
437 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
442 /*************************************************************************
443 * SHGetFileInfoW [SHELL32.@]
446 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
447 SHFILEINFOW *psfi, UINT sizeofpsfi,
453 SHFILEINFOA temppsfi;
455 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
456 temppath = HeapAlloc(GetProcessHeap(), 0, len);
457 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
459 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
460 sizeof(temppsfi.szDisplayName), NULL, NULL);
461 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
462 sizeof(temppsfi.szTypeName), NULL, NULL);
464 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
466 HeapFree(GetProcessHeap(), 0, temppath);
471 /*************************************************************************
472 * SHGetFileInfo [SHELL32.@]
474 DWORD WINAPI SHGetFileInfoAW(
476 DWORD dwFileAttributes,
481 if(SHELL_OsIsUnicode())
482 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
483 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
486 /*************************************************************************
487 * DuplicateIcon [SHELL32.@]
489 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
494 TRACE("(%04x, %04x)\n", hInstance, hIcon);
496 if(GetIconInfo(hIcon, &IconInfo))
498 hDupIcon = CreateIconIndirect(&IconInfo);
500 /* clean up hbmMask and hbmColor */
501 DeleteObject(IconInfo.hbmMask);
502 DeleteObject(IconInfo.hbmColor);
509 /*************************************************************************
510 * ExtractIconA [SHELL32.@]
513 * if the filename is not a file return 1
515 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
517 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
521 HICON16* ptr = (HICON16*)GlobalLock16(handle);
522 HICON16 hIcon = *ptr;
524 GlobalFree16(handle);
530 /*************************************************************************
531 * ExtractIconW [SHELL32.@]
533 * FIXME: if the filename is not a file return 1
535 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
541 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
542 ret = ExtractIconA(hInstance,exefn,nIconIndex);
544 HeapFree(GetProcessHeap(),0,exefn);
554 #define IDC_STATIC_TEXT 100
555 #define IDC_LISTBOX 99
556 #define IDC_WINE_TEXT 98
558 #define DROP_FIELD_TOP (-15)
559 #define DROP_FIELD_HEIGHT 15
561 static HICON hIconTitleFont;
563 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
564 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
566 { GetWindowRect( hWndCtl, lprect );
567 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
568 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
574 /*************************************************************************
575 * SHAppBarMessage [SHELL32.@]
577 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
579 int width=data->rc.right - data->rc.left;
580 int height=data->rc.bottom - data->rc.top;
584 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
585 case ABM_GETTASKBARPOS:
586 GetWindowRect(data->hWnd, &rec);
590 SetActiveWindow(data->hWnd);
592 case ABM_GETAUTOHIDEBAR:
593 data->hWnd=GetActiveWindow();
596 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
597 width,height,SWP_SHOWWINDOW);
600 GetWindowRect(data->hWnd, &(data->rc));
603 FIXME("ABM_REMOVE broken\n");
604 /* FIXME: this is wrong; should it be DestroyWindow instead? */
605 /*CloseHandle(data->hWnd);*/
607 case ABM_SETAUTOHIDEBAR:
608 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
609 width,height,SWP_SHOWWINDOW);
612 data->uEdge=(ABE_RIGHT | ABE_LEFT);
613 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
614 width,height,SWP_SHOWWINDOW);
616 case ABM_WINDOWPOSCHANGED:
617 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
618 width,height,SWP_SHOWWINDOW);
624 /*************************************************************************
625 * SHHelpShortcuts_RunDLL [SHELL32.@]
628 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
629 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
630 dwArg1, dwArg2, dwArg3, dwArg4);
635 /*************************************************************************
636 * SHLoadInProc [SHELL32.@]
637 * Create an instance of specified object class from within
638 * the shell process and release it immediately
641 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
643 IUnknown * pUnk = NULL;
644 TRACE("%s\n", debugstr_guid(rclsid));
646 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
649 IUnknown_Release(pUnk);
652 return DISP_E_MEMBERNOTFOUND;
655 /*************************************************************************
656 * AboutDlgProc (internal)
658 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
661 char Template[512], AppTitle[512];
666 { case WM_INITDIALOG:
667 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
669 { const char* const *pstr = SHELL_People;
670 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
671 GetWindowTextA( hWnd, Template, sizeof(Template) );
672 sprintf( AppTitle, Template, info->szApp );
673 SetWindowTextA( hWnd, AppTitle );
674 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
675 info->szOtherStuff );
676 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
677 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
681 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
682 hIconTitleFont = CreateFontIndirectA( &logFont );
684 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
686 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
689 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
697 HDC hDC = BeginPaint( hWnd, &ps );
699 if( __get_dropline( hWnd, &rect ) ) {
700 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
701 MoveToEx( hDC, rect.left, rect.top, NULL );
702 LineTo( hDC, rect.right, rect.bottom );
704 EndPaint( hWnd, &ps );
708 #if 0 /* FIXME: should use DoDragDrop */
709 case WM_LBTRACKPOINT:
710 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
711 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
712 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
713 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
715 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
716 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
717 char* pstr = (char*)GlobalLock16( hMemObj );
720 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
721 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
722 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
723 UpdateWindow( hWndCtl );
724 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
725 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
728 GlobalFree16( hMemObj );
735 case WM_QUERYDROPOBJECT:
737 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
738 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
740 if( __get_dropline( hWnd, &rect ) )
742 pt.x=lpDragInfo->pt.x;
743 pt.x=lpDragInfo->pt.y;
744 rect.bottom += DROP_FIELD_HEIGHT;
745 if( PtInRect( &rect, pt ) )
746 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
756 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
757 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
758 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
760 { static char __appendix_str[] = " with";
762 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
763 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
764 if( !strncmp( Template, "WINE", 4 ) )
765 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
767 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
769 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
770 (WPARAM)-1, (LPARAM)Template );
773 strcpy( Template, pstr );
774 strcat( Template, __appendix_str );
775 SetWindowTextA( hWndCtl, Template );
776 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
785 { EndDialog(hWnd, TRUE);
790 EndDialog(hWnd, TRUE);
798 /*************************************************************************
799 * ShellAboutA [SHELL32.288]
801 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
808 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
810 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
814 info.szOtherStuff = szOtherStuff;
816 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
817 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
818 template, hWnd, AboutDlgProc, (LPARAM)&info );
822 /*************************************************************************
823 * ShellAboutW [SHELL32.289]
825 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
834 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
836 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
839 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
840 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
842 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
843 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
844 template, hWnd, AboutDlgProc, (LPARAM)&info );
845 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
846 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
850 /*************************************************************************
851 * FreeIconList (SHELL32.@)
853 void WINAPI FreeIconList( DWORD dw )
854 { FIXME("(%lx): stub\n",dw);
857 /***********************************************************************
858 * DllGetVersion [SHELL32.@]
860 * Retrieves version information of the 'SHELL32.DLL'
863 * pdvi [O] pointer to version information structure.
867 * Failure: E_INVALIDARG
870 * Returns version of a shell32.dll from IE4.01 SP1.
873 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
875 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
877 WARN("wrong DLLVERSIONINFO size from app\n");
881 pdvi->dwMajorVersion = 4;
882 pdvi->dwMinorVersion = 72;
883 pdvi->dwBuildNumber = 3110;
884 pdvi->dwPlatformID = 1;
886 TRACE("%lu.%lu.%lu.%lu\n",
887 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
888 pdvi->dwBuildNumber, pdvi->dwPlatformID);
892 /*************************************************************************
893 * global variables of the shell32.dll
894 * all are once per process
897 void (WINAPI *pDLLInitComctl)(LPVOID);
899 LPVOID (WINAPI *pCOMCTL32_Alloc) (INT);
900 BOOL (WINAPI *pCOMCTL32_Free) (LPVOID);
902 HDPA (WINAPI *pDPA_Create) (INT);
903 INT (WINAPI *pDPA_InsertPtr) (const HDPA, INT, LPVOID);
904 BOOL (WINAPI *pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
905 LPVOID (WINAPI *pDPA_GetPtr) (const HDPA, INT);
906 BOOL (WINAPI *pDPA_Destroy) (const HDPA);
907 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
908 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
909 HANDLE (WINAPI *pCreateMRUListA) (LPVOID lpcml);
910 DWORD (WINAPI *pFreeMRUListA) (HANDLE hMRUList);
911 INT (WINAPI *pAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
912 INT (WINAPI *pFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
913 INT (WINAPI *pEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
915 static HINSTANCE hComctl32;
917 LONG shell32_ObjCount = 0;
918 HINSTANCE shell32_hInstance = 0;
919 HIMAGELIST ShellSmallIconList = 0;
920 HIMAGELIST ShellBigIconList = 0;
923 /*************************************************************************
927 * calling oleinitialize here breaks sone apps.
930 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
932 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
936 case DLL_PROCESS_ATTACH:
937 shell32_hInstance = hinstDLL;
938 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
939 DisableThreadLibraryCalls(shell32_hInstance);
943 ERR("P A N I C SHELL32 loading failed\n");
948 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
949 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
950 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
951 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
952 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
953 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
954 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
955 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
956 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
957 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
958 pCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
959 pFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
960 pAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
961 pFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
962 pEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
964 /* initialize the common controls */
967 pDLLInitComctl(NULL);
972 InitChangeNotifications();
973 SHInitRestricted(NULL, NULL);
976 case DLL_THREAD_ATTACH:
979 case DLL_THREAD_DETACH:
982 case DLL_PROCESS_DETACH:
983 shell32_hInstance = 0;
987 IShellFolder_Release(pdesktopfolder);
988 pdesktopfolder = NULL;
992 FreeChangeNotifications();
994 /* this one is here to check if AddRef/Release is balanced */
995 if (shell32_ObjCount)
997 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
1004 /*************************************************************************
1005 * DllInstall [SHELL32.@]
1009 * BOOL bInstall - TRUE for install, FALSE for uninstall
1010 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1013 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
1015 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1017 return S_OK; /* indicate success */
1020 /***********************************************************************
1021 * DllCanUnloadNow (SHELL32.@)
1023 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
1025 FIXME("(void): stub\n");