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(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
], szFullPath
[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_PIDL
)){
233 /* SHGitFileInfo should work with absolute and relative paths */
234 if (PathIsRelativeA(path
)){
235 GetCurrentDirectoryA(MAX_PATH
, szLocation
);
236 PathCombineA(szFullPath
, szLocation
, path
);
238 lstrcpynA(szFullPath
, path
, MAX_PATH
);
242 if (flags
& SHGFI_EXETYPE
) {
246 IMAGE_DOS_HEADER mz_header
;
251 if (flags
!= SHGFI_EXETYPE
) return 0;
253 status
= GetBinaryTypeA (szFullPath
, &BinaryType
);
254 if (!status
) return 0;
255 if ((BinaryType
== SCS_DOS_BINARY
)
256 || (BinaryType
== SCS_PIF_BINARY
)) return 0x4d5a;
258 hfile
= CreateFileA( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
259 NULL
, OPEN_EXISTING
, 0, 0 );
260 if ( hfile
== INVALID_HANDLE_VALUE
) return 0;
262 /* The next section is adapted from MODULE_GetBinaryType, as we need
263 * to examine the image header to get OS and version information. We
264 * know from calling GetBinaryTypeA that the image is valid and either
265 * an NE or PE, so much error handling can be omitted.
266 * Seek to the start of the file and read the header information.
269 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
270 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
272 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
273 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
274 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
276 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
277 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
278 CloseHandle( hfile
);
279 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
) {
280 return IMAGE_NT_SIGNATURE
281 | (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24)
282 | (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
284 return IMAGE_NT_SIGNATURE
;
286 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
289 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
290 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
291 CloseHandle( hfile
);
292 if (ne
.ne_exetyp
== 2) return IMAGE_OS2_SIGNATURE
293 | (ne
.ne_expver
<< 16);
296 CloseHandle( hfile
);
301 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
303 The pidl functions fail on not existing file names */
305 if (flags
& SHGFI_PIDL
) {
306 pidl
= ILClone((LPCITEMIDLIST
)path
);
307 } else if (!(flags
& SHGFI_USEFILEATTRIBUTES
)) {
308 hr
= SHILCreateFromPathA(szFullPath
, &pidl
, &dwAttributes
);
311 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
313 /* get the parent shellfolder */
315 hr
= SHBindToParent( pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
, &pidlLast
);
318 ERR("pidl is null!\n");
323 /* get the attributes of the child */
324 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
326 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
328 psfi
->dwAttributes
= 0xffffffff;
330 IShellFolder_GetAttributesOf(psfParent
, 1 , &pidlLast
, &(psfi
->dwAttributes
));
333 /* get the displayname */
334 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
336 if (flags
& SHGFI_USEFILEATTRIBUTES
)
338 strcpy (psfi
->szDisplayName
, PathFindFileNameA(szFullPath
));
343 hr
= IShellFolder_GetDisplayNameOf(psfParent
, pidlLast
, SHGDN_INFOLDER
, &str
);
344 StrRetToStrNA (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
348 /* get the type name */
349 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
351 if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
352 _ILGetFileType(pidlLast
, psfi
->szTypeName
, 80);
355 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
356 strcat (psfi
->szTypeName
, "File");
360 strcpy(sTemp
,PathFindExtensionA(szFullPath
));
361 if (!( HCR_MapTypeToValueA(sTemp
, sTemp
, 64, TRUE
)
362 && HCR_MapTypeToValueA(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
364 lstrcpynA (psfi
->szTypeName
, sTemp
, 64);
365 strcat (psfi
->szTypeName
, "-file");
372 if (flags
& SHGFI_LINKOVERLAY
)
373 FIXME("set icon to link, stub\n");
375 if (flags
& SHGFI_SELECTED
)
376 FIXME("set icon to selected, stub\n");
378 if (flags
& SHGFI_SHELLICONSIZE
)
379 FIXME("set icon to shell size, stub\n");
381 /* get the iconlocation */
382 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
385 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1, &pidlLast
, &IID_IExtractIconA
, &uDummy
, (LPVOID
*)&pei
);
389 hr
= IExtractIconA_GetIconLocation(pei
, (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0,szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
390 /* FIXME what to do with the index? */
392 if(uFlags
!= GIL_NOTFILENAME
)
393 strcpy (psfi
->szDisplayName
, szLocation
);
397 IExtractIconA_Release(pei
);
401 /* get icon index (or load icon)*/
402 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
405 if (flags
& SHGFI_USEFILEATTRIBUTES
)
407 char sTemp
[MAX_PATH
];
411 lstrcpynA(sTemp
, szFullPath
, MAX_PATH
);
413 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
418 szExt
= (LPSTR
) PathFindExtensionA(sTemp
);
419 if ( szExt
&& HCR_MapTypeToValueA(szExt
, sTemp
, MAX_PATH
, TRUE
)
420 && HCR_GetDefaultIconA(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
422 if (!strcmp("%1",sTemp
)) /* icon is in the file */
423 strcpy(sTemp
, szFullPath
);
425 if (flags
& SHGFI_SYSICONINDEX
)
427 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,dwNr
);
428 if (psfi
->iIcon
== -1) psfi
->iIcon
= 0;
432 IconNotYetLoaded
=FALSE
;
433 PrivateExtractIconsA(sTemp
,dwNr
,(flags
& SHGFI_SMALLICON
) ?
434 GetSystemMetrics(SM_CXSMICON
) : GetSystemMetrics(SM_CXICON
),
435 (flags
& SHGFI_SMALLICON
) ? GetSystemMetrics(SM_CYSMICON
) :
436 GetSystemMetrics(SM_CYICON
), &psfi
->hIcon
,0,1,0);
444 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
445 (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0, &(psfi
->iIcon
))))
452 ret
= (DWORD
) ((flags
& SHGFI_SMALLICON
) ? ShellSmallIconList
: ShellBigIconList
);
457 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
458 psfi
->hIcon
= ImageList_GetIcon((flags
& SHGFI_SMALLICON
) ? ShellSmallIconList
:ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
460 if (flags
& (SHGFI_UNKNOWN1
| SHGFI_UNKNOWN2
| SHGFI_UNKNOWN3
))
461 FIXME("unknown attribute!\n");
464 IShellFolder_Release(psfParent
);
469 if(pidlLast
) SHFree(pidlLast
);
471 TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
472 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
, psfi
->szDisplayName
, psfi
->szTypeName
, ret
);
477 /*************************************************************************
478 * SHGetFileInfoW [SHELL32.@]
481 DWORD WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
482 SHFILEINFOW
*psfi
, UINT sizeofpsfi
,
488 SHFILEINFOA temppsfi
;
490 if (flags
& SHGFI_PIDL
) {
491 /* path contains a pidl */
492 temppath
= (LPSTR
) path
;
494 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, NULL
, 0, NULL
, NULL
);
495 temppath
= HeapAlloc(GetProcessHeap(), 0, len
);
496 WideCharToMultiByte(CP_ACP
, 0, path
, -1, temppath
, len
, NULL
, NULL
);
499 if(flags
& SHGFI_ATTR_SPECIFIED
)
500 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
502 ret
= SHGetFileInfoA(temppath
, dwFileAttributes
, &temppsfi
, sizeof(temppsfi
), flags
);
504 if(flags
& SHGFI_ICON
)
505 psfi
->hIcon
=temppsfi
.hIcon
;
506 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
507 psfi
->iIcon
=temppsfi
.iIcon
;
508 if(flags
& SHGFI_ATTRIBUTES
)
509 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
510 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
511 MultiByteToWideChar(CP_ACP
, 0, temppsfi
.szDisplayName
, -1, psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
));
512 if(flags
& SHGFI_TYPENAME
)
513 MultiByteToWideChar(CP_ACP
, 0, temppsfi
.szTypeName
, -1, psfi
->szTypeName
, sizeof(psfi
->szTypeName
));
515 if(!(flags
& SHGFI_PIDL
)) HeapFree(GetProcessHeap(), 0, temppath
);
519 /*************************************************************************
520 * SHGetFileInfo [SHELL32.@]
522 DWORD WINAPI
SHGetFileInfoAW(
524 DWORD dwFileAttributes
,
529 if(SHELL_OsIsUnicode())
530 return SHGetFileInfoW(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
531 return SHGetFileInfoA(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
534 /*************************************************************************
535 * DuplicateIcon [SHELL32.@]
537 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
542 TRACE("(%p, %p)\n", hInstance
, hIcon
);
544 if(GetIconInfo(hIcon
, &IconInfo
))
546 hDupIcon
= CreateIconIndirect(&IconInfo
);
548 /* clean up hbmMask and hbmColor */
549 DeleteObject(IconInfo
.hbmMask
);
550 DeleteObject(IconInfo
.hbmColor
);
556 /*************************************************************************
557 * ExtractIconA [SHELL32.@]
559 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
562 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
563 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
565 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
567 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
568 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
569 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
573 /*************************************************************************
574 * ExtractIconW [SHELL32.@]
576 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
580 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
582 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
584 if (nIconIndex
== -1) {
585 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
586 if (ret
!= 0xFFFFFFFF && ret
)
591 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
593 if (ret
== 0xFFFFFFFF)
595 else if (ret
> 0 && hIcon
)
606 #define IDC_STATIC_TEXT 100
607 #define IDC_LISTBOX 99
608 #define IDC_WINE_TEXT 98
610 #define DROP_FIELD_TOP (-15)
611 #define DROP_FIELD_HEIGHT 15
613 static HFONT hIconTitleFont
;
615 static BOOL
__get_dropline( HWND hWnd
, LPRECT lprect
)
616 { HWND hWndCtl
= GetDlgItem(hWnd
, IDC_WINE_TEXT
);
618 { GetWindowRect( hWndCtl
, lprect
);
619 MapWindowPoints( 0, hWnd
, (LPPOINT
)lprect
, 2 );
620 lprect
->bottom
= (lprect
->top
+= DROP_FIELD_TOP
);
626 /*************************************************************************
627 * SHAppBarMessage [SHELL32.@]
629 UINT WINAPI
SHAppBarMessage(DWORD msg
, PAPPBARDATA data
)
631 int width
=data
->rc
.right
- data
->rc
.left
;
632 int height
=data
->rc
.bottom
- data
->rc
.top
;
636 return ABS_ALWAYSONTOP
| ABS_AUTOHIDE
;
637 case ABM_GETTASKBARPOS
:
638 GetWindowRect(data
->hWnd
, &rec
);
642 SetActiveWindow(data
->hWnd
);
644 case ABM_GETAUTOHIDEBAR
:
645 data
->hWnd
=GetActiveWindow();
648 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
,rec
.top
,
649 width
,height
,SWP_SHOWWINDOW
);
652 GetWindowRect(data
->hWnd
, &(data
->rc
));
655 FIXME("ABM_REMOVE broken\n");
656 /* FIXME: this is wrong; should it be DestroyWindow instead? */
657 /*CloseHandle(data->hWnd);*/
659 case ABM_SETAUTOHIDEBAR
:
660 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
+1000,rec
.top
,
661 width
,height
,SWP_SHOWWINDOW
);
664 data
->uEdge
=(ABE_RIGHT
| ABE_LEFT
);
665 SetWindowPos(data
->hWnd
,HWND_TOP
,data
->rc
.left
,data
->rc
.top
,
666 width
,height
,SWP_SHOWWINDOW
);
668 case ABM_WINDOWPOSCHANGED
:
674 /*************************************************************************
675 * SHHelpShortcuts_RunDLL [SHELL32.@]
678 DWORD WINAPI
SHHelpShortcuts_RunDLL (DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
679 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
680 dwArg1
, dwArg2
, dwArg3
, dwArg4
);
685 /*************************************************************************
686 * SHLoadInProc [SHELL32.@]
687 * Create an instance of specified object class from within
688 * the shell process and release it immediately
691 DWORD WINAPI
SHLoadInProc (REFCLSID rclsid
)
695 TRACE("%s\n", debugstr_guid(rclsid
));
697 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
700 IUnknown
* pUnk
= ptr
;
701 IUnknown_Release(pUnk
);
704 return DISP_E_MEMBERNOTFOUND
;
707 /*************************************************************************
708 * AboutDlgProc (internal)
710 INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
713 char Template
[512], AppTitle
[512];
718 { case WM_INITDIALOG
:
719 { ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
721 { const char* const *pstr
= SHELL_People
;
722 SendDlgItemMessageA(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
723 GetWindowTextA( hWnd
, Template
, sizeof(Template
) );
724 sprintf( AppTitle
, Template
, info
->szApp
);
725 SetWindowTextA( hWnd
, AppTitle
);
726 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
),
727 info
->szOtherStuff
);
728 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
729 SendMessageA( hWndCtl
, WM_SETREDRAW
, 0, 0 );
733 SystemParametersInfoA( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
734 hIconTitleFont
= CreateFontIndirectA( &logFont
);
736 SendMessageA( hWndCtl
, WM_SETFONT
, HICON_16(hIconTitleFont
), 0 );
738 { SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)*pstr
);
741 SendMessageA( hWndCtl
, WM_SETREDRAW
, 1, 0 );
749 HDC hDC
= BeginPaint( hWnd
, &ps
);
751 if( __get_dropline( hWnd
, &rect
) ) {
752 SelectObject( hDC
, GetStockObject( BLACK_PEN
) );
753 MoveToEx( hDC
, rect
.left
, rect
.top
, NULL
);
754 LineTo( hDC
, rect
.right
, rect
.bottom
);
756 EndPaint( hWnd
, &ps
);
760 #if 0 /* FIXME: should use DoDragDrop */
761 case WM_LBTRACKPOINT
:
762 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
763 if( (INT16
)GetKeyState( VK_CONTROL
) < 0 )
764 { if( DragDetect( hWndCtl
, *((LPPOINT
)&lParam
) ) )
765 { INT idx
= SendMessageA( hWndCtl
, LB_GETCURSEL
, 0, 0 );
767 { INT length
= SendMessageA( hWndCtl
, LB_GETTEXTLEN
, (WPARAM
)idx
, 0 );
768 HGLOBAL16 hMemObj
= GlobalAlloc16( GMEM_MOVEABLE
, length
+ 1 );
769 char* pstr
= (char*)GlobalLock16( hMemObj
);
772 { HCURSOR hCursor
= LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT
) );
773 SendMessageA( hWndCtl
, LB_GETTEXT
, (WPARAM
)idx
, (LPARAM
)pstr
);
774 SendMessageA( hWndCtl
, LB_DELETESTRING
, (WPARAM
)idx
, 0 );
775 UpdateWindow( hWndCtl
);
776 if( !DragObject16((HWND16
)hWnd
, (HWND16
)hWnd
, DRAGOBJ_DATA
, 0, (WORD
)hMemObj
, hCursor
) )
777 SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)pstr
);
780 GlobalFree16( hMemObj
);
787 case WM_QUERYDROPOBJECT
:
789 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
790 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
)
792 if( __get_dropline( hWnd
, &rect
) )
794 pt
.x
=lpDragInfo
->pt
.x
;
795 pt
.x
=lpDragInfo
->pt
.y
;
796 rect
.bottom
+= DROP_FIELD_HEIGHT
;
797 if( PtInRect( &rect
, pt
) )
798 { SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
807 if( wParam
== (WPARAM
)hWnd
)
808 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
809 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
&& lpDragInfo
->hList
)
810 { char* pstr
= (char*)GlobalLock16( (HGLOBAL16
)(lpDragInfo
->hList
) );
812 { static char __appendix_str
[] = " with";
814 hWndCtl
= GetDlgItem( hWnd
, IDC_WINE_TEXT
);
815 SendMessageA( hWndCtl
, WM_GETTEXT
, 512, (LPARAM
)Template
);
816 if( !strncmp( Template
, "WINE", 4 ) )
817 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
), Template
);
819 { char* pch
= Template
+ strlen(Template
) - strlen(__appendix_str
);
821 SendMessageA( GetDlgItem(hWnd
, IDC_LISTBOX
), LB_ADDSTRING
,
822 (WPARAM
)-1, (LPARAM
)Template
);
825 strcpy( Template
, pstr
);
826 strcat( Template
, __appendix_str
);
827 SetWindowTextA( hWndCtl
, Template
);
828 SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
837 { EndDialog(hWnd
, TRUE
);
842 EndDialog(hWnd
, TRUE
);
850 /*************************************************************************
851 * ShellAboutA [SHELL32.288]
853 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
,
860 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
862 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
866 info
.szOtherStuff
= szOtherStuff
;
868 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
869 return DialogBoxIndirectParamA( (HINSTANCE
)GetWindowLongA( hWnd
, GWL_HINSTANCE
),
870 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
874 /*************************************************************************
875 * ShellAboutW [SHELL32.289]
877 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
886 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
888 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
891 info
.szApp
= HEAP_strdupWtoA( GetProcessHeap(), 0, szApp
);
892 info
.szOtherStuff
= HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff
);
894 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
895 ret
= DialogBoxIndirectParamA((HINSTANCE
)GetWindowLongA( hWnd
, GWL_HINSTANCE
),
896 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
897 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szApp
);
898 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szOtherStuff
);
902 /*************************************************************************
903 * FreeIconList (SHELL32.@)
905 void WINAPI
FreeIconList( DWORD dw
)
906 { FIXME("(%lx): stub\n",dw
);
909 /***********************************************************************
910 * DllGetVersion [SHELL32.@]
912 * Retrieves version information of the 'SHELL32.DLL'
915 * pdvi [O] pointer to version information structure.
919 * Failure: E_INVALIDARG
922 * Returns version of a shell32.dll from IE4.01 SP1.
925 HRESULT WINAPI
SHELL32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
927 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
))
929 WARN("wrong DLLVERSIONINFO size from app\n");
933 pdvi
->dwMajorVersion
= 4;
934 pdvi
->dwMinorVersion
= 72;
935 pdvi
->dwBuildNumber
= 3110;
936 pdvi
->dwPlatformID
= 1;
938 TRACE("%lu.%lu.%lu.%lu\n",
939 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
940 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
944 /*************************************************************************
945 * global variables of the shell32.dll
946 * all are once per process
949 void (WINAPI
*pDLLInitComctl
)(LPVOID
);
951 LPVOID (WINAPI
*pCOMCTL32_Alloc
) (INT
);
952 BOOL (WINAPI
*pCOMCTL32_Free
) (LPVOID
);
954 HANDLE (WINAPI
*pCreateMRUListA
) (LPVOID lpcml
);
955 DWORD (WINAPI
*pFreeMRUListA
) (HANDLE hMRUList
);
956 INT (WINAPI
*pAddMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
957 INT (WINAPI
*pFindMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
958 INT (WINAPI
*pEnumMRUListA
) (HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
960 static HINSTANCE hComctl32
;
962 HINSTANCE shell32_hInstance
= 0;
963 HIMAGELIST ShellSmallIconList
= 0;
964 HIMAGELIST ShellBigIconList
= 0;
967 /*************************************************************************
971 * calling oleinitialize here breaks sone apps.
974 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
976 TRACE("%p 0x%lx %p\n", hinstDLL
, fdwReason
, fImpLoad
);
980 case DLL_PROCESS_ATTACH
:
981 shell32_hInstance
= hinstDLL
;
982 hComctl32
= GetModuleHandleA("COMCTL32.DLL");
983 DisableThreadLibraryCalls(shell32_hInstance
);
987 ERR("P A N I C SHELL32 loading failed\n");
992 pDLLInitComctl
=(void*)GetProcAddress(hComctl32
,"InitCommonControlsEx");
993 /* initialize the common controls */
996 pDLLInitComctl(NULL
);
1001 InitChangeNotifications();
1002 SHInitRestricted(NULL
, NULL
);
1005 case DLL_THREAD_ATTACH
:
1008 case DLL_THREAD_DETACH
:
1011 case DLL_PROCESS_DETACH
:
1012 shell32_hInstance
= 0;
1014 FreeChangeNotifications();
1020 /*************************************************************************
1021 * DllInstall [SHELL32.@]
1025 * BOOL bInstall - TRUE for install, FALSE for uninstall
1026 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1029 HRESULT WINAPI
SHELL32_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1031 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1033 return S_OK
; /* indicate success */
1036 /***********************************************************************
1037 * DllCanUnloadNow (SHELL32.@)
1039 HRESULT WINAPI
SHELL32_DllCanUnloadNow(void)
1041 FIXME("(void): stub\n");