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
41 #include "undocshell.h"
42 #include "wine/winuser16.h"
46 #include "shell32_main.h"
48 #include "wine/debug.h"
49 #include "wine/unicode.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
54 /*************************************************************************
55 * CommandLineToArgvW [SHELL32.@]
57 * We must interpret the quotes in the command line to rebuild the argv
59 * - arguments are separated by spaces or tabs
60 * - quotes serve as optional argument delimiters
62 * - escaped quotes must be converted back to '"'
64 * - an odd number of '\'s followed by '"' correspond to half that number
65 * of '\' followed by a '"' (extension of the above)
68 * - an even number of '\'s followed by a '"' correspond to half that number
69 * of '\', plus a regular quote serving as an argument delimiter (which
70 * means it does not appear in the result)
71 * 'a\\"b c"' -> 'a\b c'
72 * 'a\\\\"b c"' -> 'a\\b c'
73 * - '\' that are not followed by a '"' are copied literally
83 LPWSTR
* WINAPI
CommandLineToArgvW(LPCWSTR lpCmdline
, int* numargs
)
94 /* Return the path to the executable */
101 hargv
=GlobalReAlloc(hargv
, size
, 0);
102 argv
=GlobalLock(hargv
);
103 } while (GetModuleFileNameW(0, (LPWSTR
)(argv
+1), size
-sizeof(LPWSTR
)) == 0);
104 argv
[0]=(LPWSTR
)(argv
+1);
111 /* to get a writeable copy */
117 if (*cs
==0 || ((*cs
==0x0009 || *cs
==0x0020) && !in_quotes
)) {
120 /* skip the remaining spaces */
121 while (*cs
==0x0009 || *cs
==0x0020) {
128 } else if (*cs
==0x005c) {
129 /* '\', count them */
131 } else if ((*cs
==0x0022) && ((bcount
& 1)==0)) {
133 in_quotes
=!in_quotes
;
136 /* a regular character */
141 /* Allocate in a single lump, the string array, and the strings that go with it.
142 * This way the caller can make a single GlobalFree call to free both, as per MSDN.
144 hargv
=GlobalAlloc(0, argc
*sizeof(LPWSTR
)+(strlenW(lpCmdline
)+1)*sizeof(WCHAR
));
145 argv
=GlobalLock(hargv
);
148 cmdline
=(LPWSTR
)(argv
+argc
);
149 strcpyW(cmdline
, lpCmdline
);
156 if ((*s
==0x0009 || *s
==0x0020) && !in_quotes
) {
157 /* Close the argument and copy it */
161 /* skip the remaining spaces */
164 } while (*s
==0x0009 || *s
==0x0020);
166 /* Start with a new argument */
169 } else if (*s
==0x005c) {
173 } else if (*s
==0x0022) {
175 if ((bcount
& 1)==0) {
176 /* Preceeded by an even number of '\', this is half that
177 * number of '\', plus a quote which we erase.
180 in_quotes
=!in_quotes
;
183 /* Preceeded by an odd number of '\', this is half that
184 * number of '\' followed by a '"'
192 /* a regular character */
207 /*************************************************************************
208 * SHGetFileInfoA [SHELL32.@]
212 DWORD WINAPI
SHGetFileInfoA(LPCSTR path
,DWORD dwFileAttributes
,
213 SHFILEINFOA
*psfi
, UINT sizeofpsfi
,
216 char szLocation
[MAX_PATH
], szFullPath
[MAX_PATH
];
218 DWORD ret
= TRUE
, dwAttributes
= 0;
219 IShellFolder
* psfParent
= NULL
;
220 IExtractIconA
* pei
= NULL
;
221 LPITEMIDLIST pidlLast
= NULL
, pidl
= NULL
;
223 BOOL IconNotYetLoaded
=TRUE
;
225 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
226 (flags
& SHGFI_PIDL
)? "pidl" : path
, dwFileAttributes
, psfi
, psfi
->dwAttributes
, sizeofpsfi
, flags
);
228 if ((flags
& SHGFI_USEFILEATTRIBUTES
) && (flags
& (SHGFI_ATTRIBUTES
|SHGFI_EXETYPE
|SHGFI_PIDL
)))
231 /* windows initializes this values regardless of the flags */
233 psfi
->szDisplayName
[0] = '\0';
234 psfi
->szTypeName
[0] = '\0';
238 if (!(flags
& SHGFI_PIDL
)){
239 /* SHGitFileInfo should work with absolute and relative paths */
240 if (PathIsRelativeA(path
)){
241 GetCurrentDirectoryA(MAX_PATH
, szLocation
);
242 PathCombineA(szFullPath
, szLocation
, path
);
244 lstrcpynA(szFullPath
, path
, MAX_PATH
);
248 if (flags
& SHGFI_EXETYPE
) {
252 IMAGE_DOS_HEADER mz_header
;
257 if (flags
!= SHGFI_EXETYPE
) return 0;
259 status
= GetBinaryTypeA (szFullPath
, &BinaryType
);
260 if (!status
) return 0;
261 if ((BinaryType
== SCS_DOS_BINARY
)
262 || (BinaryType
== SCS_PIF_BINARY
)) return 0x4d5a;
264 hfile
= CreateFileA( szFullPath
, GENERIC_READ
, FILE_SHARE_READ
,
265 NULL
, OPEN_EXISTING
, 0, 0 );
266 if ( hfile
== INVALID_HANDLE_VALUE
) return 0;
268 /* The next section is adapted from MODULE_GetBinaryType, as we need
269 * to examine the image header to get OS and version information. We
270 * know from calling GetBinaryTypeA that the image is valid and either
271 * an NE or PE, so much error handling can be omitted.
272 * Seek to the start of the file and read the header information.
275 SetFilePointer( hfile
, 0, NULL
, SEEK_SET
);
276 ReadFile( hfile
, &mz_header
, sizeof(mz_header
), &len
, NULL
);
278 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
279 ReadFile( hfile
, magic
, sizeof(magic
), &len
, NULL
);
280 if ( *(DWORD
*)magic
== IMAGE_NT_SIGNATURE
)
282 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
283 ReadFile( hfile
, &nt
, sizeof(nt
), &len
, NULL
);
284 CloseHandle( hfile
);
285 if (nt
.OptionalHeader
.Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_GUI
) {
286 return IMAGE_NT_SIGNATURE
287 | (nt
.OptionalHeader
.MajorSubsystemVersion
<< 24)
288 | (nt
.OptionalHeader
.MinorSubsystemVersion
<< 16);
290 return IMAGE_NT_SIGNATURE
;
292 else if ( *(WORD
*)magic
== IMAGE_OS2_SIGNATURE
)
295 SetFilePointer( hfile
, mz_header
.e_lfanew
, NULL
, SEEK_SET
);
296 ReadFile( hfile
, &ne
, sizeof(ne
), &len
, NULL
);
297 CloseHandle( hfile
);
298 if (ne
.ne_exetyp
== 2) return IMAGE_OS2_SIGNATURE
299 | (ne
.ne_expver
<< 16);
302 CloseHandle( hfile
);
306 /* psfi is NULL normally to query EXE type. If it is NULL, none of the
307 * below makes sense anyway. Windows allows this and just returns FALSE */
308 if (psfi
== NULL
) return FALSE
;
310 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES
312 The pidl functions fail on not existing file names */
314 if (flags
& SHGFI_PIDL
) {
315 pidl
= ILClone((LPCITEMIDLIST
)path
);
316 } else if (!(flags
& SHGFI_USEFILEATTRIBUTES
)) {
317 hr
= SHILCreateFromPathA(szFullPath
, &pidl
, &dwAttributes
);
320 if ((flags
& SHGFI_PIDL
) || !(flags
& SHGFI_USEFILEATTRIBUTES
))
322 /* get the parent shellfolder */
324 hr
= SHBindToParent(pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
, (LPCITEMIDLIST
*)&pidlLast
);
327 ERR("pidl is null!\n");
332 /* get the attributes of the child */
333 if (SUCCEEDED(hr
) && (flags
& SHGFI_ATTRIBUTES
))
335 if (!(flags
& SHGFI_ATTR_SPECIFIED
))
337 psfi
->dwAttributes
= 0xffffffff;
339 IShellFolder_GetAttributesOf(psfParent
, 1, (LPCITEMIDLIST
*)&pidlLast
, &(psfi
->dwAttributes
));
342 /* get the displayname */
343 if (SUCCEEDED(hr
) && (flags
& SHGFI_DISPLAYNAME
))
345 if (flags
& SHGFI_USEFILEATTRIBUTES
)
347 strcpy (psfi
->szDisplayName
, PathFindFileNameA(szFullPath
));
352 hr
= IShellFolder_GetDisplayNameOf(psfParent
, pidlLast
, SHGDN_INFOLDER
, &str
);
353 StrRetToStrNA (psfi
->szDisplayName
, MAX_PATH
, &str
, pidlLast
);
357 /* get the type name */
358 if (SUCCEEDED(hr
) && (flags
& SHGFI_TYPENAME
))
360 if (!(flags
& SHGFI_USEFILEATTRIBUTES
))
361 _ILGetFileType(pidlLast
, psfi
->szTypeName
, 80);
364 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
365 strcat (psfi
->szTypeName
, "File");
369 strcpy(sTemp
,PathFindExtensionA(szFullPath
));
370 if (!( HCR_MapTypeToValueA(sTemp
, sTemp
, 64, TRUE
)
371 && HCR_MapTypeToValueA(sTemp
, psfi
->szTypeName
, 80, FALSE
)))
373 lstrcpynA (psfi
->szTypeName
, sTemp
, 64);
374 strcat (psfi
->szTypeName
, "-file");
381 if (flags
& SHGFI_LINKOVERLAY
)
382 FIXME("set icon to link, stub\n");
384 if (flags
& SHGFI_SELECTED
)
385 FIXME("set icon to selected, stub\n");
387 if (flags
& SHGFI_SHELLICONSIZE
)
388 FIXME("set icon to shell size, stub\n");
390 /* get the iconlocation */
391 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICONLOCATION
))
394 hr
= IShellFolder_GetUIObjectOf(psfParent
, 0, 1, (LPCITEMIDLIST
*)&pidlLast
, &IID_IExtractIconA
, &uDummy
, (LPVOID
*)&pei
);
398 hr
= IExtractIconA_GetIconLocation(pei
, (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0,szLocation
, MAX_PATH
, &iIndex
, &uFlags
);
399 psfi
->iIcon
= iIndex
;
401 if(uFlags
!= GIL_NOTFILENAME
)
402 strcpy (psfi
->szDisplayName
, szLocation
);
406 IExtractIconA_Release(pei
);
410 /* get icon index (or load icon)*/
411 if (SUCCEEDED(hr
) && (flags
& (SHGFI_ICON
| SHGFI_SYSICONINDEX
)))
414 if (flags
& SHGFI_USEFILEATTRIBUTES
)
416 char sTemp
[MAX_PATH
];
420 lstrcpynA(sTemp
, szFullPath
, MAX_PATH
);
422 if (dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
427 szExt
= (LPSTR
) PathFindExtensionA(sTemp
);
428 if ( szExt
&& HCR_MapTypeToValueA(szExt
, sTemp
, MAX_PATH
, TRUE
)
429 && HCR_GetDefaultIconA(sTemp
, sTemp
, MAX_PATH
, &dwNr
))
431 if (!strcmp("%1",sTemp
)) /* icon is in the file */
432 strcpy(sTemp
, szFullPath
);
434 if (flags
& SHGFI_SYSICONINDEX
)
436 psfi
->iIcon
= SIC_GetIconIndex(sTemp
,dwNr
);
437 if (psfi
->iIcon
== -1) psfi
->iIcon
= 0;
441 IconNotYetLoaded
=FALSE
;
442 PrivateExtractIconsA(sTemp
,dwNr
,(flags
& SHGFI_SMALLICON
) ?
443 GetSystemMetrics(SM_CXSMICON
) : GetSystemMetrics(SM_CXICON
),
444 (flags
& SHGFI_SMALLICON
) ? GetSystemMetrics(SM_CYSMICON
) :
445 GetSystemMetrics(SM_CYICON
), &psfi
->hIcon
,0,1,0);
453 if (!(PidlToSicIndex(psfParent
, pidlLast
, !(flags
& SHGFI_SMALLICON
),
454 (flags
& SHGFI_OPENICON
)? GIL_OPENICON
: 0, &(psfi
->iIcon
))))
461 ret
= (DWORD
) ((flags
& SHGFI_SMALLICON
) ? ShellSmallIconList
: ShellBigIconList
);
466 if (SUCCEEDED(hr
) && (flags
& SHGFI_ICON
) && IconNotYetLoaded
)
467 psfi
->hIcon
= ImageList_GetIcon((flags
& SHGFI_SMALLICON
) ? ShellSmallIconList
:ShellBigIconList
, psfi
->iIcon
, ILD_NORMAL
);
469 if (flags
& (SHGFI_UNKNOWN1
| SHGFI_UNKNOWN2
| SHGFI_UNKNOWN3
))
470 FIXME("unknown attribute!\n");
473 IShellFolder_Release(psfParent
);
478 if(pidlLast
) SHFree(pidlLast
);
480 TRACE ("icon=%p index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
481 psfi
->hIcon
, psfi
->iIcon
, psfi
->dwAttributes
, psfi
->szDisplayName
, psfi
->szTypeName
, ret
);
486 /*************************************************************************
487 * SHGetFileInfoW [SHELL32.@]
490 DWORD WINAPI
SHGetFileInfoW(LPCWSTR path
,DWORD dwFileAttributes
,
491 SHFILEINFOW
*psfi
, UINT sizeofpsfi
,
497 SHFILEINFOA temppsfi
;
499 if (flags
& SHGFI_PIDL
) {
500 /* path contains a pidl */
501 temppath
= (LPSTR
) path
;
503 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, NULL
, 0, NULL
, NULL
);
504 temppath
= HeapAlloc(GetProcessHeap(), 0, len
);
505 WideCharToMultiByte(CP_ACP
, 0, path
, -1, temppath
, len
, NULL
, NULL
);
508 if(psfi
&& (flags
& SHGFI_ATTR_SPECIFIED
))
509 temppsfi
.dwAttributes
=psfi
->dwAttributes
;
511 ret
= SHGetFileInfoA(temppath
, dwFileAttributes
, (psfi
== NULL
)? NULL
: &temppsfi
, sizeof(temppsfi
), flags
);
515 if(flags
& SHGFI_ICON
)
516 psfi
->hIcon
=temppsfi
.hIcon
;
517 if(flags
& (SHGFI_SYSICONINDEX
|SHGFI_ICON
|SHGFI_ICONLOCATION
))
518 psfi
->iIcon
=temppsfi
.iIcon
;
519 if(flags
& SHGFI_ATTRIBUTES
)
520 psfi
->dwAttributes
=temppsfi
.dwAttributes
;
521 if(flags
& (SHGFI_DISPLAYNAME
|SHGFI_ICONLOCATION
))
522 MultiByteToWideChar(CP_ACP
, 0, temppsfi
.szDisplayName
, -1, psfi
->szDisplayName
, sizeof(psfi
->szDisplayName
));
523 if(flags
& SHGFI_TYPENAME
)
524 MultiByteToWideChar(CP_ACP
, 0, temppsfi
.szTypeName
, -1, psfi
->szTypeName
, sizeof(psfi
->szTypeName
));
526 if(!(flags
& SHGFI_PIDL
)) HeapFree(GetProcessHeap(), 0, temppath
);
530 /*************************************************************************
531 * SHGetFileInfo [SHELL32.@]
533 DWORD WINAPI
SHGetFileInfoAW(
535 DWORD dwFileAttributes
,
540 if(SHELL_OsIsUnicode())
541 return SHGetFileInfoW(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
542 return SHGetFileInfoA(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
545 /*************************************************************************
546 * DuplicateIcon [SHELL32.@]
548 HICON WINAPI
DuplicateIcon( HINSTANCE hInstance
, HICON hIcon
)
553 TRACE("(%p, %p)\n", hInstance
, hIcon
);
555 if(GetIconInfo(hIcon
, &IconInfo
))
557 hDupIcon
= CreateIconIndirect(&IconInfo
);
559 /* clean up hbmMask and hbmColor */
560 DeleteObject(IconInfo
.hbmMask
);
561 DeleteObject(IconInfo
.hbmColor
);
567 /*************************************************************************
568 * ExtractIconA [SHELL32.@]
570 HICON WINAPI
ExtractIconA(HINSTANCE hInstance
, LPCSTR lpszFile
, UINT nIconIndex
)
573 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, NULL
, 0);
574 LPWSTR lpwstrFile
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
576 TRACE("%p %s %d\n", hInstance
, lpszFile
, nIconIndex
);
578 MultiByteToWideChar(CP_ACP
, 0, lpszFile
, -1, lpwstrFile
, len
);
579 ret
= ExtractIconW(hInstance
, lpwstrFile
, nIconIndex
);
580 HeapFree(GetProcessHeap(), 0, lpwstrFile
);
584 /*************************************************************************
585 * ExtractIconW [SHELL32.@]
587 HICON WINAPI
ExtractIconW(HINSTANCE hInstance
, LPCWSTR lpszFile
, UINT nIconIndex
)
591 UINT cx
= GetSystemMetrics(SM_CXICON
), cy
= GetSystemMetrics(SM_CYICON
);
593 TRACE("%p %s %d\n", hInstance
, debugstr_w(lpszFile
), nIconIndex
);
595 if (nIconIndex
== -1) {
596 ret
= PrivateExtractIconsW(lpszFile
, 0, cx
, cy
, NULL
, NULL
, 0, LR_DEFAULTCOLOR
);
597 if (ret
!= 0xFFFFFFFF && ret
)
602 ret
= PrivateExtractIconsW(lpszFile
, nIconIndex
, cx
, cy
, &hIcon
, NULL
, 1, LR_DEFAULTCOLOR
);
604 if (ret
== 0xFFFFFFFF)
606 else if (ret
> 0 && hIcon
)
617 #define IDC_STATIC_TEXT 100
618 #define IDC_LISTBOX 99
619 #define IDC_WINE_TEXT 98
621 #define DROP_FIELD_TOP (-15)
622 #define DROP_FIELD_HEIGHT 15
624 static HFONT hIconTitleFont
;
626 static BOOL
__get_dropline( HWND hWnd
, LPRECT lprect
)
627 { HWND hWndCtl
= GetDlgItem(hWnd
, IDC_WINE_TEXT
);
629 { GetWindowRect( hWndCtl
, lprect
);
630 MapWindowPoints( 0, hWnd
, (LPPOINT
)lprect
, 2 );
631 lprect
->bottom
= (lprect
->top
+= DROP_FIELD_TOP
);
637 /*************************************************************************
638 * SHAppBarMessage [SHELL32.@]
640 UINT WINAPI
SHAppBarMessage(DWORD msg
, PAPPBARDATA data
)
642 int width
=data
->rc
.right
- data
->rc
.left
;
643 int height
=data
->rc
.bottom
- data
->rc
.top
;
647 return ABS_ALWAYSONTOP
| ABS_AUTOHIDE
;
648 case ABM_GETTASKBARPOS
:
649 GetWindowRect(data
->hWnd
, &rec
);
653 SetActiveWindow(data
->hWnd
);
655 case ABM_GETAUTOHIDEBAR
:
656 data
->hWnd
=GetActiveWindow();
659 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
,rec
.top
,
660 width
,height
,SWP_SHOWWINDOW
);
663 GetWindowRect(data
->hWnd
, &(data
->rc
));
666 FIXME("ABM_REMOVE broken\n");
667 /* FIXME: this is wrong; should it be DestroyWindow instead? */
668 /*CloseHandle(data->hWnd);*/
670 case ABM_SETAUTOHIDEBAR
:
671 SetWindowPos(data
->hWnd
,HWND_TOP
,rec
.left
+1000,rec
.top
,
672 width
,height
,SWP_SHOWWINDOW
);
675 data
->uEdge
=(ABE_RIGHT
| ABE_LEFT
);
676 SetWindowPos(data
->hWnd
,HWND_TOP
,data
->rc
.left
,data
->rc
.top
,
677 width
,height
,SWP_SHOWWINDOW
);
679 case ABM_WINDOWPOSCHANGED
:
685 /*************************************************************************
686 * SHHelpShortcuts_RunDLL [SHELL32.@]
689 DWORD WINAPI
SHHelpShortcuts_RunDLL (DWORD dwArg1
, DWORD dwArg2
, DWORD dwArg3
, DWORD dwArg4
)
690 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
691 dwArg1
, dwArg2
, dwArg3
, dwArg4
);
696 /*************************************************************************
697 * SHLoadInProc [SHELL32.@]
698 * Create an instance of specified object class from within
699 * the shell process and release it immediately
702 DWORD WINAPI
SHLoadInProc (REFCLSID rclsid
)
706 TRACE("%s\n", debugstr_guid(rclsid
));
708 CoCreateInstance(rclsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,&ptr
);
711 IUnknown
* pUnk
= ptr
;
712 IUnknown_Release(pUnk
);
715 return DISP_E_MEMBERNOTFOUND
;
718 /*************************************************************************
719 * AboutDlgProc (internal)
721 INT_PTR CALLBACK
AboutDlgProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
724 char Template
[512], AppTitle
[512];
729 { case WM_INITDIALOG
:
730 { ABOUT_INFO
*info
= (ABOUT_INFO
*)lParam
;
732 { const char* const *pstr
= SHELL_People
;
733 SendDlgItemMessageA(hWnd
, stc1
, STM_SETICON
,(WPARAM
)info
->hIcon
, 0);
734 GetWindowTextA( hWnd
, Template
, sizeof(Template
) );
735 sprintf( AppTitle
, Template
, info
->szApp
);
736 SetWindowTextA( hWnd
, AppTitle
);
737 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
),
738 info
->szOtherStuff
);
739 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
740 SendMessageA( hWndCtl
, WM_SETREDRAW
, 0, 0 );
744 SystemParametersInfoA( SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0 );
745 hIconTitleFont
= CreateFontIndirectA( &logFont
);
747 SendMessageA( hWndCtl
, WM_SETFONT
, HICON_16(hIconTitleFont
), 0 );
749 { SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)*pstr
);
752 SendMessageA( hWndCtl
, WM_SETREDRAW
, 1, 0 );
760 HDC hDC
= BeginPaint( hWnd
, &ps
);
762 if( __get_dropline( hWnd
, &rect
) ) {
763 SelectObject( hDC
, GetStockObject( BLACK_PEN
) );
764 MoveToEx( hDC
, rect
.left
, rect
.top
, NULL
);
765 LineTo( hDC
, rect
.right
, rect
.bottom
);
767 EndPaint( hWnd
, &ps
);
771 #if 0 /* FIXME: should use DoDragDrop */
772 case WM_LBTRACKPOINT
:
773 hWndCtl
= GetDlgItem(hWnd
, IDC_LISTBOX
);
774 if( (INT16
)GetKeyState( VK_CONTROL
) < 0 )
775 { if( DragDetect( hWndCtl
, *((LPPOINT
)&lParam
) ) )
776 { INT idx
= SendMessageA( hWndCtl
, LB_GETCURSEL
, 0, 0 );
778 { INT length
= SendMessageA( hWndCtl
, LB_GETTEXTLEN
, (WPARAM
)idx
, 0 );
779 HGLOBAL16 hMemObj
= GlobalAlloc16( GMEM_MOVEABLE
, length
+ 1 );
780 char* pstr
= (char*)GlobalLock16( hMemObj
);
783 { HCURSOR hCursor
= LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT
) );
784 SendMessageA( hWndCtl
, LB_GETTEXT
, (WPARAM
)idx
, (LPARAM
)pstr
);
785 SendMessageA( hWndCtl
, LB_DELETESTRING
, (WPARAM
)idx
, 0 );
786 UpdateWindow( hWndCtl
);
787 if( !DragObject16((HWND16
)hWnd
, (HWND16
)hWnd
, DRAGOBJ_DATA
, 0, (WORD
)hMemObj
, hCursor
) )
788 SendMessageA( hWndCtl
, LB_ADDSTRING
, (WPARAM
)-1, (LPARAM
)pstr
);
791 GlobalFree16( hMemObj
);
798 case WM_QUERYDROPOBJECT
:
800 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
801 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
)
803 if( __get_dropline( hWnd
, &rect
) )
805 pt
.x
=lpDragInfo
->pt
.x
;
806 pt
.x
=lpDragInfo
->pt
.y
;
807 rect
.bottom
+= DROP_FIELD_HEIGHT
;
808 if( PtInRect( &rect
, pt
) )
809 { SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
818 if( wParam
== (WPARAM
)hWnd
)
819 { LPDRAGINFO16 lpDragInfo
= MapSL((SEGPTR
)lParam
);
820 if( lpDragInfo
&& lpDragInfo
->wFlags
== DRAGOBJ_DATA
&& lpDragInfo
->hList
)
821 { char* pstr
= (char*)GlobalLock16( (HGLOBAL16
)(lpDragInfo
->hList
) );
823 { static char __appendix_str
[] = " with";
825 hWndCtl
= GetDlgItem( hWnd
, IDC_WINE_TEXT
);
826 SendMessageA( hWndCtl
, WM_GETTEXT
, 512, (LPARAM
)Template
);
827 if( !strncmp( Template
, "WINE", 4 ) )
828 SetWindowTextA( GetDlgItem(hWnd
, IDC_STATIC_TEXT
), Template
);
830 { char* pch
= Template
+ strlen(Template
) - strlen(__appendix_str
);
832 SendMessageA( GetDlgItem(hWnd
, IDC_LISTBOX
), LB_ADDSTRING
,
833 (WPARAM
)-1, (LPARAM
)Template
);
836 strcpy( Template
, pstr
);
837 strcat( Template
, __appendix_str
);
838 SetWindowTextA( hWndCtl
, Template
);
839 SetWindowLongA( hWnd
, DWL_MSGRESULT
, 1 );
848 { EndDialog(hWnd
, TRUE
);
853 EndDialog(hWnd
, TRUE
);
861 /*************************************************************************
862 * ShellAboutA [SHELL32.288]
864 BOOL WINAPI
ShellAboutA( HWND hWnd
, LPCSTR szApp
, LPCSTR szOtherStuff
,
871 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
873 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
877 info
.szOtherStuff
= szOtherStuff
;
879 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
880 return DialogBoxIndirectParamA( (HINSTANCE
)GetWindowLongA( hWnd
, GWL_HINSTANCE
),
881 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
885 /*************************************************************************
886 * ShellAboutW [SHELL32.289]
888 BOOL WINAPI
ShellAboutW( HWND hWnd
, LPCWSTR szApp
, LPCWSTR szOtherStuff
,
897 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_ABOUT_MSGBOX", RT_DIALOGA
)))
899 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
902 info
.szApp
= HEAP_strdupWtoA( GetProcessHeap(), 0, szApp
);
903 info
.szOtherStuff
= HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff
);
905 if (!hIcon
) info
.hIcon
= LoadIconA( 0, IDI_WINLOGOA
);
906 ret
= DialogBoxIndirectParamA((HINSTANCE
)GetWindowLongA( hWnd
, GWL_HINSTANCE
),
907 template, hWnd
, AboutDlgProc
, (LPARAM
)&info
);
908 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szApp
);
909 HeapFree( GetProcessHeap(), 0, (LPSTR
)info
.szOtherStuff
);
913 /*************************************************************************
914 * FreeIconList (SHELL32.@)
916 void WINAPI
FreeIconList( DWORD dw
)
917 { FIXME("(%lx): stub\n",dw
);
920 /***********************************************************************
921 * DllGetVersion [SHELL32.@]
923 * Retrieves version information of the 'SHELL32.DLL'
926 * pdvi [O] pointer to version information structure.
930 * Failure: E_INVALIDARG
933 * Returns version of a shell32.dll from IE4.01 SP1.
936 HRESULT WINAPI
SHELL32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
938 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
))
940 WARN("wrong DLLVERSIONINFO size from app\n");
944 pdvi
->dwMajorVersion
= 4;
945 pdvi
->dwMinorVersion
= 72;
946 pdvi
->dwBuildNumber
= 3110;
947 pdvi
->dwPlatformID
= 1;
949 TRACE("%lu.%lu.%lu.%lu\n",
950 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
951 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
955 /*************************************************************************
956 * global variables of the shell32.dll
957 * all are once per process
960 void (WINAPI
*pDLLInitComctl
)(LPVOID
);
962 LPVOID (WINAPI
*pCOMCTL32_Alloc
) (INT
);
963 BOOL (WINAPI
*pCOMCTL32_Free
) (LPVOID
);
965 HANDLE (WINAPI
*pCreateMRUListA
) (LPVOID lpcml
);
966 DWORD (WINAPI
*pFreeMRUListA
) (HANDLE hMRUList
);
967 INT (WINAPI
*pAddMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
968 INT (WINAPI
*pFindMRUData
) (HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
969 INT (WINAPI
*pEnumMRUListA
) (HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
971 static HINSTANCE hComctl32
;
973 HINSTANCE shell32_hInstance
= 0;
974 HIMAGELIST ShellSmallIconList
= 0;
975 HIMAGELIST ShellBigIconList
= 0;
978 /*************************************************************************
982 * calling oleinitialize here breaks sone apps.
985 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
987 TRACE("%p 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 /* initialize the common controls */
1007 pDLLInitComctl(NULL
);
1012 InitChangeNotifications();
1013 SHInitRestricted(NULL
, NULL
);
1016 case DLL_PROCESS_DETACH
:
1017 shell32_hInstance
= 0;
1019 FreeChangeNotifications();
1025 /*************************************************************************
1026 * DllInstall [SHELL32.@]
1030 * BOOL bInstall - TRUE for install, FALSE for uninstall
1031 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1034 HRESULT WINAPI
SHELL32_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1036 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
1038 return S_OK
; /* indicate success */
1041 /***********************************************************************
1042 * DllCanUnloadNow (SHELL32.@)
1044 HRESULT WINAPI
SHELL32_DllCanUnloadNow(void)
1046 FIXME("(void): stub\n");