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
;
205 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
206 (flags
& SHGFI_PIDL
)? "pidl" : path
, dwFileAttributes
, psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
208 if ((flags
& SHGFI_USEFILEATTRIBUTES
) && (flags
& (SHGFI_ATTRIBUTES
|SHGFI_EXETYPE
|SHGFI_PIDL
)))
211 /* windows initializes this values regardless of the flags */
212 psfi
->szDisplayName
[0] = '\0';
213 psfi
->szTypeName
[0] = '\0';
216 if (flags
& SHGFI_EXETYPE
) {
220 IMAGE_DOS_HEADER mz_header
;
225 if (flags
!= SHGFI_EXETYPE
) return 0;
227 status
= GetBinaryTypeA (path
, &BinaryType
);
228 if (!status
) return 0;
229 if ((BinaryType
== SCS_DOS_BINARY
)
230 || (BinaryType
== SCS_PIF_BINARY
)) return 0x4d5a;
232 hfile
= CreateFileA( path
, GENERIC_READ
, FILE_SHARE_READ
,
233 NULL
, OPEN_EXISTING
, 0, 0 );
234 if ( hfile
== INVALID_HANDLE_VALUE
) return 0;
236 /* The next section is adapted from MODULE_GetBinaryType, as we need
237 * to examine the image header to get OS and version information. We
238 * know from calling GetBinaryTypeA that the image is valid and either
239 * an NE or PE, so much error handling can be omitted.
240 * Seek to the start of the file and read the header information.
243 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
244 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
246 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
247 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
248 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
250 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
251 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
252 CloseHandle( hfile
);
253 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
) {
254 return IMAGE_NT_SIGNATURE
255 | (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24)
256 | (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
258 return IMAGE_NT_SIGNATURE
;
260 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
263 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
264 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
265 CloseHandle( hfile
);
266 if (ne
.ne_exetyp
== 2) return IMAGE_OS2_SIGNATURE
267 | (ne
.ne_expver
<< 16);
270 CloseHandle( hfile
);
275 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
276 the pidl functions fail on not existing file names */
277 if (flags
& SHGFI_PIDL
)
279 pidl
= (LPCITEMIDLIST
) path
;
282 ERR("pidl is null!\n");
286 else if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
288 hr
= SHILCreateFromPathA ( path
, &pidl
, &dwAttributes
);
289 /* note: the attributes in ISF::ParseDisplayName are not implemented */
292 /* get the parent shellfolder */
295 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
, &pidlLast
);
298 /* get the attributes of the child */
299 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
301 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
303 psfi
->dwAttributes
= 0xffffffff;
305 IShellFolder_GetAttributesOf(psfParent
, 1 , &pidlLast
, &(psfi
->dwAttributes
));
308 /* get the displayname */
309 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
311 if (flags
& SHGFI_USEFILEATTRIBUTES
)
313 strcpy (psfi
->szDisplayName
, PathFindFileNameA(path
));
318 hr
= IShellFolder_GetDisplayNameOf(psfParent
, pidlLast
, SHGDN_INFOLDER
, &str
);
319 StrRetToStrNA (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
323 /* get the type name */
324 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
326 _ILGetFileType(pidlLast
, psfi
->szTypeName
, 80);
330 if (flags
& SHGFI_LINKOVERLAY
)
331 FIXME("set icon to link, stub\n");
333 if (flags
& SHGFI_SELECTED
)
334 FIXME("set icon to selected, stub\n");
336 if (flags
& SHGFI_SHELLICONSIZE
)
337 FIXME("set icon to shell size, stub\n");
339 /* get the iconlocation */
340 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
343 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1, &pidlLast
, &IID_IExtractIconA
, &uDummy
, (LPVOID
*)&pei
);
347 hr
= IExtractIconA_GetIconLocation(pei
, (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0,szLoaction
, MAX_PATH
, &iIndex
, &uFlags
);
348 /* fixme what to do with the index? */
350 if(uFlags
!= GIL_NOTFILENAME
)
351 strcpy (psfi
->szDisplayName
, szLoaction
);
355 IExtractIconA_Release(pei
);
359 /* get icon index (or load icon)*/
360 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
362 if (flags
& SHGFI_USEFILEATTRIBUTES
)
364 char sTemp
[MAX_PATH
];
368 lstrcpynA(sTemp
, path
, MAX_PATH
);
369 szExt
= (LPSTR
) PathFindExtensionA(sTemp
);
370 if( szExt
&& HCR_MapTypeToValue(szExt
, sTemp
, MAX_PATH
, TRUE
)
371 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
373 if (!strcmp("%1",sTemp
)) /* icon is in the file */
377 /* FIXME: if sTemp contains a valid filename, get the icon
378 from there, index is in dwNr
382 else /* default icon */
389 if (!(PidlToSicIndex(psfParent
, pidlLast
, (flags
& SHGFI_LARGEICON
),
390 (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0, &(psfi
->iIcon
))))
397 ret
= (DWORD
) ((flags
& SHGFI_LARGEICON
) ? ShellBigIconList
: ShellSmallIconList
);
402 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
))
403 psfi
->hIcon
= ImageList_GetIcon((flags
& SHGFI_LARGEICON
) ? ShellBigIconList
:ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
405 if (flags
& (SHGFI_UNKNOWN1
| SHGFI_UNKNOWN2
| SHGFI_UNKNOWN3
))
406 FIXME("unknown attribute!\n");
409 IShellFolder_Release(psfParent
);
414 if(pidlLast
) SHFree(pidlLast
);
416 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
417 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
, psfi
->szDisplayName
, psfi
->szTypeName
, ret
);
422 /*************************************************************************
423 * SHGetFileInfoW [SHELL32.@]
426 DWORD WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
427 SHFILEINFOW
*psfi
, UINT sizeofpsfi
,
433 SHFILEINFOA temppsfi
;
435 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, NULL
, 0, NULL
, NULL
);
436 temppath
= HeapAlloc(GetProcessHeap(), 0, len
);
437 WideCharToMultiByte(CP_ACP
, 0, path
, -1, temppath
, len
, NULL
, NULL
);
439 WideCharToMultiByte(CP_ACP
, 0, psfi
->szDisplayName
, -1, temppsfi
.szDisplayName
,
440 sizeof(temppsfi
.szDisplayName
), NULL
, NULL
);
441 WideCharToMultiByte(CP_ACP
, 0, psfi
->szTypeName
, -1, temppsfi
.szTypeName
,
442 sizeof(temppsfi
.szTypeName
), NULL
, NULL
);
444 ret
= SHGetFileInfoA(temppath
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
446 HeapFree(GetProcessHeap(), 0, temppath
);
451 /*************************************************************************
452 * SHGetFileInfo [SHELL32.@]
454 DWORD WINAPI
SHGetFileInfoAW(
456 DWORD dwFileAttributes
,
461 if(SHELL_OsIsUnicode())
462 return SHGetFileInfoW(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
463 return SHGetFileInfoA(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
466 /*************************************************************************
467 * DuplicateIcon [SHELL32.@]
469 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
474 TRACE("(%04x, %04x)\n", hInstance
, hIcon
);
476 if(GetIconInfo(hIcon
, &IconInfo
))
478 hDupIcon
= CreateIconIndirect(&IconInfo
);
480 /* clean up hbmMask and hbmColor */
481 DeleteObject(IconInfo
.hbmMask
);
482 DeleteObject(IconInfo
.hbmColor
);
489 /*************************************************************************
490 * ExtractIconA [SHELL32.@]
493 * if the filename is not a file return 1
495 HICON WINAPI
ExtractIconA( HINSTANCE hInstance
, LPCSTR lpszExeFileName
,
497 { HGLOBAL16 handle
= InternalExtractIcon16(hInstance
,lpszExeFileName
,nIconIndex
, 1);
501 HICON16
* ptr
= (HICON16
*)GlobalLock16(handle
);
502 HICON16 hIcon
= *ptr
;
504 GlobalFree16(handle
);
510 /*************************************************************************
511 * ExtractIconW [SHELL32.@]
514 * is the filename is not a file return 1
516 HICON WINAPI
ExtractIconW( HINSTANCE hInstance
, LPCWSTR lpszExeFileName
,
522 exefn
= HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName
);
523 ret
= ExtractIconA(hInstance
,exefn
,nIconIndex
);
525 HeapFree(GetProcessHeap(),0,exefn
);
529 /*************************************************************************
530 * FindExecutableA [SHELL32.@]
532 HINSTANCE WINAPI
FindExecutableA( LPCSTR lpFile
, LPCSTR lpDirectory
,
535 HINSTANCE retval
=31; /* default - 'No association was found' */
538 TRACE("File %s, Dir %s\n",
539 (lpFile
!= NULL
?lpFile
:"-"),
540 (lpDirectory
!= NULL
?lpDirectory
:"-"));
542 lpResult
[0]='\0'; /* Start off with an empty return string */
544 /* trap NULL parameters on entry */
545 if (( lpFile
== NULL
) || ( lpResult
== NULL
))
546 { /* FIXME - should throw a warning, perhaps! */
547 return 2; /* File not found. Close enough, I guess. */
551 { GetCurrentDirectoryA( sizeof(old_dir
), old_dir
);
552 SetCurrentDirectoryA( lpDirectory
);
555 retval
= SHELL_FindExecutable( lpFile
, "open", lpResult
);
557 TRACE("returning %s\n", lpResult
);
559 SetCurrentDirectoryA( old_dir
);
563 /*************************************************************************
564 * FindExecutableW [SHELL32.@]
566 HINSTANCE WINAPI
FindExecutableW(LPCWSTR lpFile
, LPCWSTR lpDirectory
,
569 FIXME("(%p,%p,%p): stub\n", lpFile
, lpDirectory
, lpResult
);
570 return 31; /* default - 'No association was found' */
579 #define IDC_STATIC_TEXT 100
580 #define IDC_LISTBOX 99
581 #define IDC_WINE_TEXT 98
583 #define DROP_FIELD_TOP (-15)
584 #define DROP_FIELD_HEIGHT 15
586 static HICON hIconTitleFont
;
588 static BOOL
__get_dropline( HWND hWnd
, LPRECT lprect
)
589 { HWND hWndCtl
= GetDlgItem(hWnd
, IDC_WINE_TEXT
);
591 { GetWindowRect( hWndCtl
, lprect
);
592 MapWindowPoints( 0, hWnd
, (LPPOINT
)lprect
, 2 );
593 lprect
->bottom
= (lprect
->top
+= DROP_FIELD_TOP
);
599 /*************************************************************************
600 * SHAppBarMessage [SHELL32.@]
602 UINT WINAPI
SHAppBarMessage(DWORD msg
, PAPPBARDATA data
)
604 int width
=data
->rc
.right
- data
->rc
.left
;
605 int height
=data
->rc
.bottom
- data
->rc
.top
;
609 return ABS_ALWAYSONTOP
| ABS_AUTOHIDE
;
610 case ABM_GETTASKBARPOS
:
611 GetWindowRect(data
->hWnd
, &rec
);
615 SetActiveWindow(data
->hWnd
);
617 case ABM_GETAUTOHIDEBAR
:
618 data
->hWnd
=GetActiveWindow();
621 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
,rec
.top
,
622 width
,height
,SWP_SHOWWINDOW
);
625 GetWindowRect(data
->hWnd
, &(data
->rc
));
628 FIXME("ABM_REMOVE broken\n");
629 /* FIXME: this is wrong; should it be DestroyWindow instead? */
630 /*CloseHandle(data->hWnd);*/
632 case ABM_SETAUTOHIDEBAR
:
633 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
+1000,rec
.top
,
634 width
,height
,SWP_SHOWWINDOW
);
637 data
->uEdge
=(ABE_RIGHT
| ABE_LEFT
);
638 SetWindowPos(data
->hWnd
,HWND_TOP
,data
->rc
.left
,data
->rc
.top
,
639 width
,height
,SWP_SHOWWINDOW
);
641 case ABM_WINDOWPOSCHANGED
:
642 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
,rec
.top
,
643 width
,height
,SWP_SHOWWINDOW
);
649 /*************************************************************************
650 * SHHelpShortcuts_RunDLL [SHELL32.@]
653 DWORD WINAPI
SHHelpShortcuts_RunDLL (DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
654 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
655 dwArg1
, dwArg2
, dwArg3
, dwArg4
);
660 /*************************************************************************
661 * SHLoadInProc [SHELL32.@]
662 * Create an instance of specified object class from within
663 * the shell process and release it immediately
666 DWORD WINAPI
SHLoadInProc (REFCLSID rclsid
)
668 IUnknown
* pUnk
= NULL
;
669 TRACE("%s\n", debugstr_guid(rclsid
));
671 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,(LPVOID
*)pUnk
);
674 IUnknown_Release(pUnk
);
677 return DISP_E_MEMBERNOTFOUND
;
680 /*************************************************************************
681 * ShellExecuteA [SHELL32.290]
683 HINSTANCE WINAPI
ShellExecuteA( HWND hWnd
, LPCSTR lpOperation
,
684 LPCSTR lpFile
, LPCSTR lpParameters
,
685 LPCSTR lpDirectory
, INT iShowCmd
)
687 return ShellExecute16( hWnd
, lpOperation
, lpFile
, lpParameters
,
688 lpDirectory
, iShowCmd
);
691 /*************************************************************************
692 * ShellExecuteW [SHELL32.294]
694 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
695 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
702 LPCWSTR lpParameters
,
710 /*************************************************************************
711 * AboutDlgProc (internal)
713 BOOL WINAPI
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
716 char Template
[512], AppTitle
[512];
721 { case WM_INITDIALOG
:
722 { ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
724 { const char* const *pstr
= SHELL_People
;
725 SendDlgItemMessageA(hWnd
, stc1
, STM_SETICON
,info
->hIcon
, 0);
726 GetWindowTextA( hWnd
, Template
, sizeof(Template
) );
727 sprintf( AppTitle
, Template
, info
->szApp
);
728 SetWindowTextA( hWnd
, AppTitle
);
729 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
),
730 info
->szOtherStuff
);
731 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
732 SendMessageA( hWndCtl
, WM_SETREDRAW
, 0, 0 );
736 SystemParametersInfoA( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
737 hIconTitleFont
= CreateFontIndirectA( &logFont
);
739 SendMessageA( hWndCtl
, WM_SETFONT
, hIconTitleFont
, 0 );
741 { SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)*pstr
);
744 SendMessageA( hWndCtl
, WM_SETREDRAW
, 1, 0 );
752 HDC hDC
= BeginPaint( hWnd
, &ps
);
754 if( __get_dropline( hWnd
, &rect
) ) {
755 SelectObject( hDC
, GetStockObject( BLACK_PEN
) );
756 MoveToEx( hDC
, rect
.left
, rect
.top
, NULL
);
757 LineTo( hDC
, rect
.right
, rect
.bottom
);
759 EndPaint( hWnd
, &ps
);
763 #if 0 /* FIXME: should use DoDragDrop */
764 case WM_LBTRACKPOINT
:
765 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
766 if( (INT16
)GetKeyState( VK_CONTROL
) < 0 )
767 { if( DragDetect( hWndCtl
, *((LPPOINT
)&lParam
) ) )
768 { INT idx
= SendMessageA( hWndCtl
, LB_GETCURSEL
, 0, 0 );
770 { INT length
= SendMessageA( hWndCtl
, LB_GETTEXTLEN
, (WPARAM
)idx
, 0 );
771 HGLOBAL16 hMemObj
= GlobalAlloc16( GMEM_MOVEABLE
, length
+ 1 );
772 char* pstr
= (char*)GlobalLock16( hMemObj
);
775 { HCURSOR hCursor
= LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT
) );
776 SendMessageA( hWndCtl
, LB_GETTEXT
, (WPARAM
)idx
, (LPARAM
)pstr
);
777 SendMessageA( hWndCtl
, LB_DELETESTRING
, (WPARAM
)idx
, 0 );
778 UpdateWindow( hWndCtl
);
779 if( !DragObject16((HWND16
)hWnd
, (HWND16
)hWnd
, DRAGOBJ_DATA
, 0, (WORD
)hMemObj
, hCursor
) )
780 SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)pstr
);
783 GlobalFree16( hMemObj
);
790 case WM_QUERYDROPOBJECT
:
792 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
793 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
)
795 if( __get_dropline( hWnd
, &rect
) )
797 pt
.x
=lpDragInfo
->pt
.x
;
798 pt
.x
=lpDragInfo
->pt
.y
;
799 rect
.bottom
+= DROP_FIELD_HEIGHT
;
800 if( PtInRect( &rect
, pt
) )
801 { SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
811 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
812 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
&& lpDragInfo
->hList
)
813 { char* pstr
= (char*)GlobalLock16( (HGLOBAL16
)(lpDragInfo
->hList
) );
815 { static char __appendix_str
[] = " with";
817 hWndCtl
= GetDlgItem( hWnd
, IDC_WINE_TEXT
);
818 SendMessageA( hWndCtl
, WM_GETTEXT
, 512, (LPARAM
)Template
);
819 if( !strncmp( Template
, "WINE", 4 ) )
820 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
), Template
);
822 { char* pch
= Template
+ strlen(Template
) - strlen(__appendix_str
);
824 SendMessageA( GetDlgItem(hWnd
, IDC_LISTBOX
), LB_ADDSTRING
,
825 (WPARAM
)-1, (LPARAM
)Template
);
828 strcpy( Template
, pstr
);
829 strcat( Template
, __appendix_str
);
830 SetWindowTextA( hWndCtl
, Template
);
831 SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
840 { EndDialog(hWnd
, TRUE
);
845 EndDialog(hWnd
, TRUE
);
853 /*************************************************************************
854 * ShellAboutA [SHELL32.288]
856 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
,
863 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
865 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
869 info
.szOtherStuff
= szOtherStuff
;
871 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
872 return DialogBoxIndirectParamA( GetWindowLongA( hWnd
, GWL_HINSTANCE
),
873 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
877 /*************************************************************************
878 * ShellAboutW [SHELL32.289]
880 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
889 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
891 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
894 info
.szApp
= HEAP_strdupWtoA( GetProcessHeap(), 0, szApp
);
895 info
.szOtherStuff
= HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff
);
897 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
898 ret
= DialogBoxIndirectParamA( GetWindowLongA( hWnd
, GWL_HINSTANCE
),
899 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
900 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szApp
);
901 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szOtherStuff
);
905 /*************************************************************************
906 * FreeIconList (SHELL32.@)
908 void WINAPI
FreeIconList( DWORD dw
)
909 { FIXME("(%lx): stub\n",dw
);
912 /***********************************************************************
913 * DllGetVersion [SHELL32.@]
915 * Retrieves version information of the 'SHELL32.DLL'
918 * pdvi [O] pointer to version information structure.
922 * Failure: E_INVALIDARG
925 * Returns version of a shell32.dll from IE4.01 SP1.
928 HRESULT WINAPI
SHELL32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
930 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
))
932 WARN("wrong DLLVERSIONINFO size from app\n");
936 pdvi
->dwMajorVersion
= 4;
937 pdvi
->dwMinorVersion
= 72;
938 pdvi
->dwBuildNumber
= 3110;
939 pdvi
->dwPlatformID
= 1;
941 TRACE("%lu.%lu.%lu.%lu\n",
942 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
943 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
947 /*************************************************************************
948 * global variables of the shell32.dll
949 * all are once per process
952 void WINAPI (*pDLLInitComctl
)(LPVOID
);
954 LPVOID
WINAPI (*pCOMCTL32_Alloc
) (INT
);
955 BOOL
WINAPI (*pCOMCTL32_Free
) (LPVOID
);
957 HDPA
WINAPI (*pDPA_Create
) (INT
);
958 INT
WINAPI (*pDPA_InsertPtr
) (const HDPA
, INT
, LPVOID
);
959 BOOL
WINAPI (*pDPA_Sort
) (const HDPA
, PFNDPACOMPARE
, LPARAM
);
960 LPVOID
WINAPI (*pDPA_GetPtr
) (const HDPA
, INT
);
961 BOOL
WINAPI (*pDPA_Destroy
) (const HDPA
);
962 INT
WINAPI (*pDPA_Search
) (const HDPA
, LPVOID
, INT
, PFNDPACOMPARE
, LPARAM
, UINT
);
963 LPVOID
WINAPI (*pDPA_DeletePtr
) (const HDPA hdpa
, INT i
);
964 HANDLE
WINAPI (*pCreateMRUListA
) (LPVOID lpcml
);
965 DWORD
WINAPI (*pFreeMRUListA
) (HANDLE hMRUList
);
966 INT
WINAPI (*pAddMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
967 INT
WINAPI (*pFindMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
968 INT
WINAPI (*pEnumMRUListA
) (HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
970 static HINSTANCE hComctl32
;
972 LONG shell32_ObjCount
= 0;
973 HINSTANCE shell32_hInstance
= 0;
974 HIMAGELIST ShellSmallIconList
= 0;
975 HIMAGELIST ShellBigIconList
= 0;
978 /*************************************************************************
982 * calling oleinitialize here breaks sone apps.
985 BOOL WINAPI
Shell32LibMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
987 TRACE("0x%x 0x%lx %p\n", hinstDLL
, fdwReason
, fImpLoad
);
991 case DLL_PROCESS_ATTACH
:
992 shell32_hInstance
= hinstDLL
;
993 hComctl32
= GetModuleHandleA("COMCTL32.DLL");
994 DisableThreadLibraryCalls(shell32_hInstance
);
998 ERR("P A N I C SHELL32 loading failed\n");
1003 pDLLInitComctl
=(void*)GetProcAddress(hComctl32
,"InitCommonControlsEx");
1004 pCOMCTL32_Alloc
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)71L);
1005 pCOMCTL32_Free
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)73L);
1006 pDPA_Create
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)328L);
1007 pDPA_Destroy
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)329L);
1008 pDPA_GetPtr
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)332L);
1009 pDPA_InsertPtr
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)334L);
1010 pDPA_DeletePtr
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)336L);
1011 pDPA_Sort
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)338L);
1012 pDPA_Search
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)339L);
1013 pCreateMRUListA
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)151L /*"CreateMRUListA"*/);
1014 pFreeMRUListA
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)152L /*"FreeMRUList"*/);
1015 pAddMRUData
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)167L /*"AddMRUData"*/);
1016 pFindMRUData
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)169L /*"FindMRUData"*/);
1017 pEnumMRUListA
=(void*)GetProcAddress(hComctl32
, (LPCSTR
)154L /*"EnumMRUListA"*/);
1019 /* initialize the common controls */
1022 pDLLInitComctl(NULL
);
1027 InitChangeNotifications();
1028 SHInitRestricted(NULL
, NULL
);
1031 case DLL_THREAD_ATTACH
:
1034 case DLL_THREAD_DETACH
:
1037 case DLL_PROCESS_DETACH
:
1038 shell32_hInstance
= 0;
1042 IShellFolder_Release(pdesktopfolder
);
1043 pdesktopfolder
= NULL
;
1047 FreeChangeNotifications();
1049 /* this one is here to check if AddRef/Release is balanced */
1050 if (shell32_ObjCount
)
1052 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount
);
1059 /*************************************************************************
1060 * DllInstall [SHELL32.@]
1064 * BOOL bInstall - TRUE for install, FALSE for uninstall
1065 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1068 HRESULT WINAPI
SHELL32_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1070 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1072 return S_OK
; /* indicate success */
1075 /***********************************************************************
1076 * DllCanUnloadNow (SHELL32.@)
1078 HRESULT WINAPI
SHELL32_DllCanUnloadNow(void)
1080 FIXME("(void): stub\n");