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.@]
534 * is the filename is not a file return 1
536 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
542 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
543 ret = ExtractIconA(hInstance,exefn,nIconIndex);
545 HeapFree(GetProcessHeap(),0,exefn);
549 /*************************************************************************
550 * FindExecutableA [SHELL32.@]
552 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
555 HINSTANCE retval=31; /* default - 'No association was found' */
558 TRACE("File %s, Dir %s\n",
559 (lpFile != NULL?lpFile:"-"),
560 (lpDirectory != NULL?lpDirectory:"-"));
562 lpResult[0]='\0'; /* Start off with an empty return string */
564 /* trap NULL parameters on entry */
565 if (( lpFile == NULL ) || ( lpResult == NULL ))
566 { /* FIXME - should throw a warning, perhaps! */
567 return 2; /* File not found. Close enough, I guess. */
571 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
572 SetCurrentDirectoryA( lpDirectory );
575 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
577 TRACE("returning %s\n", lpResult);
579 SetCurrentDirectoryA( old_dir );
583 /*************************************************************************
584 * FindExecutableW [SHELL32.@]
586 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
589 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
590 return 31; /* default - 'No association was found' */
599 #define IDC_STATIC_TEXT 100
600 #define IDC_LISTBOX 99
601 #define IDC_WINE_TEXT 98
603 #define DROP_FIELD_TOP (-15)
604 #define DROP_FIELD_HEIGHT 15
606 static HICON hIconTitleFont;
608 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
609 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
611 { GetWindowRect( hWndCtl, lprect );
612 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
613 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
619 /*************************************************************************
620 * SHAppBarMessage [SHELL32.@]
622 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
624 int width=data->rc.right - data->rc.left;
625 int height=data->rc.bottom - data->rc.top;
629 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
630 case ABM_GETTASKBARPOS:
631 GetWindowRect(data->hWnd, &rec);
635 SetActiveWindow(data->hWnd);
637 case ABM_GETAUTOHIDEBAR:
638 data->hWnd=GetActiveWindow();
641 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
642 width,height,SWP_SHOWWINDOW);
645 GetWindowRect(data->hWnd, &(data->rc));
648 FIXME("ABM_REMOVE broken\n");
649 /* FIXME: this is wrong; should it be DestroyWindow instead? */
650 /*CloseHandle(data->hWnd);*/
652 case ABM_SETAUTOHIDEBAR:
653 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
654 width,height,SWP_SHOWWINDOW);
657 data->uEdge=(ABE_RIGHT | ABE_LEFT);
658 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
659 width,height,SWP_SHOWWINDOW);
661 case ABM_WINDOWPOSCHANGED:
662 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
663 width,height,SWP_SHOWWINDOW);
669 /*************************************************************************
670 * SHHelpShortcuts_RunDLL [SHELL32.@]
673 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
674 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
675 dwArg1, dwArg2, dwArg3, dwArg4);
680 /*************************************************************************
681 * SHLoadInProc [SHELL32.@]
682 * Create an instance of specified object class from within
683 * the shell process and release it immediately
686 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
688 IUnknown * pUnk = NULL;
689 TRACE("%s\n", debugstr_guid(rclsid));
691 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
694 IUnknown_Release(pUnk);
697 return DISP_E_MEMBERNOTFOUND;
700 /*************************************************************************
701 * ShellExecuteA [SHELL32.290]
703 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
704 LPCSTR lpFile, LPCSTR lpParameters,
705 LPCSTR lpDirectory, INT iShowCmd )
707 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
708 lpDirectory, iShowCmd );
711 /*************************************************************************
712 * ShellExecuteW [SHELL32.294]
714 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
715 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
722 LPCWSTR lpParameters,
730 /*************************************************************************
731 * AboutDlgProc (internal)
733 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
736 char Template[512], AppTitle[512];
741 { case WM_INITDIALOG:
742 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
744 { const char* const *pstr = SHELL_People;
745 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
746 GetWindowTextA( hWnd, Template, sizeof(Template) );
747 sprintf( AppTitle, Template, info->szApp );
748 SetWindowTextA( hWnd, AppTitle );
749 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
750 info->szOtherStuff );
751 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
752 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
756 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
757 hIconTitleFont = CreateFontIndirectA( &logFont );
759 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
761 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
764 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
772 HDC hDC = BeginPaint( hWnd, &ps );
774 if( __get_dropline( hWnd, &rect ) ) {
775 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
776 MoveToEx( hDC, rect.left, rect.top, NULL );
777 LineTo( hDC, rect.right, rect.bottom );
779 EndPaint( hWnd, &ps );
783 #if 0 /* FIXME: should use DoDragDrop */
784 case WM_LBTRACKPOINT:
785 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
786 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
787 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
788 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
790 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
791 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
792 char* pstr = (char*)GlobalLock16( hMemObj );
795 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
796 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
797 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
798 UpdateWindow( hWndCtl );
799 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
800 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
803 GlobalFree16( hMemObj );
810 case WM_QUERYDROPOBJECT:
812 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
813 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
815 if( __get_dropline( hWnd, &rect ) )
817 pt.x=lpDragInfo->pt.x;
818 pt.x=lpDragInfo->pt.y;
819 rect.bottom += DROP_FIELD_HEIGHT;
820 if( PtInRect( &rect, pt ) )
821 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
831 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
832 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
833 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
835 { static char __appendix_str[] = " with";
837 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
838 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
839 if( !strncmp( Template, "WINE", 4 ) )
840 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
842 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
844 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
845 (WPARAM)-1, (LPARAM)Template );
848 strcpy( Template, pstr );
849 strcat( Template, __appendix_str );
850 SetWindowTextA( hWndCtl, Template );
851 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
860 { EndDialog(hWnd, TRUE);
865 EndDialog(hWnd, TRUE);
873 /*************************************************************************
874 * ShellAboutA [SHELL32.288]
876 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
883 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
885 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
889 info.szOtherStuff = szOtherStuff;
891 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
892 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
893 template, hWnd, AboutDlgProc, (LPARAM)&info );
897 /*************************************************************************
898 * ShellAboutW [SHELL32.289]
900 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
909 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
911 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
914 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
915 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
917 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
918 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
919 template, hWnd, AboutDlgProc, (LPARAM)&info );
920 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
921 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
925 /*************************************************************************
926 * FreeIconList (SHELL32.@)
928 void WINAPI FreeIconList( DWORD dw )
929 { FIXME("(%lx): stub\n",dw);
932 /***********************************************************************
933 * DllGetVersion [SHELL32.@]
935 * Retrieves version information of the 'SHELL32.DLL'
938 * pdvi [O] pointer to version information structure.
942 * Failure: E_INVALIDARG
945 * Returns version of a shell32.dll from IE4.01 SP1.
948 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
950 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
952 WARN("wrong DLLVERSIONINFO size from app\n");
956 pdvi->dwMajorVersion = 4;
957 pdvi->dwMinorVersion = 72;
958 pdvi->dwBuildNumber = 3110;
959 pdvi->dwPlatformID = 1;
961 TRACE("%lu.%lu.%lu.%lu\n",
962 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
963 pdvi->dwBuildNumber, pdvi->dwPlatformID);
967 /*************************************************************************
968 * global variables of the shell32.dll
969 * all are once per process
972 void WINAPI (*pDLLInitComctl)(LPVOID);
974 LPVOID WINAPI (*pCOMCTL32_Alloc) (INT);
975 BOOL WINAPI (*pCOMCTL32_Free) (LPVOID);
977 HDPA WINAPI (*pDPA_Create) (INT);
978 INT WINAPI (*pDPA_InsertPtr) (const HDPA, INT, LPVOID);
979 BOOL WINAPI (*pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
980 LPVOID WINAPI (*pDPA_GetPtr) (const HDPA, INT);
981 BOOL WINAPI (*pDPA_Destroy) (const HDPA);
982 INT WINAPI (*pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
983 LPVOID WINAPI (*pDPA_DeletePtr) (const HDPA hdpa, INT i);
984 HANDLE WINAPI (*pCreateMRUListA) (LPVOID lpcml);
985 DWORD WINAPI (*pFreeMRUListA) (HANDLE hMRUList);
986 INT WINAPI (*pAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
987 INT WINAPI (*pFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
988 INT WINAPI (*pEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
990 static HINSTANCE hComctl32;
992 LONG shell32_ObjCount = 0;
993 HINSTANCE shell32_hInstance = 0;
994 HIMAGELIST ShellSmallIconList = 0;
995 HIMAGELIST ShellBigIconList = 0;
998 /*************************************************************************
1002 * calling oleinitialize here breaks sone apps.
1005 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
1007 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
1011 case DLL_PROCESS_ATTACH:
1012 shell32_hInstance = hinstDLL;
1013 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
1014 DisableThreadLibraryCalls(shell32_hInstance);
1018 ERR("P A N I C SHELL32 loading failed\n");
1023 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
1024 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
1025 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
1026 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
1027 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
1028 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
1029 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
1030 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
1031 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
1032 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
1033 pCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
1034 pFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
1035 pAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
1036 pFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
1037 pEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
1039 /* initialize the common controls */
1042 pDLLInitComctl(NULL);
1047 InitChangeNotifications();
1048 SHInitRestricted(NULL, NULL);
1051 case DLL_THREAD_ATTACH:
1054 case DLL_THREAD_DETACH:
1057 case DLL_PROCESS_DETACH:
1058 shell32_hInstance = 0;
1062 IShellFolder_Release(pdesktopfolder);
1063 pdesktopfolder = NULL;
1067 FreeChangeNotifications();
1069 /* this one is here to check if AddRef/Release is balanced */
1070 if (shell32_ObjCount)
1072 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
1079 /*************************************************************************
1080 * DllInstall [SHELL32.@]
1084 * BOOL bInstall - TRUE for install, FALSE for uninstall
1085 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1088 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
1090 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1092 return S_OK; /* indicate success */
1095 /***********************************************************************
1096 * DllCanUnloadNow (SHELL32.@)
1098 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
1100 FIXME("(void): stub\n");