Missed the first character of every argument in CommandLineToArgv.
[wine.git] / dlls / shell32 / shell32_main.c
blobc7d5012493d17f0f7ebffc6cb0e7b94fb3078445
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 "debugtools.h"
19 #include "winreg.h"
20 #include "authors.h"
22 #include "shellapi.h"
23 #include "pidl.h"
25 #include "shell32_main.h"
26 #include "wine/undocshell.h"
27 #include "shlobj.h"
28 #include "shlguid.h"
29 #include "shlwapi.h"
31 DEFAULT_DEBUG_CHANNEL(shell);
33 #define MORE_DEBUG 1
34 /*************************************************************************
35 * CommandLineToArgvW [SHELL32.7]
37 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
38 { LPWSTR *argv,s,t;
39 int i;
40 TRACE("\n");
42 /* to get writeable copy */
43 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
44 s=cmdline;i=0;
45 while (*s)
46 { /* space */
47 if (*s==0x0020)
48 { i++;
49 s++;
50 while (*s && *s==0x0020)
51 s++;
52 continue;
54 s++;
56 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
57 s=t=cmdline;
58 i=0;
59 while (*s)
60 { if (*s==0x0020)
61 { *s=0;
62 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
63 *s=0x0020;
64 while (*s && *s==0x0020)
65 s++;
66 t=s;
67 continue;
69 s++;
71 if (*t)
72 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
74 HeapFree( GetProcessHeap(), 0, cmdline );
75 argv[i]=NULL;
76 *numargs=i;
77 return argv;
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,
101 UINT flags )
103 char szLoaction[MAX_PATH];
104 int iIndex;
105 DWORD ret = TRUE, dwAttributes = 0;
106 IShellFolder * psfParent = NULL;
107 IExtractIconA * pei = NULL;
108 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
109 HRESULT hr = S_OK;
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)))
115 return FALSE;
117 /* windows initializes this values regardless of the flags */
118 psfi->szDisplayName[0] = '\0';
119 psfi->szTypeName[0] = '\0';
120 psfi->iIcon = 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;
127 if (!pidl )
129 ERR("pidl is null!\n");
130 return FALSE;
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 */
140 if (pidl)
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));
162 else
164 STRRET str;
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);
176 /* ### icons ###*/
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 ))
189 UINT uDummy,uFlags;
190 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
192 if (SUCCEEDED(hr))
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);
199 else
200 ret = FALSE;
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];
212 char * szExt;
213 DWORD dwNr=0;
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 */
222 strcpy(sTemp, path);
224 /* FIXME: if sTemp contains a valid filename, get the icon
225 from there, index is in dwNr
227 psfi->iIcon = 2;
229 else /* default icon */
231 psfi->iIcon = 0;
234 else
236 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
237 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
239 ret = FALSE;
242 if (ret)
244 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
248 /* icon handle */
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");
259 if (psfParent)
260 IShellFolder_Release(psfParent);
262 if (hr != S_OK)
263 ret = FALSE;
265 if(pidlLast) SHFree(pidlLast);
266 #ifdef MORE_DEBUG
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);
269 #endif
270 return ret;
273 /*************************************************************************
274 * SHGetFileInfoW [SHELL32.@]
277 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
278 SHFILEINFOW *psfi, UINT sizeofpsfi,
279 UINT flags )
280 { FIXME("(%s,0x%lx,%p,0x%x,0x%x)\n",
281 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
282 return 0;
285 /*************************************************************************
286 * SHGetFileInfoAW [SHELL32.@]
288 DWORD WINAPI SHGetFileInfoAW(
289 LPCVOID path,
290 DWORD dwFileAttributes,
291 LPVOID psfi,
292 UINT sizeofpsfi,
293 UINT flags)
295 if(SHELL_OsIsUnicode())
296 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
297 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
300 /*************************************************************************
301 * ExtractIconA [SHELL32.133]
303 * fixme
304 * is the filename is not a file return 1
306 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
307 UINT nIconIndex )
308 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
309 TRACE("\n");
310 if( handle )
312 HICON16* ptr = (HICON16*)GlobalLock16(handle);
313 HICON16 hIcon = *ptr;
315 GlobalFree16(handle);
316 return hIcon;
318 return 0;
321 /*************************************************************************
322 * ExtractIconW [SHELL32.180]
324 * fixme
325 * is the filename is not a file return 1
327 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
328 UINT nIconIndex )
329 { LPSTR exefn;
330 HICON ret;
331 TRACE("\n");
333 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
334 ret = ExtractIconA(hInstance,exefn,nIconIndex);
336 HeapFree(GetProcessHeap(),0,exefn);
337 return ret;
340 /*************************************************************************
341 * FindExecutableA [SHELL32.184]
343 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
344 LPSTR lpResult )
345 { HINSTANCE retval=31; /* default - 'No association was found' */
346 char old_dir[1024];
348 TRACE("File %s, Dir %s\n",
349 (lpFile != NULL?lpFile:"-"),
350 (lpDirectory != NULL?lpDirectory:"-"));
352 lpResult[0]='\0'; /* Start off with an empty return string */
354 /* trap NULL parameters on entry */
355 if (( lpFile == NULL ) || ( lpResult == NULL ))
356 { /* FIXME - should throw a warning, perhaps! */
357 return 2; /* File not found. Close enough, I guess. */
360 if (lpDirectory)
361 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
362 SetCurrentDirectoryA( lpDirectory );
365 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
367 TRACE("returning %s\n", lpResult);
368 if (lpDirectory)
369 SetCurrentDirectoryA( old_dir );
370 return retval;
373 /*************************************************************************
374 * FindExecutableW [SHELL32.219]
376 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
377 LPWSTR lpResult)
379 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
380 return 31; /* default - 'No association was found' */
383 typedef struct
384 { LPCSTR szApp;
385 LPCSTR szOtherStuff;
386 HICON hIcon;
387 } ABOUT_INFO;
389 #define IDC_STATIC_TEXT 100
390 #define IDC_LISTBOX 99
391 #define IDC_WINE_TEXT 98
393 #define DROP_FIELD_TOP (-15)
394 #define DROP_FIELD_HEIGHT 15
396 extern HICON hIconTitleFont;
398 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
399 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
400 if( hWndCtl )
401 { GetWindowRect( hWndCtl, lprect );
402 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
403 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
404 return TRUE;
406 return FALSE;
409 /*************************************************************************
410 * SHAppBarMessage [SHELL32.207]
412 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
414 int width=data->rc.right - data->rc.left;
415 int height=data->rc.bottom - data->rc.top;
416 RECT rec=data->rc;
417 switch (msg)
418 { case ABM_GETSTATE:
419 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
420 case ABM_GETTASKBARPOS:
421 GetWindowRect(data->hWnd, &rec);
422 data->rc=rec;
423 return TRUE;
424 case ABM_ACTIVATE:
425 SetActiveWindow(data->hWnd);
426 return TRUE;
427 case ABM_GETAUTOHIDEBAR:
428 data->hWnd=GetActiveWindow();
429 return TRUE;
430 case ABM_NEW:
431 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
432 width,height,SWP_SHOWWINDOW);
433 return TRUE;
434 case ABM_QUERYPOS:
435 GetWindowRect(data->hWnd, &(data->rc));
436 return TRUE;
437 case ABM_REMOVE:
438 CloseHandle(data->hWnd);
439 return TRUE;
440 case ABM_SETAUTOHIDEBAR:
441 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
442 width,height,SWP_SHOWWINDOW);
443 return TRUE;
444 case ABM_SETPOS:
445 data->uEdge=(ABE_RIGHT | ABE_LEFT);
446 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
447 width,height,SWP_SHOWWINDOW);
448 return TRUE;
449 case ABM_WINDOWPOSCHANGED:
450 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
451 width,height,SWP_SHOWWINDOW);
452 return TRUE;
454 return FALSE;
457 /*************************************************************************
458 * SHHelpShortcuts_RunDLL [SHELL32.224]
461 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
462 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
463 dwArg1, dwArg2, dwArg3, dwArg4);
465 return 0;
468 /*************************************************************************
469 * SHLoadInProc [SHELL32.225]
470 * Create an instance of specified object class from within
471 * the shell process and release it immediately
474 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
476 IUnknown * pUnk = NULL;
477 TRACE("%s\n", debugstr_guid(rclsid));
479 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
480 if(pUnk)
482 IUnknown_Release(pUnk);
483 return NOERROR;
485 return DISP_E_MEMBERNOTFOUND;
488 /*************************************************************************
489 * ShellExecuteA [SHELL32.245]
491 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
492 LPCSTR lpFile, LPCSTR lpParameters,
493 LPCSTR lpDirectory, INT iShowCmd )
494 { TRACE("\n");
495 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
496 lpDirectory, iShowCmd );
499 /*************************************************************************
500 * ShellExecuteW [SHELL32.294]
501 * from shellapi.h
502 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
503 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
505 HINSTANCE WINAPI
506 ShellExecuteW(
507 HWND hwnd,
508 LPCWSTR lpOperation,
509 LPCWSTR lpFile,
510 LPCWSTR lpParameters,
511 LPCWSTR lpDirectory,
512 INT nShowCmd) {
514 FIXME(": stub\n");
515 return 0;
518 /*************************************************************************
519 * AboutDlgProc (internal)
521 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
522 LPARAM lParam )
523 { HWND hWndCtl;
524 char Template[512], AppTitle[512];
526 TRACE("\n");
528 switch(msg)
529 { case WM_INITDIALOG:
530 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
531 if (info)
532 { const char* const *pstr = SHELL_People;
533 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
534 GetWindowTextA( hWnd, Template, sizeof(Template) );
535 sprintf( AppTitle, Template, info->szApp );
536 SetWindowTextA( hWnd, AppTitle );
537 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
538 info->szOtherStuff );
539 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
540 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
541 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
542 while (*pstr)
543 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
544 pstr++;
546 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
549 return 1;
551 case WM_PAINT:
552 { RECT rect;
553 PAINTSTRUCT ps;
554 HDC hDC = BeginPaint( hWnd, &ps );
556 if( __get_dropline( hWnd, &rect ) ) {
557 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
558 MoveToEx( hDC, rect.left, rect.top, NULL );
559 LineTo( hDC, rect.right, rect.bottom );
561 EndPaint( hWnd, &ps );
563 break;
565 case WM_LBTRACKPOINT:
566 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
567 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
568 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
569 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
570 if( idx != -1 )
571 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
572 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
573 char* pstr = (char*)GlobalLock16( hMemObj );
575 if( pstr )
576 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
577 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
578 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
579 UpdateWindow( hWndCtl );
580 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
581 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
583 if( hMemObj )
584 GlobalFree16( hMemObj );
588 break;
590 case WM_QUERYDROPOBJECT:
591 if( wParam == 0 )
592 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
593 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
594 { RECT rect;
595 if( __get_dropline( hWnd, &rect ) )
596 { POINT pt;
597 pt.x=lpDragInfo->pt.x;
598 pt.x=lpDragInfo->pt.y;
599 rect.bottom += DROP_FIELD_HEIGHT;
600 if( PtInRect( &rect, pt ) )
601 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
602 return TRUE;
607 break;
609 case WM_DROPOBJECT:
610 if( wParam == hWnd )
611 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
612 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
613 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
614 if( pstr )
615 { static char __appendix_str[] = " with";
617 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
618 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
619 if( !strncmp( Template, "WINE", 4 ) )
620 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
621 else
622 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
623 *pch = '\0';
624 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
625 (WPARAM)-1, (LPARAM)Template );
628 strcpy( Template, pstr );
629 strcat( Template, __appendix_str );
630 SetWindowTextA( hWndCtl, Template );
631 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
632 return TRUE;
636 break;
638 case WM_COMMAND:
639 if (wParam == IDOK)
640 { EndDialog(hWnd, TRUE);
641 return TRUE;
643 break;
644 case WM_CLOSE:
645 EndDialog(hWnd, TRUE);
646 break;
649 return 0;
653 /*************************************************************************
654 * ShellAboutA [SHELL32.243]
656 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
657 HICON hIcon )
658 { ABOUT_INFO info;
659 HRSRC hRes;
660 LPVOID template;
661 TRACE("\n");
663 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
664 return FALSE;
665 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
666 return FALSE;
668 info.szApp = szApp;
669 info.szOtherStuff = szOtherStuff;
670 info.hIcon = hIcon;
671 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
672 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
673 template, hWnd, AboutDlgProc, (LPARAM)&info );
677 /*************************************************************************
678 * ShellAboutW [SHELL32.244]
680 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
681 HICON hIcon )
682 { BOOL ret;
683 ABOUT_INFO info;
684 HRSRC hRes;
685 LPVOID template;
687 TRACE("\n");
689 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
690 return FALSE;
691 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
692 return FALSE;
694 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
695 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
696 info.hIcon = hIcon;
697 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
698 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
699 template, hWnd, AboutDlgProc, (LPARAM)&info );
700 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
701 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
702 return ret;
705 /*************************************************************************
706 * FreeIconList
708 void WINAPI FreeIconList( DWORD dw )
709 { FIXME("(%lx): stub\n",dw);
712 /***********************************************************************
713 * DllGetVersion [SHELL32]
715 * Retrieves version information of the 'SHELL32.DLL'
717 * PARAMS
718 * pdvi [O] pointer to version information structure.
720 * RETURNS
721 * Success: S_OK
722 * Failure: E_INVALIDARG
724 * NOTES
725 * Returns version of a shell32.dll from IE4.01 SP1.
728 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
730 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
732 WARN("wrong DLLVERSIONINFO size from app");
733 return E_INVALIDARG;
736 pdvi->dwMajorVersion = 4;
737 pdvi->dwMinorVersion = 72;
738 pdvi->dwBuildNumber = 3110;
739 pdvi->dwPlatformID = 1;
741 TRACE("%lu.%lu.%lu.%lu\n",
742 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
743 pdvi->dwBuildNumber, pdvi->dwPlatformID);
745 return S_OK;
747 /*************************************************************************
748 * global variables of the shell32.dll
749 * all are once per process
752 void (WINAPI* pDLLInitComctl)(LPVOID);
753 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
754 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
755 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
756 BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
757 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
758 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
759 COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
761 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
762 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
764 HDPA (WINAPI* pDPA_Create) (INT);
765 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
766 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
767 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
768 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
769 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
770 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
772 /* user32 */
773 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
774 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
776 static HINSTANCE hComctl32;
777 static INT shell32_RefCount = 0;
779 LONG shell32_ObjCount = 0;
780 HINSTANCE shell32_hInstance = 0;
781 HMODULE huser32 = 0;
782 HIMAGELIST ShellSmallIconList = 0;
783 HIMAGELIST ShellBigIconList = 0;
786 /*************************************************************************
787 * SHELL32 LibMain
789 * NOTES
790 * calling oleinitialize here breaks sone apps.
793 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
795 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
797 switch (fdwReason)
799 case DLL_PROCESS_ATTACH:
800 shell32_RefCount++;
801 if (shell32_hInstance) return TRUE;
803 shell32_hInstance = hinstDLL;
804 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
805 if(!huser32) huser32 = GetModuleHandleA("USER32.DLL");
806 DisableThreadLibraryCalls(shell32_hInstance);
808 if (!hComctl32 || !huser32)
810 ERR("P A N I C SHELL32 loading failed\n");
811 return FALSE;
814 /* comctl32 */
815 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
816 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
817 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
818 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
819 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
820 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
821 pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
822 pImageList_SetBkColor=(void*)GetProcAddress(hComctl32,"ImageList_SetBkColor");
823 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
824 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
825 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
826 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
827 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
828 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
829 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
830 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
831 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
832 /* user32 */
833 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(huser32,"LookupIconIdFromDirectoryEx");
834 pCreateIconFromResourceEx=(void*)GetProcAddress(huser32,"CreateIconFromResourceEx");
836 /* initialize the common controls */
837 if (pDLLInitComctl)
839 pDLLInitComctl(NULL);
842 SIC_Initialize();
843 SYSTRAY_Init();
844 InitChangeNotifications();
845 SHInitRestricted(NULL, NULL);
846 break;
848 case DLL_THREAD_ATTACH:
849 shell32_RefCount++;
850 break;
852 case DLL_THREAD_DETACH:
853 shell32_RefCount--;
854 break;
856 case DLL_PROCESS_DETACH:
857 shell32_RefCount--;
859 if ( !shell32_RefCount )
861 shell32_hInstance = 0;
863 if (pdesktopfolder)
865 IShellFolder_Release(pdesktopfolder);
866 pdesktopfolder = NULL;
869 SIC_Destroy();
870 FreeChangeNotifications();
872 /* this one is here to check if AddRef/Release is balanced */
873 if (shell32_ObjCount)
875 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
879 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
880 break;
882 return TRUE;
885 /*************************************************************************
886 * DllInstall [SHELL32.202]
888 * PARAMETERS
890 * BOOL bInstall - TRUE for install, FALSE for uninstall
891 * LPCWSTR pszCmdLine - command line (unused by shell32?)
894 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
896 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
898 return S_OK; /* indicate success */
901 /***********************************************************************
902 * DllCanUnloadNow (SHELL32.@)
904 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
906 FIXME("(void): stub\n");
908 return S_FALSE;