Release 20000326.
[wine/gsoc-2012-control.git] / dlls / shell32 / shell32_main.c
blob1e11e25d88aa81154a2bc9bcf4d9c6f0e276a427
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>
9 #include <stdio.h>
11 #include "windef.h"
12 #include "wingdi.h"
13 #include "wine/winuser16.h"
14 #include "winerror.h"
15 #include "heap.h"
16 #include "dlgs.h"
17 #include "ldt.h"
18 #include "sysmetrics.h"
19 #include "debugtools.h"
20 #include "winreg.h"
21 #include "authors.h"
22 #include "winversion.h"
24 #include "shellapi.h"
25 #include "pidl.h"
27 #include "shlobj.h"
28 #include "shell32_main.h"
29 #include "shlguid.h"
30 #include "wine/undocshell.h"
31 #include "shpolicy.h"
33 DEFAULT_DEBUG_CHANNEL(shell);
35 #define MORE_DEBUG 1
36 /*************************************************************************
37 * CommandLineToArgvW [SHELL32.7]
39 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
40 { LPWSTR *argv,s,t;
41 int i;
42 TRACE("\n");
44 /* to get writeable copy */
45 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
46 s=cmdline;i=0;
47 while (*s)
48 { /* space */
49 if (*s==0x0020)
50 { i++;
51 s++;
52 while (*s && *s==0x0020)
53 s++;
54 continue;
56 s++;
58 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
59 s=t=cmdline;
60 i=0;
61 while (*s)
62 { if (*s==0x0020)
63 { *s=0;
64 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
65 *s=0x0020;
66 while (*s && *s==0x0020)
67 s++;
68 if (*s)
69 t=s+1;
70 else
71 t=s;
72 continue;
74 s++;
76 if (*t)
77 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
79 HeapFree( GetProcessHeap(), 0, cmdline );
80 argv[i]=NULL;
81 *numargs=i;
82 return argv;
85 /*************************************************************************
86 * Control_RunDLL [SHELL32.12]
88 * Wild speculation in the following!
90 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
93 void WINAPI Control_RunDLL( HWND hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
95 FIXME("(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
96 debugstr_a(cmd), arg4);
99 /*************************************************************************
100 * SHGetFileInfoA [SHELL32.254]
103 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
104 SHFILEINFOA *psfi, UINT sizeofpsfi,
105 UINT flags )
107 char szLoaction[MAX_PATH];
108 int iIndex;
109 DWORD ret = TRUE, dwAttributes = 0;
110 IShellFolder * psfParent = NULL;
111 IExtractIconA * pei = NULL;
112 LPITEMIDLIST pidlLast, pidl = NULL;
113 HRESULT hr = S_OK;
115 TRACE("(%s,0x%lx,%p,0x%x,0x%x)\n",
116 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, sizeofpsfi, flags);
118 #ifdef MORE_DEBUG
119 ZeroMemory(psfi, sizeof(SHFILEINFOA));
120 #endif
121 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
122 return FALSE;
124 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
125 the pidl functions fail on not existing file names */
126 if (flags & SHGFI_PIDL)
128 pidl = (LPCITEMIDLIST) path;
129 if (!pidl )
131 ERR("pidl is null!\n");
132 return FALSE;
135 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
137 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
138 /* note: the attributes in ISF::ParseDisplayName are not implemented */
141 /* get the parent shellfolder */
142 if (pidl)
144 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
147 /* get the attributes of the child */
148 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
150 if (!(flags & SHGFI_ATTR_SPECIFIED))
152 psfi->dwAttributes = 0xffffffff;
154 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
157 /* get the displayname */
158 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
160 if (flags & SHGFI_USEFILEATTRIBUTES)
162 strcpy (psfi->szDisplayName, PathFindFilenameA(path));
164 else
166 STRRET str;
167 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
168 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
172 /* get the type name */
173 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
175 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
178 /* ### icons ###*/
179 if (flags & SHGFI_LINKOVERLAY)
180 FIXME("set icon to link, stub\n");
182 if (flags & SHGFI_SELECTED)
183 FIXME("set icon to selected, stub\n");
185 if (flags & SHGFI_SHELLICONSIZE)
186 FIXME("set icon to shell size, stub\n");
188 /* get the iconlocation */
189 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
191 UINT uDummy,uFlags;
192 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
194 if (SUCCEEDED(hr))
196 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
197 /* fixme what to do with the index? */
199 if(uFlags != GIL_NOTFILENAME)
200 strcpy (psfi->szDisplayName, szLoaction);
201 else
202 ret = FALSE;
204 IExtractIconA_Release(pei);
208 /* get icon index (or load icon)*/
209 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
211 if (flags & SHGFI_USEFILEATTRIBUTES)
213 char sTemp [MAX_PATH];
214 char * szExt;
215 DWORD dwNr=0;
217 lstrcpynA(sTemp, path, MAX_PATH);
218 szExt = (LPSTR) PathFindExtensionA(sTemp);
219 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
220 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
222 if (!strcmp("%1",sTemp)) /* icon is in the file */
224 strcpy(sTemp, path);
226 /* FIXME: if sTemp contains a valid filename, get the icon
227 from there, index is in dwNr
229 psfi->iIcon = 2;
231 else /* default icon */
233 psfi->iIcon = 0;
236 else
238 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
239 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
241 ret = FALSE;
244 if (ret)
246 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
250 /* icon handle */
251 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
252 psfi->hIcon = pImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
255 if (flags & SHGFI_EXETYPE)
256 FIXME("type of executable, stub\n");
258 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
259 FIXME("unknown attribute!\n");
261 if (psfParent)
262 IShellFolder_Release(psfParent);
264 if (hr != S_OK)
265 ret = FALSE;
267 #ifdef MORE_DEBUG
268 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
269 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
270 #endif
271 return ret;
274 /*************************************************************************
275 * SHGetFileInfoW [SHELL32.255]
278 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
279 SHFILEINFOW *psfi, UINT sizeofpsfi,
280 UINT flags )
281 { FIXME("(%s,0x%lx,%p,0x%x,0x%x)\n",
282 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
283 return 0;
286 /*************************************************************************
287 * ExtractIconA [SHELL32.133]
289 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
290 UINT nIconIndex )
291 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
292 TRACE("\n");
293 if( handle )
295 HICON16* ptr = (HICON16*)GlobalLock16(handle);
296 HICON16 hIcon = *ptr;
298 GlobalFree16(handle);
299 return hIcon;
301 return 0;
304 /*************************************************************************
305 * ExtractIconW [SHELL32.180]
307 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
308 UINT nIconIndex )
309 { LPSTR exefn;
310 HICON ret;
311 TRACE("\n");
313 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
314 ret = ExtractIconA(hInstance,exefn,nIconIndex);
316 HeapFree(GetProcessHeap(),0,exefn);
317 return ret;
320 /*************************************************************************
321 * FindExecutableA [SHELL32.184]
323 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
324 LPSTR lpResult )
325 { HINSTANCE retval=31; /* default - 'No association was found' */
326 char old_dir[1024];
328 TRACE("File %s, Dir %s\n",
329 (lpFile != NULL?lpFile:"-"),
330 (lpDirectory != NULL?lpDirectory:"-"));
332 lpResult[0]='\0'; /* Start off with an empty return string */
334 /* trap NULL parameters on entry */
335 if (( lpFile == NULL ) || ( lpResult == NULL ))
336 { /* FIXME - should throw a warning, perhaps! */
337 return 2; /* File not found. Close enough, I guess. */
340 if (lpDirectory)
341 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
342 SetCurrentDirectoryA( lpDirectory );
345 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
347 TRACE("returning %s\n", lpResult);
348 if (lpDirectory)
349 SetCurrentDirectoryA( old_dir );
350 return retval;
353 /*************************************************************************
354 * FindExecutableW [SHELL32.219]
356 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
357 LPWSTR lpResult)
359 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
360 return 31; /* default - 'No association was found' */
363 typedef struct
364 { LPCSTR szApp;
365 LPCSTR szOtherStuff;
366 HICON hIcon;
367 } ABOUT_INFO;
369 #define IDC_STATIC_TEXT 100
370 #define IDC_LISTBOX 99
371 #define IDC_WINE_TEXT 98
373 #define DROP_FIELD_TOP (-15)
374 #define DROP_FIELD_HEIGHT 15
376 extern HICON hIconTitleFont;
378 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
379 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
380 if( hWndCtl )
381 { GetWindowRect( hWndCtl, lprect );
382 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
383 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
384 return TRUE;
386 return FALSE;
389 /*************************************************************************
390 * SHAppBarMessage32 [SHELL32.207]
392 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
394 int width=data->rc.right - data->rc.left;
395 int height=data->rc.bottom - data->rc.top;
396 RECT rec=data->rc;
397 switch (msg)
398 { case ABM_GETSTATE:
399 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
400 case ABM_GETTASKBARPOS:
401 GetWindowRect(data->hWnd, &rec);
402 data->rc=rec;
403 return TRUE;
404 case ABM_ACTIVATE:
405 SetActiveWindow(data->hWnd);
406 return TRUE;
407 case ABM_GETAUTOHIDEBAR:
408 data->hWnd=GetActiveWindow();
409 return TRUE;
410 case ABM_NEW:
411 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
412 width,height,SWP_SHOWWINDOW);
413 return TRUE;
414 case ABM_QUERYPOS:
415 GetWindowRect(data->hWnd, &(data->rc));
416 return TRUE;
417 case ABM_REMOVE:
418 CloseHandle(data->hWnd);
419 return TRUE;
420 case ABM_SETAUTOHIDEBAR:
421 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
422 width,height,SWP_SHOWWINDOW);
423 return TRUE;
424 case ABM_SETPOS:
425 data->uEdge=(ABE_RIGHT | ABE_LEFT);
426 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
427 width,height,SWP_SHOWWINDOW);
428 return TRUE;
429 case ABM_WINDOWPOSCHANGED:
430 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
431 width,height,SWP_SHOWWINDOW);
432 return TRUE;
434 return FALSE;
437 /*************************************************************************
438 * SHHelpShortcuts_RunDLL [SHELL32.224]
441 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
442 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
443 dwArg1, dwArg2, dwArg3, dwArg4);
445 return 0;
448 /*************************************************************************
449 * SHLoadInProc [SHELL32.225]
450 * Create an instance of specified object class from within
451 * the shell process and release it immediately
454 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
456 IUnknown * pUnk = NULL;
457 TRACE("%s\n", debugstr_guid(rclsid));
459 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
460 if(pUnk)
462 IUnknown_Release(pUnk);
463 return NOERROR;
465 return DISP_E_MEMBERNOTFOUND;
468 /*************************************************************************
469 * ShellExecuteA [SHELL32.245]
471 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
472 LPCSTR lpFile, LPCSTR lpParameters,
473 LPCSTR lpDirectory, INT iShowCmd )
474 { TRACE("\n");
475 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
476 lpDirectory, iShowCmd );
479 /*************************************************************************
480 * ShellExecuteW [SHELL32.294]
481 * from shellapi.h
482 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
483 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
485 HINSTANCE WINAPI
486 ShellExecuteW(
487 HWND hwnd,
488 LPCWSTR lpOperation,
489 LPCWSTR lpFile,
490 LPCWSTR lpParameters,
491 LPCWSTR lpDirectory,
492 INT nShowCmd) {
494 FIXME(": stub\n");
495 return 0;
498 /*************************************************************************
499 * AboutDlgProc32 (internal)
501 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
502 LPARAM lParam )
503 { HWND hWndCtl;
504 char Template[512], AppTitle[512];
506 TRACE("\n");
508 switch(msg)
509 { case WM_INITDIALOG:
510 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
511 if (info)
512 { const char* const *pstr = SHELL_People;
513 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
514 GetWindowTextA( hWnd, Template, sizeof(Template) );
515 sprintf( AppTitle, Template, info->szApp );
516 SetWindowTextA( hWnd, AppTitle );
517 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
518 info->szOtherStuff );
519 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
520 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
521 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
522 while (*pstr)
523 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
524 pstr++;
526 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
529 return 1;
531 case WM_PAINT:
532 { RECT rect;
533 PAINTSTRUCT ps;
534 HDC hDC = BeginPaint( hWnd, &ps );
536 if( __get_dropline( hWnd, &rect ) ) {
537 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
538 MoveToEx( hDC, rect.left, rect.top, NULL );
539 LineTo( hDC, rect.right, rect.bottom );
541 EndPaint( hWnd, &ps );
543 break;
545 case WM_LBTRACKPOINT:
546 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
547 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
548 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
549 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
550 if( idx != -1 )
551 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
552 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
553 char* pstr = (char*)GlobalLock16( hMemObj );
555 if( pstr )
556 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
557 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
558 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
559 UpdateWindow( hWndCtl );
560 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
561 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
563 if( hMemObj )
564 GlobalFree16( hMemObj );
568 break;
570 case WM_QUERYDROPOBJECT:
571 if( wParam == 0 )
572 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
573 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
574 { RECT rect;
575 if( __get_dropline( hWnd, &rect ) )
576 { POINT pt;
577 pt.x=lpDragInfo->pt.x;
578 pt.x=lpDragInfo->pt.y;
579 rect.bottom += DROP_FIELD_HEIGHT;
580 if( PtInRect( &rect, pt ) )
581 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
582 return TRUE;
587 break;
589 case WM_DROPOBJECT:
590 if( wParam == hWnd )
591 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
592 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
593 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
594 if( pstr )
595 { static char __appendix_str[] = " with";
597 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
598 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
599 if( !strncmp( Template, "WINE", 4 ) )
600 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
601 else
602 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
603 *pch = '\0';
604 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
605 (WPARAM)-1, (LPARAM)Template );
608 strcpy( Template, pstr );
609 strcat( Template, __appendix_str );
610 SetWindowTextA( hWndCtl, Template );
611 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
612 return TRUE;
616 break;
618 case WM_COMMAND:
619 if (wParam == IDOK)
620 { EndDialog(hWnd, TRUE);
621 return TRUE;
623 break;
624 case WM_CLOSE:
625 EndDialog(hWnd, TRUE);
626 break;
629 return 0;
633 /*************************************************************************
634 * ShellAboutA [SHELL32.243]
636 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
637 HICON hIcon )
638 { ABOUT_INFO info;
639 HRSRC hRes;
640 LPVOID template;
641 TRACE("\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 = szApp;
649 info.szOtherStuff = szOtherStuff;
650 info.hIcon = hIcon;
651 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
652 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
653 template, hWnd, AboutDlgProc, (LPARAM)&info );
657 /*************************************************************************
658 * ShellAboutW [SHELL32.244]
660 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
661 HICON hIcon )
662 { BOOL ret;
663 ABOUT_INFO info;
664 HRSRC hRes;
665 LPVOID template;
667 TRACE("\n");
669 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
670 return FALSE;
671 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
672 return FALSE;
674 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
675 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
676 info.hIcon = hIcon;
677 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
678 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
679 template, hWnd, AboutDlgProc, (LPARAM)&info );
680 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
681 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
682 return ret;
685 /*************************************************************************
686 * FreeIconList
688 void WINAPI FreeIconList( DWORD dw )
689 { FIXME("(%lx): stub\n",dw);
692 /***********************************************************************
693 * DllGetVersion [COMCTL32.25]
695 * Retrieves version information of the 'SHELL32.DLL'
697 * PARAMS
698 * pdvi [O] pointer to version information structure.
700 * RETURNS
701 * Success: S_OK
702 * Failure: E_INVALIDARG
704 * NOTES
705 * Returns version of a shell32.dll from IE4.01 SP1.
708 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
710 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
711 { WARN("wrong DLLVERSIONINFO size from app");
712 return E_INVALIDARG;
715 pdvi->dwMajorVersion = 4;
716 pdvi->dwMinorVersion = 72;
717 pdvi->dwBuildNumber = 3110;
718 pdvi->dwPlatformID = 1;
720 TRACE("%lu.%lu.%lu.%lu\n",
721 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
722 pdvi->dwBuildNumber, pdvi->dwPlatformID);
724 return S_OK;
726 /*************************************************************************
727 * global variables of the shell32.dll
728 * all are once per process
731 void (WINAPI* pDLLInitComctl)(LPVOID);
732 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
733 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
734 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
735 BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
736 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
737 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
738 COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
740 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
741 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
743 HDPA (WINAPI* pDPA_Create) (INT);
744 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
745 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
746 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
747 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
748 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
749 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
751 /* user32 */
752 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
753 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
755 static HINSTANCE hComctl32;
756 static INT shell32_RefCount = 0;
758 INT shell32_ObjCount = 0;
759 HINSTANCE shell32_hInstance;
760 HIMAGELIST ShellSmallIconList = 0;
761 HIMAGELIST ShellBigIconList = 0;
763 /*************************************************************************
764 * SHELL32 LibMain
766 * NOTES
767 * calling oleinitialize here breaks sone apps.
770 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
772 HMODULE hUser32;
774 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
776 switch (fdwReason)
778 case DLL_PROCESS_ATTACH:
779 shell32_RefCount++;
780 if (shell32_hInstance)
782 ERR("shell32.dll instantiated twice in one address space!\n");
783 break;
786 shell32_hInstance = hinstDLL;
788 hComctl32 = LoadLibraryA("COMCTL32.DLL");
789 hUser32 = GetModuleHandleA("USER32");
791 if (!hComctl32 || !hUser32)
793 ERR("P A N I C SHELL32 loading failed\n");
794 return FALSE;
797 /* comctl32 */
798 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
799 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
800 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
801 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
802 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
803 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
804 pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
805 pImageList_SetBkColor=(void*)GetProcAddress(hComctl32,"ImageList_SetBkColor");
806 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
807 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
808 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
809 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
810 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
811 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
812 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
813 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
814 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
815 /* user32 */
816 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(hUser32,"LookupIconIdFromDirectoryEx");
817 pCreateIconFromResourceEx=(void*)GetProcAddress(hUser32,"CreateIconFromResourceEx");
819 /* initialize the common controls */
820 if (pDLLInitComctl)
822 pDLLInitComctl(NULL);
825 SIC_Initialize();
826 SYSTRAY_Init();
827 InitChangeNotifications();
828 SHInitRestricted(NULL, NULL);
829 break;
831 case DLL_THREAD_ATTACH:
832 shell32_RefCount++;
833 break;
835 case DLL_THREAD_DETACH:
836 shell32_RefCount--;
837 break;
839 case DLL_PROCESS_DETACH:
840 shell32_RefCount--;
842 if ( !shell32_RefCount )
844 shell32_hInstance = 0;
846 if (pdesktopfolder)
848 IShellFolder_Release(pdesktopfolder);
849 pdesktopfolder = NULL;
852 SIC_Destroy();
853 FreeChangeNotifications();
855 /* this one is here to check if AddRef/Release is balanced */
856 if (shell32_ObjCount)
858 WARN("leaving with %u objects left (memory leak)\n", shell32_ObjCount);
862 FreeLibrary(hComctl32);
864 TRACE("refcount=%u objcount=%u \n", shell32_RefCount, shell32_ObjCount);
865 break;
867 return TRUE;
870 /*************************************************************************
871 * DllInstall [SHELL32.202]
873 * PARAMETERS
875 * BOOL bInstall - TRUE for install, FALSE for uninstall
876 * LPCWSTR pszCmdLine - command line (unused by shell32?)
879 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
881 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
883 return S_OK; /* indicate success */