Added stub for DllInstall().
[wine/multimedia.git] / dlls / shell32 / shell32_main.c
blob080d872a124b44501eda83c8bd23f39bdfe55839
1 /*
2 * Shell basics
4 * 1998 Marcus Meissner
5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
6 */
7 #include <stdlib.h>
8 #include <string.h>
10 #include "wine/winuser16.h"
11 #include "winerror.h"
12 #include "heap.h"
13 #include "resource.h"
14 #include "dlgs.h"
15 #include "ldt.h"
16 #include "sysmetrics.h"
17 #include "debugtools.h"
18 #include "winreg.h"
19 #include "authors.h"
20 #include "winversion.h"
22 #include "shellapi.h"
23 #include "pidl.h"
25 #include "shlobj.h"
26 #include "shell32_main.h"
27 #include "shlguid.h"
28 #include "wine/undocshell.h"
29 #include "shpolicy.h"
31 DECLARE_DEBUG_CHANNEL(exec)
32 DECLARE_DEBUG_CHANNEL(shell)
34 #define MORE_DEBUG 1
35 /*************************************************************************
36 * CommandLineToArgvW [SHELL32.7]
38 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
39 { LPWSTR *argv,s,t;
40 int i;
41 TRACE_(shell)("\n");
43 /* to get writeable copy */
44 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
45 s=cmdline;i=0;
46 while (*s)
47 { /* space */
48 if (*s==0x0020)
49 { i++;
50 s++;
51 while (*s && *s==0x0020)
52 s++;
53 continue;
55 s++;
57 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
58 s=t=cmdline;
59 i=0;
60 while (*s)
61 { if (*s==0x0020)
62 { *s=0;
63 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
64 *s=0x0020;
65 while (*s && *s==0x0020)
66 s++;
67 if (*s)
68 t=s+1;
69 else
70 t=s;
71 continue;
73 s++;
75 if (*t)
76 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
78 HeapFree( GetProcessHeap(), 0, cmdline );
79 argv[i]=NULL;
80 *numargs=i;
81 return argv;
84 /*************************************************************************
85 * Control_RunDLL [SHELL32.12]
87 * Wild speculation in the following!
89 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
92 void WINAPI Control_RunDLL( HWND hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
94 FIXME_(shell)("(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
95 debugstr_a(cmd), arg4);
98 /*************************************************************************
99 * SHGetFileInfoA [SHELL32.254]
102 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
103 SHFILEINFOA *psfi, UINT sizeofpsfi,
104 UINT flags )
106 char szLoaction[MAX_PATH];
107 int iIndex;
108 DWORD ret = TRUE, dwAttributes = 0;
109 IShellFolder * psfParent = NULL;
110 IExtractIcon * pei = NULL;
111 LPITEMIDLIST pidlLast, pidl = NULL;
112 HRESULT hr = S_OK;
114 TRACE_(shell)("(%s,0x%lx,%p,0x%x,0x%x)\n",
115 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, sizeofpsfi, flags);
117 #ifdef MORE_DEBUG
118 ZeroMemory(psfi, sizeof(SHFILEINFOA));
119 #endif
120 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
121 return FALSE;
123 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
124 the pidl functions fail on not existing file names */
125 if (flags & SHGFI_PIDL)
127 pidl = (LPCITEMIDLIST) path;
128 if (!pidl )
130 ERR_(shell)("pidl is null!\n");
131 return FALSE;
134 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
136 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
137 /* note: the attributes in ISF::ParseDisplayName are not implemented */
140 /* get the parent shellfolder */
141 if (pidl)
143 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
146 /* get the attributes of the child */
147 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
149 if (!(flags & SHGFI_ATTR_SPECIFIED))
151 psfi->dwAttributes = 0xffffffff;
153 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
156 /* get the displayname */
157 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
159 if (flags & SHGFI_USEFILEATTRIBUTES)
161 strcpy (psfi->szDisplayName, PathFindFilenameA(path));
163 else
165 STRRET str;
166 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
167 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
171 /* get the type name */
172 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
174 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
177 /* ### icons ###*/
178 if (flags & SHGFI_LINKOVERLAY)
179 FIXME_(shell)("set icon to link, stub\n");
181 if (flags & SHGFI_OPENICON)
182 FIXME_(shell)("set to open icon, stub\n");
184 if (flags & SHGFI_SELECTED)
185 FIXME_(shell)("set icon to selected, stub\n");
187 if (flags & SHGFI_SHELLICONSIZE)
188 FIXME_(shell)("set icon to shell size, stub\n");
190 /* get the iconlocation */
191 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
193 UINT uDummy,uFlags;
194 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
196 if (SUCCEEDED(hr))
198 hr = IExtractIconA_GetIconLocation(pei, 0, szLoaction, MAX_PATH, &iIndex, &uFlags);
199 /* fixme what to do with the index? */
201 if(uFlags != GIL_NOTFILENAME)
202 strcpy (psfi->szDisplayName, szLoaction);
203 else
204 ret = FALSE;
206 IExtractIconA_Release(pei);
210 /* get icon index (or load icon)*/
211 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
213 if (flags & SHGFI_USEFILEATTRIBUTES)
215 char sTemp [MAX_PATH];
216 char * szExt;
217 DWORD dwNr=0;
219 lstrcpynA(sTemp, path, MAX_PATH);
220 szExt = (LPSTR) PathFindExtensionA(sTemp);
221 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
222 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
224 if (!strcmp("%1",sTemp)) /* icon is in the file */
226 strcpy(sTemp, path);
228 /* FIXME: if sTemp contains a valid filename, get the icon
229 from there, index is in dwNr
231 psfi->iIcon = 2;
233 else /* default icon */
235 psfi->iIcon = 0;
238 else
240 if (!(PidlToSicIndex(psfParent, pidlLast, (flags && SHGFI_LARGEICON), &(psfi->iIcon))))
242 ret = FALSE;
245 if (ret)
247 ret = (DWORD) ((flags && SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
251 /* icon handle */
252 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
253 psfi->hIcon = pImageList_GetIcon((flags && SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
256 if (flags & SHGFI_EXETYPE)
257 FIXME_(shell)("type of executable, stub\n");
259 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
260 FIXME_(shell)("unknown attribute!\n");
262 if (psfParent)
263 IShellFolder_Release(psfParent);
265 if (hr != S_OK)
266 ret = FALSE;
268 #ifdef MORE_DEBUG
269 TRACE_(shell) ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s\n",
270 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName);
271 #endif
272 return ret;
275 /*************************************************************************
276 * SHGetFileInfoW [SHELL32.255]
279 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
280 SHFILEINFOW *psfi, UINT sizeofpsfi,
281 UINT flags )
282 { FIXME_(shell)("(%s,0x%lx,%p,0x%x,0x%x)\n",
283 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
284 return 0;
287 /*************************************************************************
288 * ExtractIconA [SHELL32.133]
290 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
291 UINT nIconIndex )
292 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
293 TRACE_(shell)("\n");
294 if( handle )
296 HICON16* ptr = (HICON16*)GlobalLock16(handle);
297 HICON16 hIcon = *ptr;
299 GlobalFree16(handle);
300 return hIcon;
302 return 0;
305 /*************************************************************************
306 * ExtractIconW [SHELL32.180]
308 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
309 UINT nIconIndex )
310 { LPSTR exefn;
311 HICON ret;
312 TRACE_(shell)("\n");
314 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
315 ret = ExtractIconA(hInstance,exefn,nIconIndex);
317 HeapFree(GetProcessHeap(),0,exefn);
318 return ret;
321 /*************************************************************************
322 * FindExecutableA [SHELL32.184]
324 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
325 LPSTR lpResult )
326 { HINSTANCE retval=31; /* default - 'No association was found' */
327 char old_dir[1024];
329 TRACE_(shell)("File %s, Dir %s\n",
330 (lpFile != NULL?lpFile:"-"),
331 (lpDirectory != NULL?lpDirectory:"-"));
333 lpResult[0]='\0'; /* Start off with an empty return string */
335 /* trap NULL parameters on entry */
336 if (( lpFile == NULL ) || ( lpResult == NULL ))
337 { /* FIXME - should throw a warning, perhaps! */
338 return 2; /* File not found. Close enough, I guess. */
341 if (lpDirectory)
342 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
343 SetCurrentDirectoryA( lpDirectory );
346 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
348 TRACE_(shell)("returning %s\n", lpResult);
349 if (lpDirectory)
350 SetCurrentDirectoryA( old_dir );
351 return retval;
354 /*************************************************************************
355 * FindExecutableW [SHELL32.219]
357 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
358 LPWSTR lpResult)
360 FIXME_(shell)("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
361 return 31; /* default - 'No association was found' */
364 typedef struct
365 { LPCSTR szApp;
366 LPCSTR szOtherStuff;
367 HICON hIcon;
368 } ABOUT_INFO;
370 #define IDC_STATIC_TEXT 100
371 #define IDC_LISTBOX 99
372 #define IDC_WINE_TEXT 98
374 #define DROP_FIELD_TOP (-15)
375 #define DROP_FIELD_HEIGHT 15
377 extern HICON hIconTitleFont;
379 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
380 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
381 if( hWndCtl )
382 { GetWindowRect( hWndCtl, lprect );
383 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
384 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
385 return TRUE;
387 return FALSE;
390 /*************************************************************************
391 * SHAppBarMessage32 [SHELL32.207]
393 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
395 FIXME_(shell)("(0x%08lx,%p hwnd=0x%08x): stub\n", msg, data, data->hWnd);
397 switch (msg)
398 { case ABM_GETSTATE:
399 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
400 case ABM_GETTASKBARPOS:
401 /* fake a taskbar on the bottom of the desktop */
402 { RECT rec;
403 GetWindowRect(GetDesktopWindow(), &rec);
404 rec.left = 0;
405 rec.top = rec.bottom - 2;
407 return TRUE;
408 case ABM_ACTIVATE:
409 case ABM_GETAUTOHIDEBAR:
410 case ABM_NEW:
411 case ABM_QUERYPOS:
412 case ABM_REMOVE:
413 case ABM_SETAUTOHIDEBAR:
414 case ABM_SETPOS:
415 case ABM_WINDOWPOSCHANGED:
416 return FALSE;
418 return 0;
421 /*************************************************************************
422 * SHHelpShortcuts_RunDLL [SHELL32.224]
425 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
426 { FIXME_(exec)("(%lx, %lx, %lx, %lx) empty stub!\n",
427 dwArg1, dwArg2, dwArg3, dwArg4);
429 return 0;
432 /*************************************************************************
433 * SHLoadInProc [SHELL32.225]
437 DWORD WINAPI SHLoadInProc (DWORD dwArg1)
438 { FIXME_(shell)("(%lx) empty stub!\n", dwArg1);
439 return 0;
442 /*************************************************************************
443 * ShellExecuteA [SHELL32.245]
445 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
446 LPCSTR lpFile, LPCSTR lpParameters,
447 LPCSTR lpDirectory, INT iShowCmd )
448 { TRACE_(shell)("\n");
449 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
450 lpDirectory, iShowCmd );
453 /*************************************************************************
454 * ShellExecuteW [SHELL32.294]
455 * from shellapi.h
456 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
457 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
459 HINSTANCE WINAPI
460 ShellExecuteW(
461 HWND hwnd,
462 LPCWSTR lpOperation,
463 LPCWSTR lpFile,
464 LPCWSTR lpParameters,
465 LPCWSTR lpDirectory,
466 INT nShowCmd) {
468 FIXME_(shell)(": stub\n");
469 return 0;
472 /*************************************************************************
473 * AboutDlgProc32 (internal)
475 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
476 LPARAM lParam )
477 { HWND hWndCtl;
478 char Template[512], AppTitle[512];
480 TRACE_(shell)("\n");
482 switch(msg)
483 { case WM_INITDIALOG:
484 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
485 if (info)
486 { const char* const *pstr = SHELL_People;
487 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
488 GetWindowTextA( hWnd, Template, sizeof(Template) );
489 sprintf( AppTitle, Template, info->szApp );
490 SetWindowTextA( hWnd, AppTitle );
491 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
492 info->szOtherStuff );
493 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
494 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
495 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
496 while (*pstr)
497 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
498 pstr++;
500 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
503 return 1;
505 case WM_PAINT:
506 { RECT rect;
507 PAINTSTRUCT ps;
508 HDC hDC = BeginPaint( hWnd, &ps );
510 if( __get_dropline( hWnd, &rect ) ) {
511 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
512 MoveToEx( hDC, rect.left, rect.top, NULL );
513 LineTo( hDC, rect.right, rect.bottom );
515 EndPaint( hWnd, &ps );
517 break;
519 case WM_LBTRACKPOINT:
520 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
521 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
522 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
523 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
524 if( idx != -1 )
525 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
526 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
527 char* pstr = (char*)GlobalLock16( hMemObj );
529 if( pstr )
530 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
531 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
532 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
533 UpdateWindow( hWndCtl );
534 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
535 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
537 if( hMemObj )
538 GlobalFree16( hMemObj );
542 break;
544 case WM_QUERYDROPOBJECT:
545 if( wParam == 0 )
546 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
547 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
548 { RECT rect;
549 if( __get_dropline( hWnd, &rect ) )
550 { POINT pt;
551 pt.x=lpDragInfo->pt.x;
552 pt.x=lpDragInfo->pt.y;
553 rect.bottom += DROP_FIELD_HEIGHT;
554 if( PtInRect( &rect, pt ) )
555 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
556 return TRUE;
561 break;
563 case WM_DROPOBJECT:
564 if( wParam == hWnd )
565 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
566 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
567 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
568 if( pstr )
569 { static char __appendix_str[] = " with";
571 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
572 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
573 if( !strncmp( Template, "WINE", 4 ) )
574 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
575 else
576 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
577 *pch = '\0';
578 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
579 (WPARAM)-1, (LPARAM)Template );
582 strcpy( Template, pstr );
583 strcat( Template, __appendix_str );
584 SetWindowTextA( hWndCtl, Template );
585 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
586 return TRUE;
590 break;
592 case WM_COMMAND:
593 if (wParam == IDOK)
594 { EndDialog(hWnd, TRUE);
595 return TRUE;
597 break;
598 case WM_CLOSE:
599 EndDialog(hWnd, TRUE);
600 break;
603 return 0;
607 /*************************************************************************
608 * ShellAboutA [SHELL32.243]
610 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
611 HICON hIcon )
612 { ABOUT_INFO info;
613 HRSRC hRes;
614 LPVOID template;
615 TRACE_(shell)("\n");
617 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
618 return FALSE;
619 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
620 return FALSE;
622 info.szApp = szApp;
623 info.szOtherStuff = szOtherStuff;
624 info.hIcon = hIcon;
625 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
626 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
627 template, hWnd, AboutDlgProc, (LPARAM)&info );
631 /*************************************************************************
632 * ShellAboutW [SHELL32.244]
634 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
635 HICON hIcon )
636 { BOOL ret;
637 ABOUT_INFO info;
638 HRSRC hRes;
639 LPVOID template;
641 TRACE_(shell)("\n");
643 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
644 return FALSE;
645 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
646 return FALSE;
648 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
649 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
650 info.hIcon = hIcon;
651 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
652 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
653 template, hWnd, AboutDlgProc, (LPARAM)&info );
654 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
655 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
656 return ret;
659 /*************************************************************************
660 * Shell_NotifyIcon [SHELL32.296]
661 * FIXME
662 * This function is supposed to deal with the systray.
663 * Any ideas on how this is to be implimented?
665 BOOL WINAPI Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATAA pnid )
666 { FIXME_(shell)("Taskbar Notification Area functionality not implemented !\n");
667 return TRUE; /* pretend success */
670 /*************************************************************************
671 * Shell_NotifyIcon [SHELL32.297]
672 * FIXME
673 * This function is supposed to deal with the systray.
674 * Any ideas on how this is to be implimented?
676 BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid )
677 { FIXME_(shell)("Taskbar Notification Area functionality not implemented !\n");
678 return TRUE; /* pretend success */
681 /*************************************************************************
682 * FreeIconList
684 void WINAPI FreeIconList( DWORD dw )
685 { FIXME_(shell)("(%lx): stub\n",dw);
688 /***********************************************************************
689 * DllGetVersion [COMCTL32.25]
691 * Retrieves version information of the 'SHELL32.DLL'
693 * PARAMS
694 * pdvi [O] pointer to version information structure.
696 * RETURNS
697 * Success: S_OK
698 * Failure: E_INVALIDARG
700 * NOTES
701 * Returns version of a shell32.dll from IE4.01 SP1.
704 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
706 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
707 { WARN_(shell)("wrong DLLVERSIONINFO size from app");
708 return E_INVALIDARG;
711 pdvi->dwMajorVersion = 4;
712 pdvi->dwMinorVersion = 72;
713 pdvi->dwBuildNumber = 3110;
714 pdvi->dwPlatformID = 1;
716 TRACE_(shell)("%lu.%lu.%lu.%lu\n",
717 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
718 pdvi->dwBuildNumber, pdvi->dwPlatformID);
720 return S_OK;
722 /*************************************************************************
723 * global variables of the shell32.dll
724 * all are once per process
727 void (WINAPI* pDLLInitComctl)(LPVOID);
728 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
729 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
730 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
731 BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
732 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
733 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
734 COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
736 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
737 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
739 HDPA (WINAPI* pDPA_Create) (INT);
740 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
741 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
742 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
743 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
744 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
745 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
747 /* user32 */
748 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
749 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
751 /* ole2 */
752 HRESULT (WINAPI* pOleInitialize)(LPVOID reserved);
753 void (WINAPI* pOleUninitialize)(void);
754 HRESULT (WINAPI* pDoDragDrop)(IDataObject* pDataObject, IDropSource * pDropSource, DWORD dwOKEffect, DWORD *pdwEffect);
755 HRESULT (WINAPI* pRegisterDragDrop)(HWND hwnd, IDropTarget* pDropTarget);
756 HRESULT (WINAPI* pRevokeDragDrop)(HWND hwnd);
758 static HINSTANCE hComctl32;
759 static HINSTANCE hOle32;
760 static INT shell32_RefCount = 0;
762 INT shell32_ObjCount = 0;
763 HINSTANCE shell32_hInstance;
764 HIMAGELIST ShellSmallIconList = 0;
765 HIMAGELIST ShellBigIconList = 0;
767 /*************************************************************************
768 * SHELL32 LibMain
770 * NOTES
771 * calling oleinitialize here breaks sone apps.
774 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
776 HMODULE hUser32;
778 TRACE_(shell)("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
780 switch (fdwReason)
782 case DLL_PROCESS_ATTACH:
783 shell32_RefCount++;
784 if (shell32_hInstance)
786 ERR_(shell)("shell32.dll instantiated twice in one address space!\n");
788 else
790 /* we only want to call this the first time shell32 is instantiated */
791 SHInitRestricted(NULL, NULL);
794 shell32_hInstance = hinstDLL;
796 hComctl32 = LoadLibraryA("COMCTL32.DLL");
797 hOle32 = LoadLibraryA("OLE32.DLL");
798 hUser32 = GetModuleHandleA("USER32");
800 if (!hComctl32 || !hUser32 || !hOle32)
802 ERR_(shell)("P A N I C SHELL32 loading failed\n");
803 return FALSE;
806 /* comctl32 */
807 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
808 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
809 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
810 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
811 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
812 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
813 pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
814 pImageList_SetBkColor=(void*)GetProcAddress(hComctl32,"ImageList_SetBkColor");
815 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
816 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
817 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
818 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
819 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
820 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
821 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
822 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
823 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
824 /* user32 */
825 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(hUser32,"LookupIconIdFromDirectoryEx");
826 pCreateIconFromResourceEx=(void*)GetProcAddress(hUser32,"CreateIconFromResourceEx");
827 /* ole2 */
828 pOleInitialize=(void*)GetProcAddress(hOle32,"OleInitialize");
829 pOleUninitialize=(void*)GetProcAddress(hOle32,"OleUninitialize");
830 pDoDragDrop=(void*)GetProcAddress(hOle32,"DoDragDrop");
831 pRegisterDragDrop=(void*)GetProcAddress(hOle32,"RegisterDragDrop");
832 pRevokeDragDrop=(void*)GetProcAddress(hOle32,"RevokeDragDrop");
834 /* initialize the common controls */
835 if (pDLLInitComctl)
837 pDLLInitComctl(NULL);
840 SIC_Initialize();
842 break;
844 case DLL_THREAD_ATTACH:
845 shell32_RefCount++;
846 break;
848 case DLL_THREAD_DETACH:
849 shell32_RefCount--;
850 break;
852 case DLL_PROCESS_DETACH:
853 shell32_RefCount--;
855 if ( !shell32_RefCount )
857 shell32_hInstance = 0;
859 if (pdesktopfolder)
861 IShellFolder_Release(pdesktopfolder);
862 pdesktopfolder = NULL;
865 SIC_Destroy();
867 /* this one is here to check if AddRef/Release is balanced */
868 if (shell32_ObjCount)
870 WARN_(shell)("leaving with %u objects left (memory leak)\n", shell32_ObjCount);
874 FreeLibrary(hOle32);
875 FreeLibrary(hComctl32);
877 TRACE_(shell)("refcount=%u objcount=%u \n", shell32_RefCount, shell32_ObjCount);
878 break;
880 return TRUE;
883 /*************************************************************************
884 * DllInstall [SHELL32.202]
886 * PARAMETERS
888 * BOOL bInstall - TRUE for install, FALSE for uninstall
889 * LPCWSTR pszCmdLine - command line (unused by shell32?)
892 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
894 FIXME_(shell)("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
896 return S_OK; /* indicate success */