Added sample config file in the new format.
[wine/multimedia.git] / dlls / shell32 / shell32_main.c
blobae2690eaf68afe7551d9d42369cd07c4f550cf3d
1 /*
2 * Shell basics
4 * 1998 Marcus Meissner
5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
6 */
7 #include <stdlib.h>
8 #include <string.h>
9 #include <stdio.h>
11 #include "windef.h"
12 #include "wingdi.h"
13 #include "wine/winuser16.h"
14 #include "winerror.h"
15 #include "heap.h"
16 #include "dlgs.h"
17 #include "ldt.h"
18 #include "debugtools.h"
19 #include "winreg.h"
20 #include "authors.h"
22 #include "shellapi.h"
23 #include "pidl.h"
25 #include "shell32_main.h"
26 #include "wine/undocshell.h"
27 #include "shlobj.h"
28 #include "shlguid.h"
29 #include "shlwapi.h"
31 DEFAULT_DEBUG_CHANNEL(shell);
33 #define MORE_DEBUG 1
34 /*************************************************************************
35 * CommandLineToArgvW [SHELL32.7]
37 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
38 { LPWSTR *argv,s,t;
39 int i;
40 TRACE("\n");
42 /* to get writeable copy */
43 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
44 s=cmdline;i=0;
45 while (*s)
46 { /* space */
47 if (*s==0x0020)
48 { i++;
49 s++;
50 while (*s && *s==0x0020)
51 s++;
52 continue;
54 s++;
56 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
57 s=t=cmdline;
58 i=0;
59 while (*s)
60 { if (*s==0x0020)
61 { *s=0;
62 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
63 *s=0x0020;
64 while (*s && *s==0x0020)
65 s++;
66 t=s;
67 continue;
69 s++;
71 if (*t)
72 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
74 HeapFree( GetProcessHeap(), 0, cmdline );
75 argv[i]=NULL;
76 *numargs=i;
77 return argv;
80 /*************************************************************************
81 * Control_RunDLL [SHELL32.12]
83 * Wild speculation in the following!
85 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
88 void WINAPI Control_RunDLL( HWND hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
90 FIXME("(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
91 debugstr_a(cmd), arg4);
94 /*************************************************************************
95 * SHGetFileInfoA [SHELL32.@]
99 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
100 SHFILEINFOA *psfi, UINT sizeofpsfi,
101 UINT flags )
103 char szLoaction[MAX_PATH];
104 int iIndex;
105 DWORD ret = TRUE, dwAttributes = 0;
106 IShellFolder * psfParent = NULL;
107 IExtractIconA * pei = NULL;
108 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
109 HRESULT hr = S_OK;
111 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
112 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
114 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
115 return FALSE;
117 /* windows initializes this values regardless of the flags */
118 psfi->szDisplayName[0] = '\0';
119 psfi->szTypeName[0] = '\0';
120 psfi->iIcon = 0;
122 if (flags & SHGFI_EXETYPE) {
123 BOOL status = FALSE;
124 HANDLE hfile;
125 DWORD BinaryType;
126 IMAGE_DOS_HEADER mz_header;
127 IMAGE_NT_HEADERS nt;
128 DWORD len;
129 char magic[4];
131 if (flags != SHGFI_EXETYPE) return 0;
133 status = GetBinaryTypeA (path, &BinaryType);
134 if (!status) return 0;
135 if ((BinaryType == SCS_DOS_BINARY)
136 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
138 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
139 NULL, OPEN_EXISTING, 0, -1 );
140 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
142 /* The next section is adapted from MODULE_GetBinaryType, as we need
143 * to examine the image header to get OS and version information. We
144 * know from calling GetBinaryTypeA that the image is valid and either
145 * an NE or PE, so much error handling can be omitted.
146 * Seek to the start of the file and read the header information.
149 SetFilePointer( hfile, 0, NULL, SEEK_SET );
150 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
152 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
153 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
154 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
156 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
157 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
158 CloseHandle( hfile );
159 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
160 return IMAGE_NT_SIGNATURE
161 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
162 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
164 return IMAGE_NT_SIGNATURE;
166 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
168 IMAGE_OS2_HEADER ne;
169 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
170 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
171 CloseHandle( hfile );
172 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
173 | (ne.ne_expver << 16);
174 return 0;
176 CloseHandle( hfile );
177 return 0;
181 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
182 the pidl functions fail on not existing file names */
183 if (flags & SHGFI_PIDL)
185 pidl = (LPCITEMIDLIST) path;
186 if (!pidl )
188 ERR("pidl is null!\n");
189 return FALSE;
192 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
194 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
195 /* note: the attributes in ISF::ParseDisplayName are not implemented */
198 /* get the parent shellfolder */
199 if (pidl)
201 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
204 /* get the attributes of the child */
205 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
207 if (!(flags & SHGFI_ATTR_SPECIFIED))
209 psfi->dwAttributes = 0xffffffff;
211 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
214 /* get the displayname */
215 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
217 if (flags & SHGFI_USEFILEATTRIBUTES)
219 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
221 else
223 STRRET str;
224 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
225 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
229 /* get the type name */
230 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
232 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
235 /* ### icons ###*/
236 if (flags & SHGFI_LINKOVERLAY)
237 FIXME("set icon to link, stub\n");
239 if (flags & SHGFI_SELECTED)
240 FIXME("set icon to selected, stub\n");
242 if (flags & SHGFI_SHELLICONSIZE)
243 FIXME("set icon to shell size, stub\n");
245 /* get the iconlocation */
246 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
248 UINT uDummy,uFlags;
249 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
251 if (SUCCEEDED(hr))
253 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
254 /* fixme what to do with the index? */
256 if(uFlags != GIL_NOTFILENAME)
257 strcpy (psfi->szDisplayName, szLoaction);
258 else
259 ret = FALSE;
261 IExtractIconA_Release(pei);
265 /* get icon index (or load icon)*/
266 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
268 if (flags & SHGFI_USEFILEATTRIBUTES)
270 char sTemp [MAX_PATH];
271 char * szExt;
272 DWORD dwNr=0;
274 lstrcpynA(sTemp, path, MAX_PATH);
275 szExt = (LPSTR) PathFindExtensionA(sTemp);
276 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
277 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
279 if (!strcmp("%1",sTemp)) /* icon is in the file */
281 strcpy(sTemp, path);
283 /* FIXME: if sTemp contains a valid filename, get the icon
284 from there, index is in dwNr
286 psfi->iIcon = 2;
288 else /* default icon */
290 psfi->iIcon = 0;
293 else
295 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
296 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
298 ret = FALSE;
301 if (ret)
303 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
307 /* icon handle */
308 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
309 psfi->hIcon = pImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
311 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
312 FIXME("unknown attribute!\n");
314 if (psfParent)
315 IShellFolder_Release(psfParent);
317 if (hr != S_OK)
318 ret = FALSE;
320 if(pidlLast) SHFree(pidlLast);
321 #ifdef MORE_DEBUG
322 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
323 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
324 #endif
325 return ret;
328 /*************************************************************************
329 * SHGetFileInfoW [SHELL32.@]
332 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
333 SHFILEINFOW *psfi, UINT sizeofpsfi,
334 UINT flags )
335 { FIXME("(%s,0x%lx,%p,0x%x,0x%x)\n",
336 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
337 return 0;
340 /*************************************************************************
341 * SHGetFileInfoAW [SHELL32.@]
343 DWORD WINAPI SHGetFileInfoAW(
344 LPCVOID path,
345 DWORD dwFileAttributes,
346 LPVOID psfi,
347 UINT sizeofpsfi,
348 UINT flags)
350 if(SHELL_OsIsUnicode())
351 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
352 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
355 /*************************************************************************
356 * DuplicateIcon [SHELL32.188]
358 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
360 ICONINFO IconInfo;
361 HICON hDupIcon = 0;
363 TRACE("(%04x, %04x)\n", hInstance, hIcon);
365 if(GetIconInfo(hIcon, &IconInfo))
367 hDupIcon = CreateIconIndirect(&IconInfo);
369 /* clean up hbmMask and hbmColor */
370 DeleteObject(IconInfo.hbmMask);
371 DeleteObject(IconInfo.hbmColor);
374 return hDupIcon;
378 /*************************************************************************
379 * ExtractIconA [SHELL32.133]
381 * FIXME
382 * if the filename is not a file return 1
384 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
385 UINT nIconIndex )
386 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
387 TRACE("\n");
388 if( handle )
390 HICON16* ptr = (HICON16*)GlobalLock16(handle);
391 HICON16 hIcon = *ptr;
393 GlobalFree16(handle);
394 return hIcon;
396 return 0;
399 /*************************************************************************
400 * ExtractIconW [SHELL32.180]
402 * fixme
403 * is the filename is not a file return 1
405 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
406 UINT nIconIndex )
407 { LPSTR exefn;
408 HICON ret;
409 TRACE("\n");
411 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
412 ret = ExtractIconA(hInstance,exefn,nIconIndex);
414 HeapFree(GetProcessHeap(),0,exefn);
415 return ret;
418 /*************************************************************************
419 * FindExecutableA [SHELL32.184]
421 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
422 LPSTR lpResult )
424 HINSTANCE retval=31; /* default - 'No association was found' */
425 char old_dir[1024];
427 TRACE("File %s, Dir %s\n",
428 (lpFile != NULL?lpFile:"-"),
429 (lpDirectory != NULL?lpDirectory:"-"));
431 lpResult[0]='\0'; /* Start off with an empty return string */
433 /* trap NULL parameters on entry */
434 if (( lpFile == NULL ) || ( lpResult == NULL ))
435 { /* FIXME - should throw a warning, perhaps! */
436 return 2; /* File not found. Close enough, I guess. */
439 if (lpDirectory)
440 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
441 SetCurrentDirectoryA( lpDirectory );
444 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
446 TRACE("returning %s\n", lpResult);
447 if (lpDirectory)
448 SetCurrentDirectoryA( old_dir );
449 return retval;
452 /*************************************************************************
453 * FindExecutableW [SHELL32.219]
455 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
456 LPWSTR lpResult)
458 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
459 return 31; /* default - 'No association was found' */
462 typedef struct
463 { LPCSTR szApp;
464 LPCSTR szOtherStuff;
465 HICON hIcon;
466 } ABOUT_INFO;
468 #define IDC_STATIC_TEXT 100
469 #define IDC_LISTBOX 99
470 #define IDC_WINE_TEXT 98
472 #define DROP_FIELD_TOP (-15)
473 #define DROP_FIELD_HEIGHT 15
475 static HICON hIconTitleFont;
477 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
478 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
479 if( hWndCtl )
480 { GetWindowRect( hWndCtl, lprect );
481 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
482 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
483 return TRUE;
485 return FALSE;
488 /*************************************************************************
489 * SHAppBarMessage [SHELL32.207]
491 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
493 int width=data->rc.right - data->rc.left;
494 int height=data->rc.bottom - data->rc.top;
495 RECT rec=data->rc;
496 switch (msg)
497 { case ABM_GETSTATE:
498 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
499 case ABM_GETTASKBARPOS:
500 GetWindowRect(data->hWnd, &rec);
501 data->rc=rec;
502 return TRUE;
503 case ABM_ACTIVATE:
504 SetActiveWindow(data->hWnd);
505 return TRUE;
506 case ABM_GETAUTOHIDEBAR:
507 data->hWnd=GetActiveWindow();
508 return TRUE;
509 case ABM_NEW:
510 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
511 width,height,SWP_SHOWWINDOW);
512 return TRUE;
513 case ABM_QUERYPOS:
514 GetWindowRect(data->hWnd, &(data->rc));
515 return TRUE;
516 case ABM_REMOVE:
517 CloseHandle(data->hWnd);
518 return TRUE;
519 case ABM_SETAUTOHIDEBAR:
520 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
521 width,height,SWP_SHOWWINDOW);
522 return TRUE;
523 case ABM_SETPOS:
524 data->uEdge=(ABE_RIGHT | ABE_LEFT);
525 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
526 width,height,SWP_SHOWWINDOW);
527 return TRUE;
528 case ABM_WINDOWPOSCHANGED:
529 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
530 width,height,SWP_SHOWWINDOW);
531 return TRUE;
533 return FALSE;
536 /*************************************************************************
537 * SHHelpShortcuts_RunDLL [SHELL32.224]
540 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
541 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
542 dwArg1, dwArg2, dwArg3, dwArg4);
544 return 0;
547 /*************************************************************************
548 * SHLoadInProc [SHELL32.225]
549 * Create an instance of specified object class from within
550 * the shell process and release it immediately
553 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
555 IUnknown * pUnk = NULL;
556 TRACE("%s\n", debugstr_guid(rclsid));
558 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
559 if(pUnk)
561 IUnknown_Release(pUnk);
562 return NOERROR;
564 return DISP_E_MEMBERNOTFOUND;
567 /*************************************************************************
568 * ShellExecuteA [SHELL32.245]
570 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
571 LPCSTR lpFile, LPCSTR lpParameters,
572 LPCSTR lpDirectory, INT iShowCmd )
573 { TRACE("\n");
574 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
575 lpDirectory, iShowCmd );
578 /*************************************************************************
579 * ShellExecuteW [SHELL32.294]
580 * from shellapi.h
581 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
582 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
584 HINSTANCE WINAPI
585 ShellExecuteW(
586 HWND hwnd,
587 LPCWSTR lpOperation,
588 LPCWSTR lpFile,
589 LPCWSTR lpParameters,
590 LPCWSTR lpDirectory,
591 INT nShowCmd) {
593 FIXME(": stub\n");
594 return 0;
597 /*************************************************************************
598 * AboutDlgProc (internal)
600 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
601 LPARAM lParam )
602 { HWND hWndCtl;
603 char Template[512], AppTitle[512];
605 TRACE("\n");
607 switch(msg)
608 { case WM_INITDIALOG:
609 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
610 if (info)
611 { const char* const *pstr = SHELL_People;
612 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
613 GetWindowTextA( hWnd, Template, sizeof(Template) );
614 sprintf( AppTitle, Template, info->szApp );
615 SetWindowTextA( hWnd, AppTitle );
616 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
617 info->szOtherStuff );
618 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
619 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
620 if (!hIconTitleFont)
622 LOGFONTA logFont;
623 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
624 hIconTitleFont = CreateFontIndirectA( &logFont );
626 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
627 while (*pstr)
628 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
629 pstr++;
631 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
634 return 1;
636 case WM_PAINT:
637 { RECT rect;
638 PAINTSTRUCT ps;
639 HDC hDC = BeginPaint( hWnd, &ps );
641 if( __get_dropline( hWnd, &rect ) ) {
642 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
643 MoveToEx( hDC, rect.left, rect.top, NULL );
644 LineTo( hDC, rect.right, rect.bottom );
646 EndPaint( hWnd, &ps );
648 break;
650 #if 0 /* FIXME: should use DoDragDrop */
651 case WM_LBTRACKPOINT:
652 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
653 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
654 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
655 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
656 if( idx != -1 )
657 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
658 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
659 char* pstr = (char*)GlobalLock16( hMemObj );
661 if( pstr )
662 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
663 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
664 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
665 UpdateWindow( hWndCtl );
666 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
667 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
669 if( hMemObj )
670 GlobalFree16( hMemObj );
674 break;
675 #endif
677 case WM_QUERYDROPOBJECT:
678 if( wParam == 0 )
679 { LPDRAGINFO16 lpDragInfo = (LPDRAGINFO16)PTR_SEG_TO_LIN((SEGPTR)lParam);
680 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
681 { RECT rect;
682 if( __get_dropline( hWnd, &rect ) )
683 { POINT pt;
684 pt.x=lpDragInfo->pt.x;
685 pt.x=lpDragInfo->pt.y;
686 rect.bottom += DROP_FIELD_HEIGHT;
687 if( PtInRect( &rect, pt ) )
688 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
689 return TRUE;
694 break;
696 case WM_DROPOBJECT:
697 if( wParam == hWnd )
698 { LPDRAGINFO16 lpDragInfo = (LPDRAGINFO16)PTR_SEG_TO_LIN((SEGPTR)lParam);
699 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
700 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
701 if( pstr )
702 { static char __appendix_str[] = " with";
704 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
705 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
706 if( !strncmp( Template, "WINE", 4 ) )
707 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
708 else
709 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
710 *pch = '\0';
711 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
712 (WPARAM)-1, (LPARAM)Template );
715 strcpy( Template, pstr );
716 strcat( Template, __appendix_str );
717 SetWindowTextA( hWndCtl, Template );
718 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
719 return TRUE;
723 break;
725 case WM_COMMAND:
726 if (wParam == IDOK)
727 { EndDialog(hWnd, TRUE);
728 return TRUE;
730 break;
731 case WM_CLOSE:
732 EndDialog(hWnd, TRUE);
733 break;
736 return 0;
740 /*************************************************************************
741 * ShellAboutA [SHELL32.243]
743 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
744 HICON hIcon )
745 { ABOUT_INFO info;
746 HRSRC hRes;
747 LPVOID template;
748 TRACE("\n");
750 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
751 return FALSE;
752 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
753 return FALSE;
755 info.szApp = szApp;
756 info.szOtherStuff = szOtherStuff;
757 info.hIcon = hIcon;
758 if (!hIcon) info.hIcon = LoadIconA( 0, MAKEINTRESOURCEA(OIC_WINEICON) );
759 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
760 template, hWnd, AboutDlgProc, (LPARAM)&info );
764 /*************************************************************************
765 * ShellAboutW [SHELL32.244]
767 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
768 HICON hIcon )
769 { BOOL ret;
770 ABOUT_INFO info;
771 HRSRC hRes;
772 LPVOID template;
774 TRACE("\n");
776 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
777 return FALSE;
778 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
779 return FALSE;
781 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
782 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
783 info.hIcon = hIcon;
784 if (!hIcon) info.hIcon = LoadIconA( 0, MAKEINTRESOURCEA(OIC_WINEICON) );
785 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
786 template, hWnd, AboutDlgProc, (LPARAM)&info );
787 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
788 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
789 return ret;
792 /*************************************************************************
793 * FreeIconList
795 void WINAPI FreeIconList( DWORD dw )
796 { FIXME("(%lx): stub\n",dw);
799 /***********************************************************************
800 * DllGetVersion [SHELL32]
802 * Retrieves version information of the 'SHELL32.DLL'
804 * PARAMS
805 * pdvi [O] pointer to version information structure.
807 * RETURNS
808 * Success: S_OK
809 * Failure: E_INVALIDARG
811 * NOTES
812 * Returns version of a shell32.dll from IE4.01 SP1.
815 HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
817 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
819 WARN("wrong DLLVERSIONINFO size from app");
820 return E_INVALIDARG;
823 pdvi->dwMajorVersion = 4;
824 pdvi->dwMinorVersion = 72;
825 pdvi->dwBuildNumber = 3110;
826 pdvi->dwPlatformID = 1;
828 TRACE("%lu.%lu.%lu.%lu\n",
829 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
830 pdvi->dwBuildNumber, pdvi->dwPlatformID);
832 return S_OK;
834 /*************************************************************************
835 * global variables of the shell32.dll
836 * all are once per process
839 void (WINAPI* pDLLInitComctl)(LPVOID);
840 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
841 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
842 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
843 BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
844 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
845 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
846 COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
848 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
849 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
851 HDPA (WINAPI* pDPA_Create) (INT);
852 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
853 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
854 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
855 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
856 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
857 LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
859 /* user32 */
860 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
861 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
863 static HINSTANCE hComctl32;
864 static INT shell32_RefCount = 0;
866 LONG shell32_ObjCount = 0;
867 HINSTANCE shell32_hInstance = 0;
868 HMODULE huser32 = 0;
869 HIMAGELIST ShellSmallIconList = 0;
870 HIMAGELIST ShellBigIconList = 0;
873 /*************************************************************************
874 * SHELL32 LibMain
876 * NOTES
877 * calling oleinitialize here breaks sone apps.
880 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
882 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
884 switch (fdwReason)
886 case DLL_PROCESS_ATTACH:
887 shell32_RefCount++;
888 if (shell32_hInstance) return TRUE;
890 shell32_hInstance = hinstDLL;
891 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
892 if(!huser32) huser32 = GetModuleHandleA("USER32.DLL");
893 DisableThreadLibraryCalls(shell32_hInstance);
895 if (!hComctl32 || !huser32)
897 ERR("P A N I C SHELL32 loading failed\n");
898 return FALSE;
901 /* comctl32 */
902 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
903 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
904 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
905 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
906 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
907 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
908 pImageList_Draw=(void*)GetProcAddress(hComctl32,"ImageList_Draw");
909 pImageList_SetBkColor=(void*)GetProcAddress(hComctl32,"ImageList_SetBkColor");
910 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
911 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
912 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
913 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
914 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
915 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
916 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
917 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
918 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
919 /* user32 */
920 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(huser32,"LookupIconIdFromDirectoryEx");
921 pCreateIconFromResourceEx=(void*)GetProcAddress(huser32,"CreateIconFromResourceEx");
923 /* initialize the common controls */
924 if (pDLLInitComctl)
926 pDLLInitComctl(NULL);
929 SIC_Initialize();
930 SYSTRAY_Init();
931 InitChangeNotifications();
932 SHInitRestricted(NULL, NULL);
933 break;
935 case DLL_THREAD_ATTACH:
936 shell32_RefCount++;
937 break;
939 case DLL_THREAD_DETACH:
940 shell32_RefCount--;
941 break;
943 case DLL_PROCESS_DETACH:
944 shell32_RefCount--;
946 if ( !shell32_RefCount )
948 shell32_hInstance = 0;
950 if (pdesktopfolder)
952 IShellFolder_Release(pdesktopfolder);
953 pdesktopfolder = NULL;
956 SIC_Destroy();
957 FreeChangeNotifications();
959 /* this one is here to check if AddRef/Release is balanced */
960 if (shell32_ObjCount)
962 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
966 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
967 break;
969 return TRUE;
972 /*************************************************************************
973 * DllInstall [SHELL32.202]
975 * PARAMETERS
977 * BOOL bInstall - TRUE for install, FALSE for uninstall
978 * LPCWSTR pszCmdLine - command line (unused by shell32?)
981 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
983 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
985 return S_OK; /* indicate success */
988 /***********************************************************************
989 * DllCanUnloadNow (SHELL32.@)
991 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
993 FIXME("(void): stub\n");
995 return S_FALSE;