5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
23 #include "wine/shell16.h"
24 #include "wine/undocshell.h"
25 #include "wine/winuser16.h"
29 #include "shell32_main.h"
31 #include "debugtools.h"
33 DEFAULT_DEBUG_CHANNEL(shell);
36 /*************************************************************************
37 * CommandLineToArgvW [SHELL32.@]
39 LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
45 /* to get writeable copy */
46 if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, (strlenW(lpCmdline)+1) * sizeof(WCHAR) )))
48 strcpyW( cmdline, lpCmdline );
56 while (*s && *s==0x0020)
62 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
70 while (*s==0x0020) *s++ = 0;
84 /*************************************************************************
85 * SHGetFileInfoA [SHELL32.@]
89 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
90 SHFILEINFOA *psfi, UINT sizeofpsfi,
93 char szLoaction[MAX_PATH];
95 DWORD ret = TRUE, dwAttributes = 0;
96 IShellFolder * psfParent = NULL;
97 IExtractIconA * pei = NULL;
98 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
101 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
102 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
104 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
107 /* windows initializes this values regardless of the flags */
108 psfi->szDisplayName[0] = '\0';
109 psfi->szTypeName[0] = '\0';
112 if (flags & SHGFI_EXETYPE) {
116 IMAGE_DOS_HEADER mz_header;
121 if (flags != SHGFI_EXETYPE) return 0;
123 status = GetBinaryTypeA (path, &BinaryType);
124 if (!status) return 0;
125 if ((BinaryType == SCS_DOS_BINARY)
126 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
128 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
129 NULL, OPEN_EXISTING, 0, 0 );
130 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
132 /* The next section is adapted from MODULE_GetBinaryType, as we need
133 * to examine the image header to get OS and version information. We
134 * know from calling GetBinaryTypeA that the image is valid and either
135 * an NE or PE, so much error handling can be omitted.
136 * Seek to the start of the file and read the header information.
139 SetFilePointer( hfile, 0, NULL, SEEK_SET );
140 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
142 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
143 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
144 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
146 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
147 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
148 CloseHandle( hfile );
149 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
150 return IMAGE_NT_SIGNATURE
151 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
152 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
154 return IMAGE_NT_SIGNATURE;
156 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
159 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
160 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
161 CloseHandle( hfile );
162 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
163 | (ne.ne_expver << 16);
166 CloseHandle( hfile );
171 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
172 the pidl functions fail on not existing file names */
173 if (flags & SHGFI_PIDL)
175 pidl = (LPCITEMIDLIST) path;
178 ERR("pidl is null!\n");
182 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
184 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
185 /* note: the attributes in ISF::ParseDisplayName are not implemented */
188 /* get the parent shellfolder */
191 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
194 /* get the attributes of the child */
195 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
197 if (!(flags & SHGFI_ATTR_SPECIFIED))
199 psfi->dwAttributes = 0xffffffff;
201 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
204 /* get the displayname */
205 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
207 if (flags & SHGFI_USEFILEATTRIBUTES)
209 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
214 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
215 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
219 /* get the type name */
220 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
222 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
226 if (flags & SHGFI_LINKOVERLAY)
227 FIXME("set icon to link, stub\n");
229 if (flags & SHGFI_SELECTED)
230 FIXME("set icon to selected, stub\n");
232 if (flags & SHGFI_SHELLICONSIZE)
233 FIXME("set icon to shell size, stub\n");
235 /* get the iconlocation */
236 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
239 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
243 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
244 /* fixme what to do with the index? */
246 if(uFlags != GIL_NOTFILENAME)
247 strcpy (psfi->szDisplayName, szLoaction);
251 IExtractIconA_Release(pei);
255 /* get icon index (or load icon)*/
256 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
258 if (flags & SHGFI_USEFILEATTRIBUTES)
260 char sTemp [MAX_PATH];
264 lstrcpynA(sTemp, path, MAX_PATH);
265 szExt = (LPSTR) PathFindExtensionA(sTemp);
266 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
267 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
269 if (!strcmp("%1",sTemp)) /* icon is in the file */
273 /* FIXME: if sTemp contains a valid filename, get the icon
274 from there, index is in dwNr
278 else /* default icon */
285 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
286 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
293 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
298 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
299 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
301 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
302 FIXME("unknown attribute!\n");
305 IShellFolder_Release(psfParent);
310 if(pidlLast) SHFree(pidlLast);
312 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
313 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
318 /*************************************************************************
319 * SHGetFileInfoW [SHELL32.@]
322 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
323 SHFILEINFOW *psfi, UINT sizeofpsfi,
329 SHFILEINFOA temppsfi;
331 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
332 temppath = HeapAlloc(GetProcessHeap(), 0, len);
333 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
335 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
336 sizeof(temppsfi.szDisplayName), NULL, NULL);
337 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
338 sizeof(temppsfi.szTypeName), NULL, NULL);
340 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
342 HeapFree(GetProcessHeap(), 0, temppath);
347 /*************************************************************************
348 * SHGetFileInfo [SHELL32.@]
350 DWORD WINAPI SHGetFileInfoAW(
352 DWORD dwFileAttributes,
357 if(SHELL_OsIsUnicode())
358 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
359 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
362 /*************************************************************************
363 * DuplicateIcon [SHELL32.@]
365 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
370 TRACE("(%04x, %04x)\n", hInstance, hIcon);
372 if(GetIconInfo(hIcon, &IconInfo))
374 hDupIcon = CreateIconIndirect(&IconInfo);
376 /* clean up hbmMask and hbmColor */
377 DeleteObject(IconInfo.hbmMask);
378 DeleteObject(IconInfo.hbmColor);
385 /*************************************************************************
386 * ExtractIconA [SHELL32.@]
389 * if the filename is not a file return 1
391 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
393 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
397 HICON16* ptr = (HICON16*)GlobalLock16(handle);
398 HICON16 hIcon = *ptr;
400 GlobalFree16(handle);
406 /*************************************************************************
407 * ExtractIconW [SHELL32.@]
410 * is the filename is not a file return 1
412 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
418 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
419 ret = ExtractIconA(hInstance,exefn,nIconIndex);
421 HeapFree(GetProcessHeap(),0,exefn);
425 /*************************************************************************
426 * FindExecutableA [SHELL32.@]
428 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
431 HINSTANCE retval=31; /* default - 'No association was found' */
434 TRACE("File %s, Dir %s\n",
435 (lpFile != NULL?lpFile:"-"),
436 (lpDirectory != NULL?lpDirectory:"-"));
438 lpResult[0]='\0'; /* Start off with an empty return string */
440 /* trap NULL parameters on entry */
441 if (( lpFile == NULL ) || ( lpResult == NULL ))
442 { /* FIXME - should throw a warning, perhaps! */
443 return 2; /* File not found. Close enough, I guess. */
447 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
448 SetCurrentDirectoryA( lpDirectory );
451 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
453 TRACE("returning %s\n", lpResult);
455 SetCurrentDirectoryA( old_dir );
459 /*************************************************************************
460 * FindExecutableW [SHELL32.@]
462 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
465 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
466 return 31; /* default - 'No association was found' */
475 #define IDC_STATIC_TEXT 100
476 #define IDC_LISTBOX 99
477 #define IDC_WINE_TEXT 98
479 #define DROP_FIELD_TOP (-15)
480 #define DROP_FIELD_HEIGHT 15
482 static HICON hIconTitleFont;
484 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
485 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
487 { GetWindowRect( hWndCtl, lprect );
488 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
489 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
495 /*************************************************************************
496 * SHAppBarMessage [SHELL32.@]
498 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
500 int width=data->rc.right - data->rc.left;
501 int height=data->rc.bottom - data->rc.top;
505 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
506 case ABM_GETTASKBARPOS:
507 GetWindowRect(data->hWnd, &rec);
511 SetActiveWindow(data->hWnd);
513 case ABM_GETAUTOHIDEBAR:
514 data->hWnd=GetActiveWindow();
517 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
518 width,height,SWP_SHOWWINDOW);
521 GetWindowRect(data->hWnd, &(data->rc));
524 CloseHandle(data->hWnd);
526 case ABM_SETAUTOHIDEBAR:
527 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
528 width,height,SWP_SHOWWINDOW);
531 data->uEdge=(ABE_RIGHT | ABE_LEFT);
532 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
533 width,height,SWP_SHOWWINDOW);
535 case ABM_WINDOWPOSCHANGED:
536 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
537 width,height,SWP_SHOWWINDOW);
543 /*************************************************************************
544 * SHHelpShortcuts_RunDLL [SHELL32.@]
547 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
548 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
549 dwArg1, dwArg2, dwArg3, dwArg4);
554 /*************************************************************************
555 * SHLoadInProc [SHELL32.@]
556 * Create an instance of specified object class from within
557 * the shell process and release it immediately
560 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
562 IUnknown * pUnk = NULL;
563 TRACE("%s\n", debugstr_guid(rclsid));
565 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
568 IUnknown_Release(pUnk);
571 return DISP_E_MEMBERNOTFOUND;
574 /*************************************************************************
575 * ShellExecuteA [SHELL32.290]
577 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
578 LPCSTR lpFile, LPCSTR lpParameters,
579 LPCSTR lpDirectory, INT iShowCmd )
581 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
582 lpDirectory, iShowCmd );
585 /*************************************************************************
586 * ShellExecuteW [SHELL32.294]
588 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
589 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
596 LPCWSTR lpParameters,
604 /*************************************************************************
605 * AboutDlgProc (internal)
607 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
610 char Template[512], AppTitle[512];
615 { case WM_INITDIALOG:
616 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
618 { const char* const *pstr = SHELL_People;
619 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
620 GetWindowTextA( hWnd, Template, sizeof(Template) );
621 sprintf( AppTitle, Template, info->szApp );
622 SetWindowTextA( hWnd, AppTitle );
623 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
624 info->szOtherStuff );
625 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
626 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
630 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
631 hIconTitleFont = CreateFontIndirectA( &logFont );
633 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
635 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
638 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
646 HDC hDC = BeginPaint( hWnd, &ps );
648 if( __get_dropline( hWnd, &rect ) ) {
649 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
650 MoveToEx( hDC, rect.left, rect.top, NULL );
651 LineTo( hDC, rect.right, rect.bottom );
653 EndPaint( hWnd, &ps );
657 #if 0 /* FIXME: should use DoDragDrop */
658 case WM_LBTRACKPOINT:
659 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
660 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
661 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
662 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
664 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
665 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
666 char* pstr = (char*)GlobalLock16( hMemObj );
669 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
670 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
671 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
672 UpdateWindow( hWndCtl );
673 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
674 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
677 GlobalFree16( hMemObj );
684 case WM_QUERYDROPOBJECT:
686 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
687 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
689 if( __get_dropline( hWnd, &rect ) )
691 pt.x=lpDragInfo->pt.x;
692 pt.x=lpDragInfo->pt.y;
693 rect.bottom += DROP_FIELD_HEIGHT;
694 if( PtInRect( &rect, pt ) )
695 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
705 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
706 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
707 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
709 { static char __appendix_str[] = " with";
711 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
712 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
713 if( !strncmp( Template, "WINE", 4 ) )
714 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
716 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
718 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
719 (WPARAM)-1, (LPARAM)Template );
722 strcpy( Template, pstr );
723 strcat( Template, __appendix_str );
724 SetWindowTextA( hWndCtl, Template );
725 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
734 { EndDialog(hWnd, TRUE);
739 EndDialog(hWnd, TRUE);
747 /*************************************************************************
748 * ShellAboutA [SHELL32.288]
750 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
757 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
759 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
763 info.szOtherStuff = szOtherStuff;
765 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
766 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
767 template, hWnd, AboutDlgProc, (LPARAM)&info );
771 /*************************************************************************
772 * ShellAboutW [SHELL32.289]
774 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
783 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
785 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
788 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
789 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
791 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
792 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
793 template, hWnd, AboutDlgProc, (LPARAM)&info );
794 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
795 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
799 /*************************************************************************
800 * FreeIconList (SHELL32.@)
802 void WINAPI FreeIconList( DWORD dw )
803 { FIXME("(%lx): stub\n",dw);
806 /***********************************************************************
807 * DllGetVersion [SHELL32.@]
809 * Retrieves version information of the 'SHELL32.DLL'
812 * pdvi [O] pointer to version information structure.
816 * Failure: E_INVALIDARG
819 * Returns version of a shell32.dll from IE4.01 SP1.
822 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
824 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
826 WARN("wrong DLLVERSIONINFO size from app\n");
830 pdvi->dwMajorVersion = 4;
831 pdvi->dwMinorVersion = 72;
832 pdvi->dwBuildNumber = 3110;
833 pdvi->dwPlatformID = 1;
835 TRACE("%lu.%lu.%lu.%lu\n",
836 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
837 pdvi->dwBuildNumber, pdvi->dwPlatformID);
841 /*************************************************************************
842 * global variables of the shell32.dll
843 * all are once per process
846 void WINAPI (*pDLLInitComctl)(LPVOID);
848 LPVOID WINAPI (*pCOMCTL32_Alloc) (INT);
849 BOOL WINAPI (*pCOMCTL32_Free) (LPVOID);
851 HDPA WINAPI (*pDPA_Create) (INT);
852 INT WINAPI (*pDPA_InsertPtr) (const HDPA, INT, LPVOID);
853 BOOL WINAPI (*pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
854 LPVOID WINAPI (*pDPA_GetPtr) (const HDPA, INT);
855 BOOL WINAPI (*pDPA_Destroy) (const HDPA);
856 INT WINAPI (*pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
857 LPVOID WINAPI (*pDPA_DeletePtr) (const HDPA hdpa, INT i);
859 static HINSTANCE hComctl32;
861 LONG shell32_ObjCount = 0;
862 HINSTANCE shell32_hInstance = 0;
863 HIMAGELIST ShellSmallIconList = 0;
864 HIMAGELIST ShellBigIconList = 0;
867 /*************************************************************************
871 * calling oleinitialize here breaks sone apps.
874 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
876 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
880 case DLL_PROCESS_ATTACH:
881 shell32_hInstance = hinstDLL;
882 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
883 DisableThreadLibraryCalls(shell32_hInstance);
887 ERR("P A N I C SHELL32 loading failed\n");
892 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
893 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
894 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
895 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
896 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
897 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
898 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
899 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
900 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
901 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
903 /* initialize the common controls */
906 pDLLInitComctl(NULL);
911 InitChangeNotifications();
912 SHInitRestricted(NULL, NULL);
915 case DLL_THREAD_ATTACH:
918 case DLL_THREAD_DETACH:
921 case DLL_PROCESS_DETACH:
922 shell32_hInstance = 0;
926 IShellFolder_Release(pdesktopfolder);
927 pdesktopfolder = NULL;
931 FreeChangeNotifications();
933 /* this one is here to check if AddRef/Release is balanced */
934 if (shell32_ObjCount)
936 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
943 /*************************************************************************
944 * DllInstall [SHELL32.@]
948 * BOOL bInstall - TRUE for install, FALSE for uninstall
949 * LPCWSTR pszCmdLine - command line (unused by shell32?)
952 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
954 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
956 return S_OK; /* indicate success */
959 /***********************************************************************
960 * DllCanUnloadNow (SHELL32.@)
962 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
964 FIXME("(void): stub\n");