4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 #include "undocshell.h"
38 #include "wine/winuser16.h"
42 #include "shell32_main.h"
44 #include "wine/debug.h"
45 #include "wine/unicode.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
50 /*************************************************************************
51 * CommandLineToArgvW [SHELL32.@]
53 * We must interpret the quotes in the command line to rebuild the argv
55 * - arguments are separated by spaces or tabs
56 * - quotes serve as optional argument delimiters
58 * - escaped quotes must be converted back to '"'
60 * - an odd number of '\'s followed by '"' correspond to half that number
61 * of '\' followed by a '"' (extension of the above)
64 * - an even number of '\'s followed by a '"' correspond to half that number
65 * of '\', plus a regular quote serving as an argument delimiter (which
66 * means it does not appear in the result)
67 * 'a\\"b c"' -> 'a\b c'
68 * 'a\\\\"b c"' -> 'a\\b c'
69 * - '\' that are not followed by a '"' are copied literally
79 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
90 /* Return the path to the executable */
97 hargv
=GlobalReAlloc(hargv
, size
, 0);
98 argv
=GlobalLock(hargv
);
99 } while (GetModuleFileNameW((HMODULE
)0, (LPWSTR
)(argv
+1), size
-sizeof(LPWSTR
)) == 0);
100 argv
[0]=(LPWSTR
)(argv
+1);
107 /* to get a writeable copy */
113 if (*cs
==0 || ((*cs
==0x0009 || *cs
==0x0020) && !in_quotes
)) {
116 /* skip the remaining spaces */
117 while (*cs
==0x0009 || *cs
==0x0020) {
124 } else if (*cs
==0x005c) {
125 /* '\', count them */
127 } else if ((*cs
==0x0022) && ((bcount
& 1)==0)) {
129 in_quotes
=!in_quotes
;
132 /* a regular character */
137 /* Allocate in a single lump, the string array, and the strings that go with it.
138 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
140 hargv
=GlobalAlloc(0, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
141 argv
=GlobalLock(hargv
);
144 cmdline
=(LPWSTR
)(argv
+argc
);
145 strcpyW(cmdline
, lpCmdline
);
152 if ((*s
==0x0009 || *s
==0x0020) && !in_quotes
) {
153 /* Close the argument and copy it */
157 /* skip the remaining spaces */
160 } while (*s
==0x0009 || *s
==0x0020);
162 /* Start with a new argument */
165 } else if (*s
==0x005c) {
169 } else if (*s
==0x0022) {
171 if ((bcount
& 1)==0) {
172 /* Preceeded by an even number of '\', this is half that
173 * number of '\', plus a quote which we erase.
176 in_quotes
=!in_quotes
;
179 /* Preceeded by an odd number of '\', this is half that
180 * number of '\' followed by a '"'
188 /* a regular character */
203 /*************************************************************************
204 * SHGetFileInfoA [SHELL32.@]
208 DWORD WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
209 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
212 char szLocation
[MAX_PATH
];
214 DWORD ret
= TRUE
, dwAttributes
= 0;
215 IShellFolder
* psfParent
= NULL
;
216 IExtractIconA
* pei
= NULL
;
217 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
219 BOOL IconNotYetLoaded
=TRUE
;
221 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
222 (flags
& SHGFI_PIDL
)? "pidl" : path
, dwFileAttributes
, psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
224 if ((flags
& SHGFI_USEFILEATTRIBUTES
) && (flags
& (SHGFI_ATTRIBUTES
|SHGFI_EXETYPE
|SHGFI_PIDL
)))
227 /* windows initializes this values regardless of the flags */
228 psfi
->szDisplayName
[0] = '\0';
229 psfi
->szTypeName
[0] = '\0';
232 if (flags
& SHGFI_EXETYPE
) {
236 IMAGE_DOS_HEADER mz_header
;
241 if (flags
!= SHGFI_EXETYPE
) return 0;
243 status
= GetBinaryTypeA (path
, &BinaryType
);
244 if (!status
) return 0;
245 if ((BinaryType
== SCS_DOS_BINARY
)
246 || (BinaryType
== SCS_PIF_BINARY
)) return 0x4d5a;
248 hfile
= CreateFileA( path
, GENERIC_READ
, FILE_SHARE_READ
,
249 NULL
, OPEN_EXISTING
, 0, 0 );
250 if ( hfile
== INVALID_HANDLE_VALUE
) return 0;
252 /* The next section is adapted from MODULE_GetBinaryType, as we need
253 * to examine the image header to get OS and version information. We
254 * know from calling GetBinaryTypeA that the image is valid and either
255 * an NE or PE, so much error handling can be omitted.
256 * Seek to the start of the file and read the header information.
259 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
260 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
262 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
263 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
264 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
266 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
267 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
268 CloseHandle( hfile
);
269 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
) {
270 return IMAGE_NT_SIGNATURE
271 | (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24)
272 | (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
274 return IMAGE_NT_SIGNATURE
;
276 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
279 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
280 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
281 CloseHandle( hfile
);
282 if (ne
.ne_exetyp
== 2) return IMAGE_OS2_SIGNATURE
283 | (ne
.ne_expver
<< 16);
286 CloseHandle( hfile
);
291 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
292 the pidl functions fail on not existing file names */
294 if (flags
& SHGFI_PIDL
) {
295 pidl
= ILClone((LPCITEMIDLIST
)path
);
296 } else if (!(flags
& SHGFI_USEFILEATTRIBUTES
)) {
297 hr
= SHILCreateFromPathA(path
, &pidl
, &dwAttributes
);
300 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
302 /* get the parent shellfolder */
304 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
, &pidlLast
);
307 ERR("pidl is null!\n");
312 /* get the attributes of the child */
313 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
315 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
317 psfi
->dwAttributes
= 0xffffffff;
319 IShellFolder_GetAttributesOf(psfParent
, 1 , &pidlLast
, &(psfi
->dwAttributes
));
322 /* get the displayname */
323 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
325 if (flags
& SHGFI_USEFILEATTRIBUTES
)
327 strcpy (psfi
->szDisplayName
, PathFindFileNameA(path
));
332 hr
= IShellFolder_GetDisplayNameOf(psfParent
, pidlLast
, SHGDN_INFOLDER
, &str
);
333 StrRetToStrNA (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
337 /* get the type name */
338 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
340 if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
341 _ILGetFileType(pidlLast
, psfi
->szTypeName
, 80);
344 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
345 strcat (psfi
->szTypeName
, "File");
349 strcpy(sTemp
,PathFindExtensionA(path
));
350 if (!( HCR_MapTypeToValue(sTemp
, sTemp
, 64, TRUE
)
351 && HCR_MapTypeToValue(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
353 lstrcpynA (psfi
->szTypeName
, sTemp
, 64);
354 strcat (psfi
->szTypeName
, "-file");
361 if (flags
& SHGFI_LINKOVERLAY
)
362 FIXME("set icon to link, stub\n");
364 if (flags
& SHGFI_SELECTED
)
365 FIXME("set icon to selected, stub\n");
367 if (flags
& SHGFI_SHELLICONSIZE
)
368 FIXME("set icon to shell size, stub\n");
370 /* get the iconlocation */
371 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
374 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1, &pidlLast
, &IID_IExtractIconA
, &uDummy
, (LPVOID
*)&pei
);
378 hr
= IExtractIconA_GetIconLocation(pei
, (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0,szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
379 /* FIXME what to do with the index? */
381 if(uFlags
!= GIL_NOTFILENAME
)
382 strcpy (psfi
->szDisplayName
, szLocation
);
386 IExtractIconA_Release(pei
);
390 /* get icon index (or load icon)*/
391 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
394 if (flags
& SHGFI_USEFILEATTRIBUTES
)
396 char sTemp
[MAX_PATH
];
400 lstrcpynA(sTemp
, path
, MAX_PATH
);
402 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
407 szExt
= (LPSTR
) PathFindExtensionA(sTemp
);
408 if ( szExt
&& HCR_MapTypeToValue(szExt
, sTemp
, MAX_PATH
, TRUE
)
409 && HCR_GetDefaultIcon(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
411 if (!strcmp("%1",sTemp
)) /* icon is in the file */
414 if (flags
& SHGFI_SYSICONINDEX
)
416 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,dwNr
);
417 if (psfi
->iIcon
== -1) psfi
->iIcon
= 0;
421 IconNotYetLoaded
=FALSE
;
422 PrivateExtractIconsA(sTemp
,dwNr
,(flags
&SHGFI_LARGEICON
) ?
423 GetSystemMetrics(SM_CXICON
) : GetSystemMetrics(SM_CXSMICON
),
424 (flags
&SHGFI_LARGEICON
) ? GetSystemMetrics(SM_CYICON
) :
425 GetSystemMetrics(SM_CYSMICON
), &psfi
->hIcon
,0,1,0);
433 if (!(PidlToSicIndex(psfParent
, pidlLast
, (flags
& SHGFI_LARGEICON
),
434 (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0, &(psfi
->iIcon
))))
441 ret
= (DWORD
) ((flags
& SHGFI_LARGEICON
) ? ShellBigIconList
: ShellSmallIconList
);
446 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
447 psfi
->hIcon
= ImageList_GetIcon((flags
& SHGFI_LARGEICON
) ? ShellBigIconList
:ShellSmallIconList
, psfi
->iIcon
, ILD_NORMAL
);
449 if (flags
& (SHGFI_UNKNOWN1
| SHGFI_UNKNOWN2
| SHGFI_UNKNOWN3
))
450 FIXME("unknown attribute!\n");
453 IShellFolder_Release(psfParent
);
458 if(pidlLast
) SHFree(pidlLast
);
460 TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
461 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
, psfi
->szDisplayName
, psfi
->szTypeName
, ret
);
466 /*************************************************************************
467 * SHGetFileInfoW [SHELL32.@]
470 DWORD WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
471 SHFILEINFOW
*psfi
, UINT sizeofpsfi
,
477 SHFILEINFOA temppsfi
;
479 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, NULL
, 0, NULL
, NULL
);
480 temppath
= HeapAlloc(GetProcessHeap(), 0, len
);
481 WideCharToMultiByte(CP_ACP
, 0, path
, -1, temppath
, len
, NULL
, NULL
);
483 if(flags
& SHGFI_ATTR_SPECIFIED
)
484 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
486 ret
= SHGetFileInfoA(temppath
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
488 if(flags
& SHGFI_ICON
)
489 psfi
->hIcon
=temppsfi
.hIcon
;
490 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
491 psfi
->iIcon
=temppsfi
.iIcon
;
492 if(flags
& SHGFI_ATTRIBUTES
)
493 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
494 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
495 MultiByteToWideChar(CP_ACP
, 0, temppsfi
.szDisplayName
, -1, psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
));
496 if(flags
& SHGFI_TYPENAME
)
497 MultiByteToWideChar(CP_ACP
, 0, temppsfi
.szTypeName
, -1, psfi
->szTypeName
, sizeof(psfi
->szTypeName
));
499 HeapFree(GetProcessHeap(), 0, temppath
);
504 /*************************************************************************
505 * SHGetFileInfo [SHELL32.@]
507 DWORD WINAPI
SHGetFileInfoAW(
509 DWORD dwFileAttributes
,
514 if(SHELL_OsIsUnicode())
515 return SHGetFileInfoW(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
516 return SHGetFileInfoA(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
519 /*************************************************************************
520 * DuplicateIcon [SHELL32.@]
522 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
527 TRACE("(%p, %p)\n", hInstance
, hIcon
);
529 if(GetIconInfo(hIcon
, &IconInfo
))
531 hDupIcon
= CreateIconIndirect(&IconInfo
);
533 /* clean up hbmMask and hbmColor */
534 DeleteObject(IconInfo
.hbmMask
);
535 DeleteObject(IconInfo
.hbmColor
);
541 /*************************************************************************
542 * ExtractIconA [SHELL32.@]
545 * if the filename is not a file return 1
547 HICON WINAPI
ExtractIconA( HINSTANCE hInstance
, LPCSTR lpszExeFileName
,
549 { HGLOBAL16 handle
= InternalExtractIcon16(HINSTANCE_16(hInstance
),lpszExeFileName
,nIconIndex
, 1);
553 HICON16
* ptr
= (HICON16
*)GlobalLock16(handle
);
554 HICON16 hIcon
= *ptr
;
556 GlobalFree16(handle
);
557 return HICON_32(hIcon
);
562 /*************************************************************************
563 * ExtractIconW [SHELL32.@]
565 * FIXME: if the filename is not a file return 1
567 HICON WINAPI
ExtractIconW( HINSTANCE hInstance
, LPCWSTR lpszExeFileName
,
573 exefn
= HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName
);
574 ret
= ExtractIconA(hInstance
,exefn
,nIconIndex
);
576 HeapFree(GetProcessHeap(),0,exefn
);
586 #define IDC_STATIC_TEXT 100
587 #define IDC_LISTBOX 99
588 #define IDC_WINE_TEXT 98
590 #define DROP_FIELD_TOP (-15)
591 #define DROP_FIELD_HEIGHT 15
593 static HFONT hIconTitleFont
;
595 static BOOL
__get_dropline( HWND hWnd
, LPRECT lprect
)
596 { HWND hWndCtl
= GetDlgItem(hWnd
, IDC_WINE_TEXT
);
598 { GetWindowRect( hWndCtl
, lprect
);
599 MapWindowPoints( 0, hWnd
, (LPPOINT
)lprect
, 2 );
600 lprect
->bottom
= (lprect
->top
+= DROP_FIELD_TOP
);
606 /*************************************************************************
607 * SHAppBarMessage [SHELL32.@]
609 UINT WINAPI
SHAppBarMessage(DWORD msg
, PAPPBARDATA data
)
611 int width
=data
->rc
.right
- data
->rc
.left
;
612 int height
=data
->rc
.bottom
- data
->rc
.top
;
616 return ABS_ALWAYSONTOP
| ABS_AUTOHIDE
;
617 case ABM_GETTASKBARPOS
:
618 GetWindowRect(data
->hWnd
, &rec
);
622 SetActiveWindow(data
->hWnd
);
624 case ABM_GETAUTOHIDEBAR
:
625 data
->hWnd
=GetActiveWindow();
628 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
,rec
.top
,
629 width
,height
,SWP_SHOWWINDOW
);
632 GetWindowRect(data
->hWnd
, &(data
->rc
));
635 FIXME("ABM_REMOVE broken\n");
636 /* FIXME: this is wrong; should it be DestroyWindow instead? */
637 /*CloseHandle(data->hWnd);*/
639 case ABM_SETAUTOHIDEBAR
:
640 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
+1000,rec
.top
,
641 width
,height
,SWP_SHOWWINDOW
);
644 data
->uEdge
=(ABE_RIGHT
| ABE_LEFT
);
645 SetWindowPos(data
->hWnd
,HWND_TOP
,data
->rc
.left
,data
->rc
.top
,
646 width
,height
,SWP_SHOWWINDOW
);
648 case ABM_WINDOWPOSCHANGED
:
654 /*************************************************************************
655 * SHHelpShortcuts_RunDLL [SHELL32.@]
658 DWORD WINAPI
SHHelpShortcuts_RunDLL (DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
659 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
660 dwArg1
, dwArg2
, dwArg3
, dwArg4
);
665 /*************************************************************************
666 * SHLoadInProc [SHELL32.@]
667 * Create an instance of specified object class from within
668 * the shell process and release it immediately
671 DWORD WINAPI
SHLoadInProc (REFCLSID rclsid
)
673 IUnknown
* pUnk
= NULL
;
674 TRACE("%s\n", debugstr_guid(rclsid
));
676 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,(LPVOID
*)pUnk
);
679 IUnknown_Release(pUnk
);
682 return DISP_E_MEMBERNOTFOUND
;
685 /*************************************************************************
686 * AboutDlgProc (internal)
688 INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
691 char Template
[512], AppTitle
[512];
696 { case WM_INITDIALOG
:
697 { ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
699 { const char* const *pstr
= SHELL_People
;
700 SendDlgItemMessageA(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
701 GetWindowTextA( hWnd
, Template
, sizeof(Template
) );
702 sprintf( AppTitle
, Template
, info
->szApp
);
703 SetWindowTextA( hWnd
, AppTitle
);
704 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
),
705 info
->szOtherStuff
);
706 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
707 SendMessageA( hWndCtl
, WM_SETREDRAW
, 0, 0 );
711 SystemParametersInfoA( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
712 hIconTitleFont
= CreateFontIndirectA( &logFont
);
714 SendMessageA( hWndCtl
, WM_SETFONT
, HICON_16(hIconTitleFont
), 0 );
716 { SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)*pstr
);
719 SendMessageA( hWndCtl
, WM_SETREDRAW
, 1, 0 );
727 HDC hDC
= BeginPaint( hWnd
, &ps
);
729 if( __get_dropline( hWnd
, &rect
) ) {
730 SelectObject( hDC
, GetStockObject( BLACK_PEN
) );
731 MoveToEx( hDC
, rect
.left
, rect
.top
, NULL
);
732 LineTo( hDC
, rect
.right
, rect
.bottom
);
734 EndPaint( hWnd
, &ps
);
738 #if 0 /* FIXME: should use DoDragDrop */
739 case WM_LBTRACKPOINT
:
740 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
741 if( (INT16
)GetKeyState( VK_CONTROL
) < 0 )
742 { if( DragDetect( hWndCtl
, *((LPPOINT
)&lParam
) ) )
743 { INT idx
= SendMessageA( hWndCtl
, LB_GETCURSEL
, 0, 0 );
745 { INT length
= SendMessageA( hWndCtl
, LB_GETTEXTLEN
, (WPARAM
)idx
, 0 );
746 HGLOBAL16 hMemObj
= GlobalAlloc16( GMEM_MOVEABLE
, length
+ 1 );
747 char* pstr
= (char*)GlobalLock16( hMemObj
);
750 { HCURSOR hCursor
= LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT
) );
751 SendMessageA( hWndCtl
, LB_GETTEXT
, (WPARAM
)idx
, (LPARAM
)pstr
);
752 SendMessageA( hWndCtl
, LB_DELETESTRING
, (WPARAM
)idx
, 0 );
753 UpdateWindow( hWndCtl
);
754 if( !DragObject16((HWND16
)hWnd
, (HWND16
)hWnd
, DRAGOBJ_DATA
, 0, (WORD
)hMemObj
, hCursor
) )
755 SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)pstr
);
758 GlobalFree16( hMemObj
);
765 case WM_QUERYDROPOBJECT
:
767 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
768 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
)
770 if( __get_dropline( hWnd
, &rect
) )
772 pt
.x
=lpDragInfo
->pt
.x
;
773 pt
.x
=lpDragInfo
->pt
.y
;
774 rect
.bottom
+= DROP_FIELD_HEIGHT
;
775 if( PtInRect( &rect
, pt
) )
776 { SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
785 if( wParam
== (WPARAM
)hWnd
)
786 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
787 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
&& lpDragInfo
->hList
)
788 { char* pstr
= (char*)GlobalLock16( (HGLOBAL16
)(lpDragInfo
->hList
) );
790 { static char __appendix_str
[] = " with";
792 hWndCtl
= GetDlgItem( hWnd
, IDC_WINE_TEXT
);
793 SendMessageA( hWndCtl
, WM_GETTEXT
, 512, (LPARAM
)Template
);
794 if( !strncmp( Template
, "WINE", 4 ) )
795 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
), Template
);
797 { char* pch
= Template
+ strlen(Template
) - strlen(__appendix_str
);
799 SendMessageA( GetDlgItem(hWnd
, IDC_LISTBOX
), LB_ADDSTRING
,
800 (WPARAM
)-1, (LPARAM
)Template
);
803 strcpy( Template
, pstr
);
804 strcat( Template
, __appendix_str
);
805 SetWindowTextA( hWndCtl
, Template
);
806 SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
815 { EndDialog(hWnd
, TRUE
);
820 EndDialog(hWnd
, TRUE
);
828 /*************************************************************************
829 * ShellAboutA [SHELL32.288]
831 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
,
838 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
840 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
844 info
.szOtherStuff
= szOtherStuff
;
846 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
847 return DialogBoxIndirectParamA( (HINSTANCE
)GetWindowLongA( hWnd
, GWL_HINSTANCE
),
848 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
852 /*************************************************************************
853 * ShellAboutW [SHELL32.289]
855 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
864 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
866 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
869 info
.szApp
= HEAP_strdupWtoA( GetProcessHeap(), 0, szApp
);
870 info
.szOtherStuff
= HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff
);
872 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
873 ret
= DialogBoxIndirectParamA((HINSTANCE
)GetWindowLongA( hWnd
, GWL_HINSTANCE
),
874 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
875 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szApp
);
876 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szOtherStuff
);
880 /*************************************************************************
881 * FreeIconList (SHELL32.@)
883 void WINAPI
FreeIconList( DWORD dw
)
884 { FIXME("(%lx): stub\n",dw
);
887 /***********************************************************************
888 * DllGetVersion [SHELL32.@]
890 * Retrieves version information of the 'SHELL32.DLL'
893 * pdvi [O] pointer to version information structure.
897 * Failure: E_INVALIDARG
900 * Returns version of a shell32.dll from IE4.01 SP1.
903 HRESULT WINAPI
SHELL32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
905 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
))
907 WARN("wrong DLLVERSIONINFO size from app\n");
911 pdvi
->dwMajorVersion
= 4;
912 pdvi
->dwMinorVersion
= 72;
913 pdvi
->dwBuildNumber
= 3110;
914 pdvi
->dwPlatformID
= 1;
916 TRACE("%lu.%lu.%lu.%lu\n",
917 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
918 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
922 /*************************************************************************
923 * global variables of the shell32.dll
924 * all are once per process
927 void (WINAPI
*pDLLInitComctl
)(LPVOID
);
929 LPVOID (WINAPI
*pCOMCTL32_Alloc
) (INT
);
930 BOOL (WINAPI
*pCOMCTL32_Free
) (LPVOID
);
932 HANDLE (WINAPI
*pCreateMRUListA
) (LPVOID lpcml
);
933 DWORD (WINAPI
*pFreeMRUListA
) (HANDLE hMRUList
);
934 INT (WINAPI
*pAddMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
935 INT (WINAPI
*pFindMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
936 INT (WINAPI
*pEnumMRUListA
) (HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
938 static HINSTANCE hComctl32
;
940 HINSTANCE shell32_hInstance
= 0;
941 HIMAGELIST ShellSmallIconList
= 0;
942 HIMAGELIST ShellBigIconList
= 0;
945 /*************************************************************************
949 * calling oleinitialize here breaks sone apps.
952 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
954 TRACE("%p 0x%lx %p\n", hinstDLL
, fdwReason
, fImpLoad
);
958 case DLL_PROCESS_ATTACH
:
959 shell32_hInstance
= hinstDLL
;
960 hComctl32
= GetModuleHandleA("COMCTL32.DLL");
961 DisableThreadLibraryCalls(shell32_hInstance
);
965 ERR("P A N I C SHELL32 loading failed\n");
970 pDLLInitComctl
=(void*)GetProcAddress(hComctl32
,"InitCommonControlsEx");
971 /* initialize the common controls */
974 pDLLInitComctl(NULL
);
979 InitChangeNotifications();
980 SHInitRestricted(NULL
, NULL
);
983 case DLL_THREAD_ATTACH
:
986 case DLL_THREAD_DETACH
:
989 case DLL_PROCESS_DETACH
:
990 shell32_hInstance
= 0;
992 FreeChangeNotifications();
998 /*************************************************************************
999 * DllInstall [SHELL32.@]
1003 * BOOL bInstall - TRUE for install, FALSE for uninstall
1004 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1007 HRESULT WINAPI
SHELL32_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1009 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1011 return S_OK
; /* indicate success */
1014 /***********************************************************************
1015 * DllCanUnloadNow (SHELL32.@)
1017 HRESULT WINAPI
SHELL32_DllCanUnloadNow(void)
1019 FIXME("(void): stub\n");