5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
23 #include "undocshell.h"
24 #include "wine/winuser16.h"
28 #include "shell32_main.h"
30 #include "debugtools.h"
32 DEFAULT_DEBUG_CHANNEL(shell);
35 /*************************************************************************
36 * CommandLineToArgvW [SHELL32.@]
38 * We must interpret the quotes in the command line to rebuild the argv
40 * - arguments are separated by spaces or tabs
41 * - quotes serve as optional argument delimiters
43 * - escaped quotes must be converted back to '"'
45 * - an odd number of '\'s followed by '"' correspond to half that number
46 * of '\' followed by a '"' (extension of the above)
49 * - an even number of '\'s followed by a '"' correspond to half that number
50 * of '\', plus a regular quote serving as an argument delimiter (which
51 * means it does not appear in the result)
52 * 'a\\"b c"' -> 'a\b c'
53 * 'a\\\\"b c"' -> 'a\\b c'
54 * - '\' that are not followed by a '"' are copied literally
64 LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
75 /* Return the path to the executable */
82 hargv=GlobalReAlloc(hargv, size, 0);
83 argv=GlobalLock(hargv);
84 } while (GetModuleFileNameW((HMODULE)0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)) == 0);
85 argv[0]=(LPWSTR)(argv+1);
92 /* to get a writeable copy */
98 if (*cs==0 || ((*cs==0x0009 || *cs==0x0020) && !in_quotes)) {
101 /* skip the remaining spaces */
102 while (*cs==0x0009 || *cs==0x0020) {
109 } else if (*cs==0x005c) {
110 /* '\', count them */
112 } else if ((*cs==0x0022) && ((bcount & 1)==0)) {
114 in_quotes=!in_quotes;
117 /* a regular character */
122 /* Allocate in a single lump, the string array, and the strings that go with it.
123 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
125 hargv=GlobalAlloc(0, argc*sizeof(LPWSTR)+(strlenW(lpCmdline)+1)*sizeof(WCHAR));
126 argv=GlobalLock(hargv);
129 cmdline=(LPWSTR)(argv+argc);
130 strcpyW(cmdline, lpCmdline);
137 if ((*s==0x0009 || *s==0x0020) && !in_quotes) {
138 /* Close the argument and copy it */
142 /* skip the remaining spaces */
145 } while (*s==0x0009 || *s==0x0020);
147 /* Start with a new argument */
150 } else if (*s==0x005c) {
154 } else if (*s==0x0022) {
156 if ((bcount & 1)==0) {
157 /* Preceeded by an even number of '\', this is half that
158 * number of '\', plus a quote which we erase.
161 in_quotes=!in_quotes;
164 /* Preceeded by an odd number of '\', this is half that
165 * number of '\' followed by a '"'
173 /* a regular character */
188 /*************************************************************************
189 * SHGetFileInfoA [SHELL32.@]
193 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
194 SHFILEINFOA *psfi, UINT sizeofpsfi,
197 char szLoaction[MAX_PATH];
199 DWORD ret = TRUE, dwAttributes = 0;
200 IShellFolder * psfParent = NULL;
201 IExtractIconA * pei = NULL;
202 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
204 BOOL IconNotYetLoaded=TRUE;
206 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
207 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
209 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
212 /* windows initializes this values regardless of the flags */
213 psfi->szDisplayName[0] = '\0';
214 psfi->szTypeName[0] = '\0';
217 if (flags & SHGFI_EXETYPE) {
221 IMAGE_DOS_HEADER mz_header;
226 if (flags != SHGFI_EXETYPE) return 0;
228 status = GetBinaryTypeA (path, &BinaryType);
229 if (!status) return 0;
230 if ((BinaryType == SCS_DOS_BINARY)
231 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
233 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
234 NULL, OPEN_EXISTING, 0, 0 );
235 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
237 /* The next section is adapted from MODULE_GetBinaryType, as we need
238 * to examine the image header to get OS and version information. We
239 * know from calling GetBinaryTypeA that the image is valid and either
240 * an NE or PE, so much error handling can be omitted.
241 * Seek to the start of the file and read the header information.
244 SetFilePointer( hfile, 0, NULL, SEEK_SET );
245 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
247 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
248 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
249 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
251 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
252 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
253 CloseHandle( hfile );
254 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
255 return IMAGE_NT_SIGNATURE
256 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
257 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
259 return IMAGE_NT_SIGNATURE;
261 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
264 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
265 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
266 CloseHandle( hfile );
267 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
268 | (ne.ne_expver << 16);
271 CloseHandle( hfile );
276 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
277 the pidl functions fail on not existing file names */
278 if (flags & SHGFI_PIDL)
280 pidl = (LPCITEMIDLIST) path;
283 ERR("pidl is null!\n");
287 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
289 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
290 /* note: the attributes in ISF::ParseDisplayName are not implemented */
293 /* get the parent shellfolder */
296 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
299 /* get the attributes of the child */
300 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
302 if (!(flags & SHGFI_ATTR_SPECIFIED))
304 psfi->dwAttributes = 0xffffffff;
306 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
309 /* get the displayname */
310 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
312 if (flags & SHGFI_USEFILEATTRIBUTES)
314 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
319 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
320 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
324 /* get the type name */
325 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
327 if (!(flags & SHGFI_USEFILEATTRIBUTES))
328 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
332 strcpy(sTemp,PathFindExtensionA(path));
333 if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
334 && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
336 lstrcpynA (psfi->szTypeName, sTemp, 80 - 6);
337 strcat (psfi->szTypeName, "-file");
343 if (flags & SHGFI_LINKOVERLAY)
344 FIXME("set icon to link, stub\n");
346 if (flags & SHGFI_SELECTED)
347 FIXME("set icon to selected, stub\n");
349 if (flags & SHGFI_SHELLICONSIZE)
350 FIXME("set icon to shell size, stub\n");
352 /* get the iconlocation */
353 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
356 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
360 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
361 /* FIXME what to do with the index? */
363 if(uFlags != GIL_NOTFILENAME)
364 strcpy (psfi->szDisplayName, szLoaction);
368 IExtractIconA_Release(pei);
372 /* get icon index (or load icon)*/
373 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
376 if (flags & SHGFI_USEFILEATTRIBUTES)
378 char sTemp [MAX_PATH];
382 lstrcpynA(sTemp, path, MAX_PATH);
383 szExt = (LPSTR) PathFindExtensionA(sTemp);
384 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
385 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
387 if (!strcmp("%1",sTemp)) /* icon is in the file */
391 IconNotYetLoaded=FALSE;
394 PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXICON),
395 GetSystemMetrics(SM_CYICON),
398 PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXSMICON),
399 GetSystemMetrics(SM_CYSMICON),
402 else /* default icon */
409 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
410 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
417 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
422 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
423 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
425 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
426 FIXME("unknown attribute!\n");
429 IShellFolder_Release(psfParent);
434 if(pidlLast) SHFree(pidlLast);
436 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
437 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
442 /*************************************************************************
443 * SHGetFileInfoW [SHELL32.@]
446 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
447 SHFILEINFOW *psfi, UINT sizeofpsfi,
453 SHFILEINFOA temppsfi;
455 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
456 temppath = HeapAlloc(GetProcessHeap(), 0, len);
457 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
459 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
460 sizeof(temppsfi.szDisplayName), NULL, NULL);
461 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
462 sizeof(temppsfi.szTypeName), NULL, NULL);
464 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
466 HeapFree(GetProcessHeap(), 0, temppath);
471 /*************************************************************************
472 * SHGetFileInfo [SHELL32.@]
474 DWORD WINAPI SHGetFileInfoAW(
476 DWORD dwFileAttributes,
481 if(SHELL_OsIsUnicode())
482 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
483 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
486 /*************************************************************************
487 * DuplicateIcon [SHELL32.@]
489 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
494 TRACE("(%04x, %04x)\n", hInstance, hIcon);
496 if(GetIconInfo(hIcon, &IconInfo))
498 hDupIcon = CreateIconIndirect(&IconInfo);
500 /* clean up hbmMask and hbmColor */
501 DeleteObject(IconInfo.hbmMask);
502 DeleteObject(IconInfo.hbmColor);
509 /*************************************************************************
510 * ExtractIconA [SHELL32.@]
513 * if the filename is not a file return 1
515 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
517 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
521 HICON16* ptr = (HICON16*)GlobalLock16(handle);
522 HICON16 hIcon = *ptr;
524 GlobalFree16(handle);
530 /*************************************************************************
531 * ExtractIconW [SHELL32.@]
533 * FIXME: if the filename is not a file return 1
535 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
541 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
542 ret = ExtractIconA(hInstance,exefn,nIconIndex);
544 HeapFree(GetProcessHeap(),0,exefn);
548 /*************************************************************************
549 * FindExecutableA [SHELL32.@]
551 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
554 HINSTANCE retval=31; /* default - 'No association was found' */
557 TRACE("File %s, Dir %s\n",
558 (lpFile != NULL?lpFile:"-"),
559 (lpDirectory != NULL?lpDirectory:"-"));
561 lpResult[0]='\0'; /* Start off with an empty return string */
563 /* trap NULL parameters on entry */
564 if (( lpFile == NULL ) || ( lpResult == NULL ))
565 { /* FIXME - should throw a warning, perhaps! */
566 return 2; /* File not found. Close enough, I guess. */
570 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
571 SetCurrentDirectoryA( lpDirectory );
574 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
576 TRACE("returning %s\n", lpResult);
578 SetCurrentDirectoryA( old_dir );
582 /*************************************************************************
583 * FindExecutableW [SHELL32.@]
585 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
588 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
589 return 31; /* default - 'No association was found' */
598 #define IDC_STATIC_TEXT 100
599 #define IDC_LISTBOX 99
600 #define IDC_WINE_TEXT 98
602 #define DROP_FIELD_TOP (-15)
603 #define DROP_FIELD_HEIGHT 15
605 static HICON hIconTitleFont;
607 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
608 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
610 { GetWindowRect( hWndCtl, lprect );
611 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
612 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
618 /*************************************************************************
619 * SHAppBarMessage [SHELL32.@]
621 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
623 int width=data->rc.right - data->rc.left;
624 int height=data->rc.bottom - data->rc.top;
628 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
629 case ABM_GETTASKBARPOS:
630 GetWindowRect(data->hWnd, &rec);
634 SetActiveWindow(data->hWnd);
636 case ABM_GETAUTOHIDEBAR:
637 data->hWnd=GetActiveWindow();
640 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
641 width,height,SWP_SHOWWINDOW);
644 GetWindowRect(data->hWnd, &(data->rc));
647 FIXME("ABM_REMOVE broken\n");
648 /* FIXME: this is wrong; should it be DestroyWindow instead? */
649 /*CloseHandle(data->hWnd);*/
651 case ABM_SETAUTOHIDEBAR:
652 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
653 width,height,SWP_SHOWWINDOW);
656 data->uEdge=(ABE_RIGHT | ABE_LEFT);
657 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
658 width,height,SWP_SHOWWINDOW);
660 case ABM_WINDOWPOSCHANGED:
661 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
662 width,height,SWP_SHOWWINDOW);
668 /*************************************************************************
669 * SHHelpShortcuts_RunDLL [SHELL32.@]
672 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
673 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
674 dwArg1, dwArg2, dwArg3, dwArg4);
679 /*************************************************************************
680 * SHLoadInProc [SHELL32.@]
681 * Create an instance of specified object class from within
682 * the shell process and release it immediately
685 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
687 IUnknown * pUnk = NULL;
688 TRACE("%s\n", debugstr_guid(rclsid));
690 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
693 IUnknown_Release(pUnk);
696 return DISP_E_MEMBERNOTFOUND;
699 /*************************************************************************
700 * ShellExecuteA [SHELL32.290]
702 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
703 LPCSTR lpFile, LPCSTR lpParameters,
704 LPCSTR lpDirectory, INT iShowCmd )
706 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
707 lpDirectory, iShowCmd );
710 /*************************************************************************
711 * ShellExecuteW [SHELL32.294]
713 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
714 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
721 LPCWSTR lpParameters,
729 /*************************************************************************
730 * AboutDlgProc (internal)
732 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
735 char Template[512], AppTitle[512];
740 { case WM_INITDIALOG:
741 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
743 { const char* const *pstr = SHELL_People;
744 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
745 GetWindowTextA( hWnd, Template, sizeof(Template) );
746 sprintf( AppTitle, Template, info->szApp );
747 SetWindowTextA( hWnd, AppTitle );
748 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
749 info->szOtherStuff );
750 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
751 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
755 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
756 hIconTitleFont = CreateFontIndirectA( &logFont );
758 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
760 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
763 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
771 HDC hDC = BeginPaint( hWnd, &ps );
773 if( __get_dropline( hWnd, &rect ) ) {
774 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
775 MoveToEx( hDC, rect.left, rect.top, NULL );
776 LineTo( hDC, rect.right, rect.bottom );
778 EndPaint( hWnd, &ps );
782 #if 0 /* FIXME: should use DoDragDrop */
783 case WM_LBTRACKPOINT:
784 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
785 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
786 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
787 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
789 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
790 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
791 char* pstr = (char*)GlobalLock16( hMemObj );
794 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
795 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
796 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
797 UpdateWindow( hWndCtl );
798 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
799 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
802 GlobalFree16( hMemObj );
809 case WM_QUERYDROPOBJECT:
811 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
812 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
814 if( __get_dropline( hWnd, &rect ) )
816 pt.x=lpDragInfo->pt.x;
817 pt.x=lpDragInfo->pt.y;
818 rect.bottom += DROP_FIELD_HEIGHT;
819 if( PtInRect( &rect, pt ) )
820 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
830 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
831 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
832 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
834 { static char __appendix_str[] = " with";
836 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
837 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
838 if( !strncmp( Template, "WINE", 4 ) )
839 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
841 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
843 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
844 (WPARAM)-1, (LPARAM)Template );
847 strcpy( Template, pstr );
848 strcat( Template, __appendix_str );
849 SetWindowTextA( hWndCtl, Template );
850 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
859 { EndDialog(hWnd, TRUE);
864 EndDialog(hWnd, TRUE);
872 /*************************************************************************
873 * ShellAboutA [SHELL32.288]
875 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
882 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
884 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
888 info.szOtherStuff = szOtherStuff;
890 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
891 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
892 template, hWnd, AboutDlgProc, (LPARAM)&info );
896 /*************************************************************************
897 * ShellAboutW [SHELL32.289]
899 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
908 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
910 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
913 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
914 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
916 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
917 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
918 template, hWnd, AboutDlgProc, (LPARAM)&info );
919 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
920 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
924 /*************************************************************************
925 * FreeIconList (SHELL32.@)
927 void WINAPI FreeIconList( DWORD dw )
928 { FIXME("(%lx): stub\n",dw);
931 /***********************************************************************
932 * DllGetVersion [SHELL32.@]
934 * Retrieves version information of the 'SHELL32.DLL'
937 * pdvi [O] pointer to version information structure.
941 * Failure: E_INVALIDARG
944 * Returns version of a shell32.dll from IE4.01 SP1.
947 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
949 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
951 WARN("wrong DLLVERSIONINFO size from app\n");
955 pdvi->dwMajorVersion = 4;
956 pdvi->dwMinorVersion = 72;
957 pdvi->dwBuildNumber = 3110;
958 pdvi->dwPlatformID = 1;
960 TRACE("%lu.%lu.%lu.%lu\n",
961 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
962 pdvi->dwBuildNumber, pdvi->dwPlatformID);
966 /*************************************************************************
967 * global variables of the shell32.dll
968 * all are once per process
971 void (WINAPI *pDLLInitComctl)(LPVOID);
973 LPVOID (WINAPI *pCOMCTL32_Alloc) (INT);
974 BOOL (WINAPI *pCOMCTL32_Free) (LPVOID);
976 HDPA (WINAPI *pDPA_Create) (INT);
977 INT (WINAPI *pDPA_InsertPtr) (const HDPA, INT, LPVOID);
978 BOOL (WINAPI *pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
979 LPVOID (WINAPI *pDPA_GetPtr) (const HDPA, INT);
980 BOOL (WINAPI *pDPA_Destroy) (const HDPA);
981 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
982 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
983 HANDLE (WINAPI *pCreateMRUListA) (LPVOID lpcml);
984 DWORD (WINAPI *pFreeMRUListA) (HANDLE hMRUList);
985 INT (WINAPI *pAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
986 INT (WINAPI *pFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
987 INT (WINAPI *pEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
989 static HINSTANCE hComctl32;
991 LONG shell32_ObjCount = 0;
992 HINSTANCE shell32_hInstance = 0;
993 HIMAGELIST ShellSmallIconList = 0;
994 HIMAGELIST ShellBigIconList = 0;
997 /*************************************************************************
1001 * calling oleinitialize here breaks sone apps.
1004 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
1006 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
1010 case DLL_PROCESS_ATTACH:
1011 shell32_hInstance = hinstDLL;
1012 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
1013 DisableThreadLibraryCalls(shell32_hInstance);
1017 ERR("P A N I C SHELL32 loading failed\n");
1022 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
1023 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
1024 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
1025 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
1026 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
1027 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
1028 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
1029 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
1030 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
1031 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
1032 pCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
1033 pFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
1034 pAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
1035 pFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
1036 pEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
1038 /* initialize the common controls */
1041 pDLLInitComctl(NULL);
1046 InitChangeNotifications();
1047 SHInitRestricted(NULL, NULL);
1050 case DLL_THREAD_ATTACH:
1053 case DLL_THREAD_DETACH:
1056 case DLL_PROCESS_DETACH:
1057 shell32_hInstance = 0;
1061 IShellFolder_Release(pdesktopfolder);
1062 pdesktopfolder = NULL;
1066 FreeChangeNotifications();
1068 /* this one is here to check if AddRef/Release is balanced */
1069 if (shell32_ObjCount)
1071 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
1078 /*************************************************************************
1079 * DllInstall [SHELL32.@]
1083 * BOOL bInstall - TRUE for install, FALSE for uninstall
1084 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1087 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
1089 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1091 return S_OK; /* indicate success */
1094 /***********************************************************************
1095 * DllCanUnloadNow (SHELL32.@)
1097 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
1099 FIXME("(void): stub\n");