5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
13 #include "wine/winuser16.h"
18 #include "debugtools.h"
25 #include "shell32_main.h"
26 #include "wine/undocshell.h"
31 DEFAULT_DEBUG_CHANNEL(shell);
34 /*************************************************************************
35 * CommandLineToArgvW [SHELL32.7]
37 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
42 /* to get writeable copy */
43 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
50 while (*s && *s==0x0020)
56 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
62 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
64 while (*s && *s==0x0020)
72 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
74 HeapFree( GetProcessHeap(), 0, cmdline );
80 /*************************************************************************
81 * Control_RunDLL [SHELL32.12]
83 * Wild speculation in the following!
85 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
88 void WINAPI Control_RunDLL( HWND hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
90 FIXME("(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
91 debugstr_a(cmd), arg4);
94 /*************************************************************************
95 * SHGetFileInfoA [SHELL32.@]
99 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
100 SHFILEINFOA *psfi, UINT sizeofpsfi,
103 char szLoaction[MAX_PATH];
105 DWORD ret = TRUE, dwAttributes = 0;
106 IShellFolder * psfParent = NULL;
107 IExtractIconA * pei = NULL;
108 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
111 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
112 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
114 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
117 /* windows initializes this values regardless of the flags */
118 psfi->szDisplayName[0] = '\0';
119 psfi->szTypeName[0] = '\0';
122 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
123 the pidl functions fail on not existing file names */
124 if (flags & SHGFI_PIDL)
126 pidl = (LPCITEMIDLIST) path;
129 ERR("pidl is null!\n");
133 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
135 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
136 /* note: the attributes in ISF::ParseDisplayName are not implemented */
139 /* get the parent shellfolder */
142 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
145 /* get the attributes of the child */
146 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
148 if (!(flags & SHGFI_ATTR_SPECIFIED))
150 psfi->dwAttributes = 0xffffffff;
152 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
155 /* get the displayname */
156 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
158 if (flags & SHGFI_USEFILEATTRIBUTES)
160 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
165 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
166 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
170 /* get the type name */
171 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
173 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
177 if (flags & SHGFI_LINKOVERLAY)
178 FIXME("set icon to link, stub\n");
180 if (flags & SHGFI_SELECTED)
181 FIXME("set icon to selected, stub\n");
183 if (flags & SHGFI_SHELLICONSIZE)
184 FIXME("set icon to shell size, stub\n");
186 /* get the iconlocation */
187 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
190 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
194 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
195 /* fixme what to do with the index? */
197 if(uFlags != GIL_NOTFILENAME)
198 strcpy (psfi->szDisplayName, szLoaction);
202 IExtractIconA_Release(pei);
206 /* get icon index (or load icon)*/
207 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
209 if (flags & SHGFI_USEFILEATTRIBUTES)
211 char sTemp [MAX_PATH];
215 lstrcpynA(sTemp, path, MAX_PATH);
216 szExt = (LPSTR) PathFindExtensionA(sTemp);
217 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
218 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
220 if (!strcmp("%1",sTemp)) /* icon is in the file */
224 /* FIXME: if sTemp contains a valid filename, get the icon
225 from there, index is in dwNr
229 else /* default icon */
236 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
237 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
244 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
249 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
250 psfi->hIcon = pImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
253 if (flags & SHGFI_EXETYPE)
254 FIXME("type of executable, stub\n");
256 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
257 FIXME("unknown attribute!\n");
260 IShellFolder_Release(psfParent);
265 if(pidlLast) SHFree(pidlLast);
267 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
268 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
273 /*************************************************************************
274 * SHGetFileInfoW [SHELL32.@]
277 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
278 SHFILEINFOW *psfi, UINT sizeofpsfi,
280 { FIXME("(%s,0x%lx,%p,0x%x,0x%x)\n",
281 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
285 /*************************************************************************
286 * SHGetFileInfoAW [SHELL32.@]
288 DWORD WINAPI SHGetFileInfoAW(
290 DWORD dwFileAttributes,
295 if(SHELL_OsIsUnicode())
296 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
297 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
300 /*************************************************************************
301 * DuplicateIcon [SHELL32.188]
303 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
306 HICON hDupIcon = NULL;
308 TRACE("(%04x, %04x)\n", hInstance, hIcon);
310 if(GetIconInfo(hIcon, &IconInfo))
312 hDupIcon = CreateIconIndirect(&IconInfo);
314 /* clean up hbmMask and hbmColor */
315 DeleteObject(IconInfo.hbmMask);
316 DeleteObject(IconInfo.hbmColor);
323 /*************************************************************************
324 * ExtractIconA [SHELL32.133]
327 * is the filename is not a file return 1
329 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
331 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
335 HICON16* ptr = (HICON16*)GlobalLock16(handle);
336 HICON16 hIcon = *ptr;
338 GlobalFree16(handle);
344 /*************************************************************************
345 * ExtractIconW [SHELL32.180]
348 * is the filename is not a file return 1
350 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
356 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
357 ret = ExtractIconA(hInstance,exefn,nIconIndex);
359 HeapFree(GetProcessHeap(),0,exefn);
363 /*************************************************************************
364 * FindExecutableA [SHELL32.184]
366 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
368 { HINSTANCE retval=31; /* default - 'No association was found' */
371 TRACE("File %s, Dir %s\n",
372 (lpFile != NULL?lpFile:"-"),
373 (lpDirectory != NULL?lpDirectory:"-"));
375 lpResult[0]='\0'; /* Start off with an empty return string */
377 /* trap NULL parameters on entry */
378 if (( lpFile == NULL ) || ( lpResult == NULL ))
379 { /* FIXME - should throw a warning, perhaps! */
380 return 2; /* File not found. Close enough, I guess. */
384 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
385 SetCurrentDirectoryA( lpDirectory );
388 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
390 TRACE("returning %s\n", lpResult);
392 SetCurrentDirectoryA( old_dir );
396 /*************************************************************************
397 * FindExecutableW [SHELL32.219]
399 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
402 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
403 return 31; /* default - 'No association was found' */
412 #define IDC_STATIC_TEXT 100
413 #define IDC_LISTBOX 99
414 #define IDC_WINE_TEXT 98
416 #define DROP_FIELD_TOP (-15)
417 #define DROP_FIELD_HEIGHT 15
419 extern HICON hIconTitleFont;
421 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
422 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
424 { GetWindowRect( hWndCtl, lprect );
425 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
426 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
432 /*************************************************************************
433 * SHAppBarMessage [SHELL32.207]
435 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
437 int width=data->rc.right - data->rc.left;
438 int height=data->rc.bottom - data->rc.top;
442 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
443 case ABM_GETTASKBARPOS:
444 GetWindowRect(data->hWnd, &rec);
448 SetActiveWindow(data->hWnd);
450 case ABM_GETAUTOHIDEBAR:
451 data->hWnd=GetActiveWindow();
454 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
455 width,height,SWP_SHOWWINDOW);
458 GetWindowRect(data->hWnd, &(data->rc));
461 CloseHandle(data->hWnd);
463 case ABM_SETAUTOHIDEBAR:
464 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
465 width,height,SWP_SHOWWINDOW);
468 data->uEdge=(ABE_RIGHT | ABE_LEFT);
469 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
470 width,height,SWP_SHOWWINDOW);
472 case ABM_WINDOWPOSCHANGED:
473 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
474 width,height,SWP_SHOWWINDOW);
480 /*************************************************************************
481 * SHHelpShortcuts_RunDLL [SHELL32.224]
484 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
485 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
486 dwArg1, dwArg2, dwArg3, dwArg4);
491 /*************************************************************************
492 * SHLoadInProc [SHELL32.225]
493 * Create an instance of specified object class from within
494 * the shell process and release it immediately
497 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
499 IUnknown * pUnk = NULL;
500 TRACE("%s\n", debugstr_guid(rclsid));
502 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
505 IUnknown_Release(pUnk);
508 return DISP_E_MEMBERNOTFOUND;
511 /*************************************************************************
512 * ShellExecuteA [SHELL32.245]
514 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
515 LPCSTR lpFile, LPCSTR lpParameters,
516 LPCSTR lpDirectory, INT iShowCmd )
518 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
519 lpDirectory, iShowCmd );
522 /*************************************************************************
523 * ShellExecuteW [SHELL32.294]
525 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
526 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
533 LPCWSTR lpParameters,
541 /*************************************************************************
542 * AboutDlgProc (internal)
544 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
547 char Template[512], AppTitle[512];
552 { case WM_INITDIALOG:
553 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
555 { const char* const *pstr = SHELL_People;
556 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
557 GetWindowTextA( hWnd, Template, sizeof(Template) );
558 sprintf( AppTitle, Template, info->szApp );
559 SetWindowTextA( hWnd, AppTitle );
560 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
561 info->szOtherStuff );
562 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
563 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
564 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
566 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
569 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
577 HDC hDC = BeginPaint( hWnd, &ps );
579 if( __get_dropline( hWnd, &rect ) ) {
580 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
581 MoveToEx( hDC, rect.left, rect.top, NULL );
582 LineTo( hDC, rect.right, rect.bottom );
584 EndPaint( hWnd, &ps );
588 case WM_LBTRACKPOINT:
589 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
590 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
591 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
592 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
594 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
595 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
596 char* pstr = (char*)GlobalLock16( hMemObj );
599 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
600 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
601 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
602 UpdateWindow( hWndCtl );
603 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
604 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
607 GlobalFree16( hMemObj );
613 case WM_QUERYDROPOBJECT:
615 { LPDRAGINFO16 lpDragInfo = (LPDRAGINFO16)PTR_SEG_TO_LIN((SEGPTR)lParam);
616 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
618 if( __get_dropline( hWnd, &rect ) )
620 pt.x=lpDragInfo->pt.x;
621 pt.x=lpDragInfo->pt.y;
622 rect.bottom += DROP_FIELD_HEIGHT;
623 if( PtInRect( &rect, pt ) )
624 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
634 { LPDRAGINFO16 lpDragInfo = (LPDRAGINFO16)PTR_SEG_TO_LIN((SEGPTR)lParam);
635 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
636 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
638 { static char __appendix_str[] = " with";
640 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
641 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
642 if( !strncmp( Template, "WINE", 4 ) )
643 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
645 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
647 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
648 (WPARAM)-1, (LPARAM)Template );
651 strcpy( Template, pstr );
652 strcat( Template, __appendix_str );
653 SetWindowTextA( hWndCtl, Template );
654 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
663 { EndDialog(hWnd, TRUE);
668 EndDialog(hWnd, TRUE);
676 /*************************************************************************
677 * ShellAboutA [SHELL32.243]
679 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
686 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
688 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
692 info.szOtherStuff = szOtherStuff;
694 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
695 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
696 template, hWnd, AboutDlgProc, (LPARAM)&info );
700 /*************************************************************************
701 * ShellAboutW [SHELL32.244]
703 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
712 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
714 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
717 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
718 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
720 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
721 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
722 template, hWnd, AboutDlgProc, (LPARAM)&info );
723 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
724 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
728 /*************************************************************************
731 void WINAPI FreeIconList( DWORD dw )
732 { FIXME("(%lx): stub\n",dw);
735 /***********************************************************************
736 * DllGetVersion [SHELL32]
738 * Retrieves version information of the 'SHELL32.DLL'
741 * pdvi [O] pointer to version information structure.
745 * Failure: E_INVALIDARG
748 * Returns version of a shell32.dll from IE4.01 SP1.
751 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
753 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
755 WARN("wrong DLLVERSIONINFO size from app");
759 pdvi->dwMajorVersion = 4;
760 pdvi->dwMinorVersion = 72;
761 pdvi->dwBuildNumber = 3110;
762 pdvi->dwPlatformID = 1;
764 TRACE("%lu.%lu.%lu.%lu\n",
765 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
766 pdvi->dwBuildNumber, pdvi->dwPlatformID);
770 /*************************************************************************
771 * global variables of the shell32.dll
772 * all are once per process
775 void (WINAPI* pDLLInitComctl)(LPVOID);
776 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
777 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
778 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
779 BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
780 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
781 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
782 COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
784 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
785 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
787 HDPA (WINAPI* pDPA_Create) (INT);
788 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
789 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
790 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
791 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
792 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
793 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
796 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
797 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
799 static HINSTANCE hComctl32;
800 static INT shell32_RefCount = 0;
802 LONG shell32_ObjCount = 0;
803 HINSTANCE shell32_hInstance = 0;
805 HIMAGELIST ShellSmallIconList = 0;
806 HIMAGELIST ShellBigIconList = 0;
809 /*************************************************************************
813 * calling oleinitialize here breaks sone apps.
816 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
818 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
822 case DLL_PROCESS_ATTACH:
824 if (shell32_hInstance) return TRUE;
826 shell32_hInstance = hinstDLL;
827 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
828 if(!huser32) huser32 = GetModuleHandleA("USER32.DLL");
829 DisableThreadLibraryCalls(shell32_hInstance);
831 if (!hComctl32 || !huser32)
833 ERR("P A N I C SHELL32 loading failed\n");
838 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
839 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
840 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
841 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
842 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
843 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
844 pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
845 pImageList_SetBkColor=(void*)GetProcAddress(hComctl32,"ImageList_SetBkColor");
846 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
847 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
848 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
849 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
850 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
851 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
852 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
853 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
854 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
856 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(huser32,"LookupIconIdFromDirectoryEx");
857 pCreateIconFromResourceEx=(void*)GetProcAddress(huser32,"CreateIconFromResourceEx");
859 /* initialize the common controls */
862 pDLLInitComctl(NULL);
867 InitChangeNotifications();
868 SHInitRestricted(NULL, NULL);
871 case DLL_THREAD_ATTACH:
875 case DLL_THREAD_DETACH:
879 case DLL_PROCESS_DETACH:
882 if ( !shell32_RefCount )
884 shell32_hInstance = 0;
888 IShellFolder_Release(pdesktopfolder);
889 pdesktopfolder = NULL;
893 FreeChangeNotifications();
895 /* this one is here to check if AddRef/Release is balanced */
896 if (shell32_ObjCount)
898 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
902 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
908 /*************************************************************************
909 * DllInstall [SHELL32.202]
913 * BOOL bInstall - TRUE for install, FALSE for uninstall
914 * LPCWSTR pszCmdLine - command line (unused by shell32?)
917 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
919 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
921 return S_OK; /* indicate success */
924 /***********************************************************************
925 * DllCanUnloadNow (SHELL32.@)
927 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
929 FIXME("(void): stub\n");