Moved shared crtdll/ntdll functions into ntdll.
[wine.git] / dlls / shell32 / shell32_main.c
blob61e8fdbd11da5b582aa929bae875ac760602e141
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 "shell32_main.h"
28 #include "wine/undocshell.h"
29 #include "shlobj.h"
30 #include "shlguid.h"
31 #include "shlwapi.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.@]
104 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
105 SHFILEINFOA *psfi, UINT sizeofpsfi,
106 UINT flags )
108 char szLoaction[MAX_PATH];
109 int iIndex;
110 DWORD ret = TRUE, dwAttributes = 0;
111 IShellFolder * psfParent = NULL;
112 IExtractIconA * pei = NULL;
113 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
114 HRESULT hr = S_OK;
116 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
117 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
119 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
120 return FALSE;
122 /* windows initializes this values regardless of the flags */
123 psfi->szDisplayName[0] = '\0';
124 psfi->szTypeName[0] = '\0';
125 psfi->iIcon = 0;
127 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
128 the pidl functions fail on not existing file names */
129 if (flags & SHGFI_PIDL)
131 pidl = (LPCITEMIDLIST) path;
132 if (!pidl )
134 ERR("pidl is null!\n");
135 return FALSE;
138 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
140 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
141 /* note: the attributes in ISF::ParseDisplayName are not implemented */
144 /* get the parent shellfolder */
145 if (pidl)
147 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
150 /* get the attributes of the child */
151 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
153 if (!(flags & SHGFI_ATTR_SPECIFIED))
155 psfi->dwAttributes = 0xffffffff;
157 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
160 /* get the displayname */
161 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
163 if (flags & SHGFI_USEFILEATTRIBUTES)
165 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
167 else
169 STRRET str;
170 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
171 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
175 /* get the type name */
176 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
178 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
181 /* ### icons ###*/
182 if (flags & SHGFI_LINKOVERLAY)
183 FIXME("set icon to link, stub\n");
185 if (flags & SHGFI_SELECTED)
186 FIXME("set icon to selected, stub\n");
188 if (flags & SHGFI_SHELLICONSIZE)
189 FIXME("set icon to shell size, stub\n");
191 /* get the iconlocation */
192 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
194 UINT uDummy,uFlags;
195 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
197 if (SUCCEEDED(hr))
199 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
200 /* fixme what to do with the index? */
202 if(uFlags != GIL_NOTFILENAME)
203 strcpy (psfi->szDisplayName, szLoaction);
204 else
205 ret = FALSE;
207 IExtractIconA_Release(pei);
211 /* get icon index (or load icon)*/
212 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
214 if (flags & SHGFI_USEFILEATTRIBUTES)
216 char sTemp [MAX_PATH];
217 char * szExt;
218 DWORD dwNr=0;
220 lstrcpynA(sTemp, path, MAX_PATH);
221 szExt = (LPSTR) PathFindExtensionA(sTemp);
222 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
223 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
225 if (!strcmp("%1",sTemp)) /* icon is in the file */
227 strcpy(sTemp, path);
229 /* FIXME: if sTemp contains a valid filename, get the icon
230 from there, index is in dwNr
232 psfi->iIcon = 2;
234 else /* default icon */
236 psfi->iIcon = 0;
239 else
241 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
242 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
244 ret = FALSE;
247 if (ret)
249 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
253 /* icon handle */
254 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
255 psfi->hIcon = pImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
258 if (flags & SHGFI_EXETYPE)
259 FIXME("type of executable, stub\n");
261 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
262 FIXME("unknown attribute!\n");
264 if (psfParent)
265 IShellFolder_Release(psfParent);
267 if (hr != S_OK)
268 ret = FALSE;
270 if(pidlLast) SHFree(pidlLast);
271 #ifdef MORE_DEBUG
272 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
273 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
274 #endif
275 return ret;
278 /*************************************************************************
279 * SHGetFileInfoW [SHELL32.@]
282 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
283 SHFILEINFOW *psfi, UINT sizeofpsfi,
284 UINT flags )
285 { FIXME("(%s,0x%lx,%p,0x%x,0x%x)\n",
286 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
287 return 0;
290 /*************************************************************************
291 * SHGetFileInfoAW [SHELL32.@]
293 DWORD WINAPI SHGetFileInfoAW(
294 LPCVOID path,
295 DWORD dwFileAttributes,
296 LPVOID psfi,
297 UINT sizeofpsfi,
298 UINT flags)
300 if(VERSION_OsIsUnicode())
301 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
302 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
305 /*************************************************************************
306 * ExtractIconA [SHELL32.133]
308 * fixme
309 * is the filename is not a file return 1
311 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
312 UINT nIconIndex )
313 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
314 TRACE("\n");
315 if( handle )
317 HICON16* ptr = (HICON16*)GlobalLock16(handle);
318 HICON16 hIcon = *ptr;
320 GlobalFree16(handle);
321 return hIcon;
323 return 0;
326 /*************************************************************************
327 * ExtractIconW [SHELL32.180]
329 * fixme
330 * is the filename is not a file return 1
332 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
333 UINT nIconIndex )
334 { LPSTR exefn;
335 HICON ret;
336 TRACE("\n");
338 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
339 ret = ExtractIconA(hInstance,exefn,nIconIndex);
341 HeapFree(GetProcessHeap(),0,exefn);
342 return ret;
345 /*************************************************************************
346 * FindExecutableA [SHELL32.184]
348 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
349 LPSTR lpResult )
350 { HINSTANCE retval=31; /* default - 'No association was found' */
351 char old_dir[1024];
353 TRACE("File %s, Dir %s\n",
354 (lpFile != NULL?lpFile:"-"),
355 (lpDirectory != NULL?lpDirectory:"-"));
357 lpResult[0]='\0'; /* Start off with an empty return string */
359 /* trap NULL parameters on entry */
360 if (( lpFile == NULL ) || ( lpResult == NULL ))
361 { /* FIXME - should throw a warning, perhaps! */
362 return 2; /* File not found. Close enough, I guess. */
365 if (lpDirectory)
366 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
367 SetCurrentDirectoryA( lpDirectory );
370 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
372 TRACE("returning %s\n", lpResult);
373 if (lpDirectory)
374 SetCurrentDirectoryA( old_dir );
375 return retval;
378 /*************************************************************************
379 * FindExecutableW [SHELL32.219]
381 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
382 LPWSTR lpResult)
384 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
385 return 31; /* default - 'No association was found' */
388 typedef struct
389 { LPCSTR szApp;
390 LPCSTR szOtherStuff;
391 HICON hIcon;
392 } ABOUT_INFO;
394 #define IDC_STATIC_TEXT 100
395 #define IDC_LISTBOX 99
396 #define IDC_WINE_TEXT 98
398 #define DROP_FIELD_TOP (-15)
399 #define DROP_FIELD_HEIGHT 15
401 extern HICON hIconTitleFont;
403 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
404 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
405 if( hWndCtl )
406 { GetWindowRect( hWndCtl, lprect );
407 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
408 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
409 return TRUE;
411 return FALSE;
414 /*************************************************************************
415 * SHAppBarMessage [SHELL32.207]
417 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
419 int width=data->rc.right - data->rc.left;
420 int height=data->rc.bottom - data->rc.top;
421 RECT rec=data->rc;
422 switch (msg)
423 { case ABM_GETSTATE:
424 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
425 case ABM_GETTASKBARPOS:
426 GetWindowRect(data->hWnd, &rec);
427 data->rc=rec;
428 return TRUE;
429 case ABM_ACTIVATE:
430 SetActiveWindow(data->hWnd);
431 return TRUE;
432 case ABM_GETAUTOHIDEBAR:
433 data->hWnd=GetActiveWindow();
434 return TRUE;
435 case ABM_NEW:
436 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
437 width,height,SWP_SHOWWINDOW);
438 return TRUE;
439 case ABM_QUERYPOS:
440 GetWindowRect(data->hWnd, &(data->rc));
441 return TRUE;
442 case ABM_REMOVE:
443 CloseHandle(data->hWnd);
444 return TRUE;
445 case ABM_SETAUTOHIDEBAR:
446 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
447 width,height,SWP_SHOWWINDOW);
448 return TRUE;
449 case ABM_SETPOS:
450 data->uEdge=(ABE_RIGHT | ABE_LEFT);
451 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
452 width,height,SWP_SHOWWINDOW);
453 return TRUE;
454 case ABM_WINDOWPOSCHANGED:
455 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
456 width,height,SWP_SHOWWINDOW);
457 return TRUE;
459 return FALSE;
462 /*************************************************************************
463 * SHHelpShortcuts_RunDLL [SHELL32.224]
466 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
467 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
468 dwArg1, dwArg2, dwArg3, dwArg4);
470 return 0;
473 /*************************************************************************
474 * SHLoadInProc [SHELL32.225]
475 * Create an instance of specified object class from within
476 * the shell process and release it immediately
479 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
481 IUnknown * pUnk = NULL;
482 TRACE("%s\n", debugstr_guid(rclsid));
484 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
485 if(pUnk)
487 IUnknown_Release(pUnk);
488 return NOERROR;
490 return DISP_E_MEMBERNOTFOUND;
493 /*************************************************************************
494 * ShellExecuteA [SHELL32.245]
496 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
497 LPCSTR lpFile, LPCSTR lpParameters,
498 LPCSTR lpDirectory, INT iShowCmd )
499 { TRACE("\n");
500 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
501 lpDirectory, iShowCmd );
504 /*************************************************************************
505 * ShellExecuteW [SHELL32.294]
506 * from shellapi.h
507 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
508 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
510 HINSTANCE WINAPI
511 ShellExecuteW(
512 HWND hwnd,
513 LPCWSTR lpOperation,
514 LPCWSTR lpFile,
515 LPCWSTR lpParameters,
516 LPCWSTR lpDirectory,
517 INT nShowCmd) {
519 FIXME(": stub\n");
520 return 0;
523 /*************************************************************************
524 * AboutDlgProc (internal)
526 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
527 LPARAM lParam )
528 { HWND hWndCtl;
529 char Template[512], AppTitle[512];
531 TRACE("\n");
533 switch(msg)
534 { case WM_INITDIALOG:
535 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
536 if (info)
537 { const char* const *pstr = SHELL_People;
538 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
539 GetWindowTextA( hWnd, Template, sizeof(Template) );
540 sprintf( AppTitle, Template, info->szApp );
541 SetWindowTextA( hWnd, AppTitle );
542 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
543 info->szOtherStuff );
544 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
545 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
546 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
547 while (*pstr)
548 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
549 pstr++;
551 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
554 return 1;
556 case WM_PAINT:
557 { RECT rect;
558 PAINTSTRUCT ps;
559 HDC hDC = BeginPaint( hWnd, &ps );
561 if( __get_dropline( hWnd, &rect ) ) {
562 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
563 MoveToEx( hDC, rect.left, rect.top, NULL );
564 LineTo( hDC, rect.right, rect.bottom );
566 EndPaint( hWnd, &ps );
568 break;
570 case WM_LBTRACKPOINT:
571 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
572 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
573 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
574 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
575 if( idx != -1 )
576 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
577 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
578 char* pstr = (char*)GlobalLock16( hMemObj );
580 if( pstr )
581 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
582 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
583 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
584 UpdateWindow( hWndCtl );
585 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
586 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
588 if( hMemObj )
589 GlobalFree16( hMemObj );
593 break;
595 case WM_QUERYDROPOBJECT:
596 if( wParam == 0 )
597 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
598 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
599 { RECT rect;
600 if( __get_dropline( hWnd, &rect ) )
601 { POINT pt;
602 pt.x=lpDragInfo->pt.x;
603 pt.x=lpDragInfo->pt.y;
604 rect.bottom += DROP_FIELD_HEIGHT;
605 if( PtInRect( &rect, pt ) )
606 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
607 return TRUE;
612 break;
614 case WM_DROPOBJECT:
615 if( wParam == hWnd )
616 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
617 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
618 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
619 if( pstr )
620 { static char __appendix_str[] = " with";
622 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
623 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
624 if( !strncmp( Template, "WINE", 4 ) )
625 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
626 else
627 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
628 *pch = '\0';
629 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
630 (WPARAM)-1, (LPARAM)Template );
633 strcpy( Template, pstr );
634 strcat( Template, __appendix_str );
635 SetWindowTextA( hWndCtl, Template );
636 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
637 return TRUE;
641 break;
643 case WM_COMMAND:
644 if (wParam == IDOK)
645 { EndDialog(hWnd, TRUE);
646 return TRUE;
648 break;
649 case WM_CLOSE:
650 EndDialog(hWnd, TRUE);
651 break;
654 return 0;
658 /*************************************************************************
659 * ShellAboutA [SHELL32.243]
661 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
662 HICON hIcon )
663 { ABOUT_INFO info;
664 HRSRC hRes;
665 LPVOID template;
666 TRACE("\n");
668 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
669 return FALSE;
670 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
671 return FALSE;
673 info.szApp = szApp;
674 info.szOtherStuff = szOtherStuff;
675 info.hIcon = hIcon;
676 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
677 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
678 template, hWnd, AboutDlgProc, (LPARAM)&info );
682 /*************************************************************************
683 * ShellAboutW [SHELL32.244]
685 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
686 HICON hIcon )
687 { BOOL ret;
688 ABOUT_INFO info;
689 HRSRC hRes;
690 LPVOID template;
692 TRACE("\n");
694 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
695 return FALSE;
696 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
697 return FALSE;
699 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
700 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
701 info.hIcon = hIcon;
702 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
703 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
704 template, hWnd, AboutDlgProc, (LPARAM)&info );
705 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
706 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
707 return ret;
710 /*************************************************************************
711 * FreeIconList
713 void WINAPI FreeIconList( DWORD dw )
714 { FIXME("(%lx): stub\n",dw);
717 /***********************************************************************
718 * DllGetVersion [SHELL32]
720 * Retrieves version information of the 'SHELL32.DLL'
722 * PARAMS
723 * pdvi [O] pointer to version information structure.
725 * RETURNS
726 * Success: S_OK
727 * Failure: E_INVALIDARG
729 * NOTES
730 * Returns version of a shell32.dll from IE4.01 SP1.
733 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
735 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
737 WARN("wrong DLLVERSIONINFO size from app");
738 return E_INVALIDARG;
741 pdvi->dwMajorVersion = 4;
742 pdvi->dwMinorVersion = 72;
743 pdvi->dwBuildNumber = 3110;
744 pdvi->dwPlatformID = 1;
746 TRACE("%lu.%lu.%lu.%lu\n",
747 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
748 pdvi->dwBuildNumber, pdvi->dwPlatformID);
750 return S_OK;
752 /***********************************************************************
753 * DllGetVersion [SHLWAPI]
755 * Retrieves version information of the 'SHLWAPI.DLL'
757 * PARAMS
758 * pdvi [O] pointer to version information structure.
760 * RETURNS
761 * Success: S_OK
762 * Failure: E_INVALIDARG
764 * NOTES
765 * Returns version of a SHLWAPI.dll from IE5.01.
768 HRESULT WINAPI SHLWAPI_DllGetVersion (DLLVERSIONINFO *pdvi)
770 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
772 WARN("wrong DLLVERSIONINFO size from app");
773 return E_INVALIDARG;
776 pdvi->dwMajorVersion = 5;
777 pdvi->dwMinorVersion = 0;
778 pdvi->dwBuildNumber = 2314;
779 pdvi->dwPlatformID = 1000;
781 TRACE("%lu.%lu.%lu.%lu\n",
782 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
783 pdvi->dwBuildNumber, pdvi->dwPlatformID);
785 return S_OK;
788 /*************************************************************************
789 * global variables of the shell32.dll
790 * all are once per process
793 void (WINAPI* pDLLInitComctl)(LPVOID);
794 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
795 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
796 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
797 BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
798 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
799 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
800 COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
802 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
803 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
805 HDPA (WINAPI* pDPA_Create) (INT);
806 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
807 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
808 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
809 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
810 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
811 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
813 /* user32 */
814 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
815 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
817 static HINSTANCE hComctl32;
818 static INT shell32_RefCount = 0;
820 LONG shell32_ObjCount = 0;
821 HINSTANCE shell32_hInstance = 0;
822 HINSTANCE shlwapi_hInstance = 0;
823 HMODULE huser32 = 0;
824 HIMAGELIST ShellSmallIconList = 0;
825 HIMAGELIST ShellBigIconList = 0;
827 /*************************************************************************
828 * SHELL32 LibMain
830 * NOTES
831 * calling oleinitialize here breaks sone apps.
834 BOOL WINAPI ShlwapiLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
836 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
837 switch (fdwReason)
839 case DLL_PROCESS_ATTACH:
840 shlwapi_hInstance = hinstDLL;
841 if(!huser32) huser32 = GetModuleHandleA("USER32.DLL");
843 if (!huser32)
845 ERR("hModule of USER32 is 0\n");
846 return FALSE;
848 break;
850 return TRUE;
853 /*************************************************************************
854 * SHELL32 LibMain
856 * NOTES
857 * calling oleinitialize here breaks sone apps.
860 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
862 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
864 switch (fdwReason)
866 case DLL_PROCESS_ATTACH:
867 shell32_RefCount++;
868 if (shell32_hInstance) return TRUE;
870 shell32_hInstance = hinstDLL;
871 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
872 if(!huser32) huser32 = GetModuleHandleA("USER32.DLL");
873 DisableThreadLibraryCalls(shell32_hInstance);
875 if (!hComctl32 || !huser32)
877 ERR("P A N I C SHELL32 loading failed\n");
878 return FALSE;
881 /* comctl32 */
882 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
883 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
884 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
885 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
886 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
887 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
888 pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
889 pImageList_SetBkColor=(void*)GetProcAddress(hComctl32,"ImageList_SetBkColor");
890 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
891 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
892 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
893 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
894 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
895 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
896 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
897 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
898 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
899 /* user32 */
900 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(huser32,"LookupIconIdFromDirectoryEx");
901 pCreateIconFromResourceEx=(void*)GetProcAddress(huser32,"CreateIconFromResourceEx");
903 /* initialize the common controls */
904 if (pDLLInitComctl)
906 pDLLInitComctl(NULL);
909 SIC_Initialize();
910 SYSTRAY_Init();
911 InitChangeNotifications();
912 SHInitRestricted(NULL, NULL);
913 break;
915 case DLL_THREAD_ATTACH:
916 shell32_RefCount++;
917 break;
919 case DLL_THREAD_DETACH:
920 shell32_RefCount--;
921 break;
923 case DLL_PROCESS_DETACH:
924 shell32_RefCount--;
926 if ( !shell32_RefCount )
928 shell32_hInstance = 0;
930 if (pdesktopfolder)
932 IShellFolder_Release(pdesktopfolder);
933 pdesktopfolder = NULL;
936 SIC_Destroy();
937 FreeChangeNotifications();
939 /* this one is here to check if AddRef/Release is balanced */
940 if (shell32_ObjCount)
942 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
946 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
947 break;
949 return TRUE;
952 /*************************************************************************
953 * DllInstall [SHELL32.202]
955 * PARAMETERS
957 * BOOL bInstall - TRUE for install, FALSE for uninstall
958 * LPCWSTR pszCmdLine - command line (unused by shell32?)
961 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
963 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
965 return S_OK; /* indicate success */