Get more entry points from Comctl32 and save the addresses.
[wine/testsucceed.git] / dlls / shell32 / shell32_main.c
blob0fdfb491563b5a369ab121dcba09b3d7c2972177
1 /*
2 * Shell basics
4 * 1998 Marcus Meissner
5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
6 */
8 #include "config.h"
10 #include <stdlib.h>
11 #include <string.h>
12 #include <stdio.h>
14 #include "dlgs.h"
15 #include "shellapi.h"
16 #include "shlobj.h"
17 #include "shlguid.h"
18 #include "shlwapi.h"
19 #include "windef.h"
20 #include "winerror.h"
21 #include "winreg.h"
23 #include "undocshell.h"
24 #include "wine/winuser16.h"
25 #include "authors.h"
26 #include "heap.h"
27 #include "pidl.h"
28 #include "shell32_main.h"
30 #include "debugtools.h"
32 DEFAULT_DEBUG_CHANNEL(shell);
34 #define MORE_DEBUG 1
35 /*************************************************************************
36 * CommandLineToArgvW [SHELL32.@]
38 * We must interpret the quotes in the command line to rebuild the argv
39 * array correctly:
40 * - arguments are separated by spaces or tabs
41 * - quotes serve as optional argument delimiters
42 * '"a b"' -> 'a b'
43 * - escaped quotes must be converted back to '"'
44 * '\"' -> '"'
45 * - an odd number of '\'s followed by '"' correspond to half that number
46 * of '\' followed by a '"' (extension of the above)
47 * '\\\"' -> '\"'
48 * '\\\\\"' -> '\\"'
49 * - an even number of '\'s followed by a '"' correspond to half that number
50 * of '\', plus a regular quote serving as an argument delimiter (which
51 * means it does not appear in the result)
52 * 'a\\"b c"' -> 'a\b c'
53 * 'a\\\\"b c"' -> 'a\\b c'
54 * - '\' that are not followed by a '"' are copied literally
55 * 'a\b' -> 'a\b'
56 * 'a\\b' -> 'a\\b'
58 * Note:
59 * '\t' == 0x0009
60 * ' ' == 0x0020
61 * '"' == 0x0022
62 * '\\' == 0x005c
64 LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
66 DWORD argc;
67 LPWSTR *argv;
68 LPWSTR arg,s,d;
69 LPWSTR cmdline;
70 int in_quotes,bcount;
72 /* FIXME: same thing if we only have spaces */
73 if (*lpCmdline==0) {
74 /* Return the path to the executable */
75 DWORD size;
77 argv=HeapAlloc(GetProcessHeap(), 0, 2*sizeof(LPWSTR));
78 argv[0]=NULL;
79 size=16;
80 do {
81 size*=2;
82 argv[0]=HeapReAlloc(GetProcessHeap(), 0, argv[0], size);
83 } while (GetModuleFileNameW((HMODULE)0, argv[0], size) == 0);
84 argv[1]=NULL;
85 if (numargs)
86 *numargs=2;
88 return argv;
91 /* to get a writeable copy */
92 cmdline = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpCmdline)+1) * sizeof(WCHAR));
93 if (!cmdline)
94 return NULL;
95 strcpyW(cmdline, lpCmdline);
96 argc=0;
97 bcount=0;
98 in_quotes=0;
99 s=cmdline;
100 while (1) {
101 if (*s==0 || ((*s==0x0009 || *s==0x0020) && !in_quotes)) {
102 /* space */
103 argc++;
104 /* skip the remaining spaces */
105 while (*s==0x0009 || *s==0x0020) {
106 s++;
108 if (*s==0)
109 break;
110 bcount=0;
111 continue;
112 } else if (*s==0x005c) {
113 /* '\', count them */
114 bcount++;
115 } else if ((*s==0x0022) && ((bcount & 1)==0)) {
116 /* unescaped '"' */
117 in_quotes=!in_quotes;
118 bcount=0;
119 } else {
120 /* a regular character */
121 bcount=0;
123 s++;
125 argv=HeapAlloc(GetProcessHeap(), 0, (argc+1)*sizeof(LPWSTR));
127 argc=0;
128 bcount=0;
129 in_quotes=0;
130 arg=d=s=cmdline;
131 while (*s) {
132 if ((*s==0x0009 || *s==0x0020) && !in_quotes) {
133 /* Close the argument and copy it */
134 *d=0;
135 argv[argc++]=arg;
137 /* skip the remaining spaces */
138 do {
139 s++;
140 } while (*s==0x0009 || *s==0x0020);
142 /* Start with a new argument */
143 arg=d=s;
144 bcount=0;
145 } else if (*s==0x005c) {
146 /* '\\' */
147 *d++=*s++;
148 bcount++;
149 } else if (*s==0x0022) {
150 /* '"' */
151 if ((bcount & 1)==0) {
152 /* Preceeded by an even number of '\', this is half that
153 * number of '\', plus a quote which we erase.
155 d-=bcount/2;
156 in_quotes=!in_quotes;
157 s++;
158 } else {
159 /* Preceeded by an odd number of '\', this is half that
160 * number of '\' followed by a '"'
162 d=d-bcount/2-1;
163 *d++='"';
164 s++;
166 bcount=0;
167 } else {
168 /* a regular character */
169 *d++=*s++;
170 bcount=0;
173 if (*arg) {
174 *d='\0';
175 argv[argc++]=arg;
177 argv[argc]=NULL;
178 if (numargs)
179 *numargs=argc;
181 HeapFree(GetProcessHeap(), 0, cmdline);
182 return argv;
185 /*************************************************************************
186 * SHGetFileInfoA [SHELL32.@]
190 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
191 SHFILEINFOA *psfi, UINT sizeofpsfi,
192 UINT flags )
194 char szLoaction[MAX_PATH];
195 int iIndex;
196 DWORD ret = TRUE, dwAttributes = 0;
197 IShellFolder * psfParent = NULL;
198 IExtractIconA * pei = NULL;
199 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
200 HRESULT hr = S_OK;
202 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
203 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
205 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
206 return FALSE;
208 /* windows initializes this values regardless of the flags */
209 psfi->szDisplayName[0] = '\0';
210 psfi->szTypeName[0] = '\0';
211 psfi->iIcon = 0;
213 if (flags & SHGFI_EXETYPE) {
214 BOOL status = FALSE;
215 HANDLE hfile;
216 DWORD BinaryType;
217 IMAGE_DOS_HEADER mz_header;
218 IMAGE_NT_HEADERS nt;
219 DWORD len;
220 char magic[4];
222 if (flags != SHGFI_EXETYPE) return 0;
224 status = GetBinaryTypeA (path, &BinaryType);
225 if (!status) return 0;
226 if ((BinaryType == SCS_DOS_BINARY)
227 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
229 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
230 NULL, OPEN_EXISTING, 0, 0 );
231 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
233 /* The next section is adapted from MODULE_GetBinaryType, as we need
234 * to examine the image header to get OS and version information. We
235 * know from calling GetBinaryTypeA that the image is valid and either
236 * an NE or PE, so much error handling can be omitted.
237 * Seek to the start of the file and read the header information.
240 SetFilePointer( hfile, 0, NULL, SEEK_SET );
241 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
243 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
244 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
245 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
247 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
248 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
249 CloseHandle( hfile );
250 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
251 return IMAGE_NT_SIGNATURE
252 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
253 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
255 return IMAGE_NT_SIGNATURE;
257 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
259 IMAGE_OS2_HEADER ne;
260 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
261 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
262 CloseHandle( hfile );
263 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
264 | (ne.ne_expver << 16);
265 return 0;
267 CloseHandle( hfile );
268 return 0;
272 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
273 the pidl functions fail on not existing file names */
274 if (flags & SHGFI_PIDL)
276 pidl = (LPCITEMIDLIST) path;
277 if (!pidl )
279 ERR("pidl is null!\n");
280 return FALSE;
283 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
285 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
286 /* note: the attributes in ISF::ParseDisplayName are not implemented */
289 /* get the parent shellfolder */
290 if (pidl)
292 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
295 /* get the attributes of the child */
296 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
298 if (!(flags & SHGFI_ATTR_SPECIFIED))
300 psfi->dwAttributes = 0xffffffff;
302 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
305 /* get the displayname */
306 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
308 if (flags & SHGFI_USEFILEATTRIBUTES)
310 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
312 else
314 STRRET str;
315 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
316 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
320 /* get the type name */
321 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
323 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
326 /* ### icons ###*/
327 if (flags & SHGFI_LINKOVERLAY)
328 FIXME("set icon to link, stub\n");
330 if (flags & SHGFI_SELECTED)
331 FIXME("set icon to selected, stub\n");
333 if (flags & SHGFI_SHELLICONSIZE)
334 FIXME("set icon to shell size, stub\n");
336 /* get the iconlocation */
337 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
339 UINT uDummy,uFlags;
340 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
342 if (SUCCEEDED(hr))
344 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
345 /* fixme what to do with the index? */
347 if(uFlags != GIL_NOTFILENAME)
348 strcpy (psfi->szDisplayName, szLoaction);
349 else
350 ret = FALSE;
352 IExtractIconA_Release(pei);
356 /* get icon index (or load icon)*/
357 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
359 if (flags & SHGFI_USEFILEATTRIBUTES)
361 char sTemp [MAX_PATH];
362 char * szExt;
363 DWORD dwNr=0;
365 lstrcpynA(sTemp, path, MAX_PATH);
366 szExt = (LPSTR) PathFindExtensionA(sTemp);
367 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
368 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
370 if (!strcmp("%1",sTemp)) /* icon is in the file */
372 strcpy(sTemp, path);
374 /* FIXME: if sTemp contains a valid filename, get the icon
375 from there, index is in dwNr
377 psfi->iIcon = 2;
379 else /* default icon */
381 psfi->iIcon = 0;
384 else
386 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
387 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
389 ret = FALSE;
392 if (ret)
394 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
398 /* icon handle */
399 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
400 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
402 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
403 FIXME("unknown attribute!\n");
405 if (psfParent)
406 IShellFolder_Release(psfParent);
408 if (hr != S_OK)
409 ret = FALSE;
411 if(pidlLast) SHFree(pidlLast);
412 #ifdef MORE_DEBUG
413 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
414 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
415 #endif
416 return ret;
419 /*************************************************************************
420 * SHGetFileInfoW [SHELL32.@]
423 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
424 SHFILEINFOW *psfi, UINT sizeofpsfi,
425 UINT flags )
427 INT len;
428 LPSTR temppath;
429 DWORD ret;
430 SHFILEINFOA temppsfi;
432 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
433 temppath = HeapAlloc(GetProcessHeap(), 0, len);
434 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
436 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
437 sizeof(temppsfi.szDisplayName), NULL, NULL);
438 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
439 sizeof(temppsfi.szTypeName), NULL, NULL);
441 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
443 HeapFree(GetProcessHeap(), 0, temppath);
445 return ret;
448 /*************************************************************************
449 * SHGetFileInfo [SHELL32.@]
451 DWORD WINAPI SHGetFileInfoAW(
452 LPCVOID path,
453 DWORD dwFileAttributes,
454 LPVOID psfi,
455 UINT sizeofpsfi,
456 UINT flags)
458 if(SHELL_OsIsUnicode())
459 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
460 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
463 /*************************************************************************
464 * DuplicateIcon [SHELL32.@]
466 HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
468 ICONINFO IconInfo;
469 HICON hDupIcon = 0;
471 TRACE("(%04x, %04x)\n", hInstance, hIcon);
473 if(GetIconInfo(hIcon, &IconInfo))
475 hDupIcon = CreateIconIndirect(&IconInfo);
477 /* clean up hbmMask and hbmColor */
478 DeleteObject(IconInfo.hbmMask);
479 DeleteObject(IconInfo.hbmColor);
482 return hDupIcon;
486 /*************************************************************************
487 * ExtractIconA [SHELL32.@]
489 * FIXME
490 * if the filename is not a file return 1
492 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
493 UINT nIconIndex )
494 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
495 TRACE("\n");
496 if( handle )
498 HICON16* ptr = (HICON16*)GlobalLock16(handle);
499 HICON16 hIcon = *ptr;
501 GlobalFree16(handle);
502 return hIcon;
504 return 0;
507 /*************************************************************************
508 * ExtractIconW [SHELL32.@]
510 * fixme
511 * is the filename is not a file return 1
513 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
514 UINT nIconIndex )
515 { LPSTR exefn;
516 HICON ret;
517 TRACE("\n");
519 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
520 ret = ExtractIconA(hInstance,exefn,nIconIndex);
522 HeapFree(GetProcessHeap(),0,exefn);
523 return ret;
526 /*************************************************************************
527 * FindExecutableA [SHELL32.@]
529 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
530 LPSTR lpResult )
532 HINSTANCE retval=31; /* default - 'No association was found' */
533 char old_dir[1024];
535 TRACE("File %s, Dir %s\n",
536 (lpFile != NULL?lpFile:"-"),
537 (lpDirectory != NULL?lpDirectory:"-"));
539 lpResult[0]='\0'; /* Start off with an empty return string */
541 /* trap NULL parameters on entry */
542 if (( lpFile == NULL ) || ( lpResult == NULL ))
543 { /* FIXME - should throw a warning, perhaps! */
544 return 2; /* File not found. Close enough, I guess. */
547 if (lpDirectory)
548 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
549 SetCurrentDirectoryA( lpDirectory );
552 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
554 TRACE("returning %s\n", lpResult);
555 if (lpDirectory)
556 SetCurrentDirectoryA( old_dir );
557 return retval;
560 /*************************************************************************
561 * FindExecutableW [SHELL32.@]
563 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
564 LPWSTR lpResult)
566 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
567 return 31; /* default - 'No association was found' */
570 typedef struct
571 { LPCSTR szApp;
572 LPCSTR szOtherStuff;
573 HICON hIcon;
574 } ABOUT_INFO;
576 #define IDC_STATIC_TEXT 100
577 #define IDC_LISTBOX 99
578 #define IDC_WINE_TEXT 98
580 #define DROP_FIELD_TOP (-15)
581 #define DROP_FIELD_HEIGHT 15
583 static HICON hIconTitleFont;
585 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
586 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
587 if( hWndCtl )
588 { GetWindowRect( hWndCtl, lprect );
589 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
590 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
591 return TRUE;
593 return FALSE;
596 /*************************************************************************
597 * SHAppBarMessage [SHELL32.@]
599 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
601 int width=data->rc.right - data->rc.left;
602 int height=data->rc.bottom - data->rc.top;
603 RECT rec=data->rc;
604 switch (msg)
605 { case ABM_GETSTATE:
606 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
607 case ABM_GETTASKBARPOS:
608 GetWindowRect(data->hWnd, &rec);
609 data->rc=rec;
610 return TRUE;
611 case ABM_ACTIVATE:
612 SetActiveWindow(data->hWnd);
613 return TRUE;
614 case ABM_GETAUTOHIDEBAR:
615 data->hWnd=GetActiveWindow();
616 return TRUE;
617 case ABM_NEW:
618 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
619 width,height,SWP_SHOWWINDOW);
620 return TRUE;
621 case ABM_QUERYPOS:
622 GetWindowRect(data->hWnd, &(data->rc));
623 return TRUE;
624 case ABM_REMOVE:
625 FIXME("ABM_REMOVE broken\n");
626 /* FIXME: this is wrong; should it be DestroyWindow instead? */
627 /*CloseHandle(data->hWnd);*/
628 return TRUE;
629 case ABM_SETAUTOHIDEBAR:
630 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
631 width,height,SWP_SHOWWINDOW);
632 return TRUE;
633 case ABM_SETPOS:
634 data->uEdge=(ABE_RIGHT | ABE_LEFT);
635 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
636 width,height,SWP_SHOWWINDOW);
637 return TRUE;
638 case ABM_WINDOWPOSCHANGED:
639 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
640 width,height,SWP_SHOWWINDOW);
641 return TRUE;
643 return FALSE;
646 /*************************************************************************
647 * SHHelpShortcuts_RunDLL [SHELL32.@]
650 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
651 { FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
652 dwArg1, dwArg2, dwArg3, dwArg4);
654 return 0;
657 /*************************************************************************
658 * SHLoadInProc [SHELL32.@]
659 * Create an instance of specified object class from within
660 * the shell process and release it immediately
663 DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
665 IUnknown * pUnk = NULL;
666 TRACE("%s\n", debugstr_guid(rclsid));
668 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
669 if(pUnk)
671 IUnknown_Release(pUnk);
672 return NOERROR;
674 return DISP_E_MEMBERNOTFOUND;
677 /*************************************************************************
678 * ShellExecuteA [SHELL32.290]
680 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
681 LPCSTR lpFile, LPCSTR lpParameters,
682 LPCSTR lpDirectory, INT iShowCmd )
683 { TRACE("\n");
684 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
685 lpDirectory, iShowCmd );
688 /*************************************************************************
689 * ShellExecuteW [SHELL32.294]
690 * from shellapi.h
691 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
692 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
694 HINSTANCE WINAPI
695 ShellExecuteW(
696 HWND hwnd,
697 LPCWSTR lpOperation,
698 LPCWSTR lpFile,
699 LPCWSTR lpParameters,
700 LPCWSTR lpDirectory,
701 INT nShowCmd) {
703 FIXME(": stub\n");
704 return 0;
707 /*************************************************************************
708 * AboutDlgProc (internal)
710 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
711 LPARAM lParam )
712 { HWND hWndCtl;
713 char Template[512], AppTitle[512];
715 TRACE("\n");
717 switch(msg)
718 { case WM_INITDIALOG:
719 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
720 if (info)
721 { const char* const *pstr = SHELL_People;
722 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,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 );
730 if (!hIconTitleFont)
732 LOGFONTA logFont;
733 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
734 hIconTitleFont = CreateFontIndirectA( &logFont );
736 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
737 while (*pstr)
738 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
739 pstr++;
741 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
744 return 1;
746 case WM_PAINT:
747 { RECT rect;
748 PAINTSTRUCT ps;
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 );
758 break;
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 );
766 if( idx != -1 )
767 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
768 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
769 char* pstr = (char*)GlobalLock16( hMemObj );
771 if( pstr )
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 );
779 if( hMemObj )
780 GlobalFree16( hMemObj );
784 break;
785 #endif
787 case WM_QUERYDROPOBJECT:
788 if( wParam == 0 )
789 { LPDRAGINFO16 lpDragInfo = MapSL((SEGPTR)lParam);
790 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
791 { RECT rect;
792 if( __get_dropline( hWnd, &rect ) )
793 { POINT pt;
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 );
799 return TRUE;
804 break;
806 case WM_DROPOBJECT:
807 if( 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) );
811 if( pstr )
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 );
818 else
819 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
820 *pch = '\0';
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 );
829 return TRUE;
833 break;
835 case WM_COMMAND:
836 if (wParam == IDOK)
837 { EndDialog(hWnd, TRUE);
838 return TRUE;
840 break;
841 case WM_CLOSE:
842 EndDialog(hWnd, TRUE);
843 break;
846 return 0;
850 /*************************************************************************
851 * ShellAboutA [SHELL32.288]
853 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
854 HICON hIcon )
855 { ABOUT_INFO info;
856 HRSRC hRes;
857 LPVOID template;
858 TRACE("\n");
860 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
861 return FALSE;
862 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
863 return FALSE;
865 info.szApp = szApp;
866 info.szOtherStuff = szOtherStuff;
867 info.hIcon = hIcon;
868 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
869 return DialogBoxIndirectParamA( 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,
878 HICON hIcon )
879 { BOOL ret;
880 ABOUT_INFO info;
881 HRSRC hRes;
882 LPVOID template;
884 TRACE("\n");
886 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
887 return FALSE;
888 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
889 return FALSE;
891 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
892 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
893 info.hIcon = hIcon;
894 if (!hIcon) info.hIcon = LoadIconA( 0, IDI_WINLOGOA );
895 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
896 template, hWnd, AboutDlgProc, (LPARAM)&info );
897 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
898 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
899 return ret;
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'
914 * PARAMS
915 * pdvi [O] pointer to version information structure.
917 * RETURNS
918 * Success: S_OK
919 * Failure: E_INVALIDARG
921 * NOTES
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");
930 return E_INVALIDARG;
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);
942 return S_OK;
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 HDPA WINAPI (*pDPA_Create) (INT);
955 INT WINAPI (*pDPA_InsertPtr) (const HDPA, INT, LPVOID);
956 BOOL WINAPI (*pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
957 LPVOID WINAPI (*pDPA_GetPtr) (const HDPA, INT);
958 BOOL WINAPI (*pDPA_Destroy) (const HDPA);
959 INT WINAPI (*pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
960 LPVOID WINAPI (*pDPA_DeletePtr) (const HDPA hdpa, INT i);
961 HANDLE WINAPI (*pCreateMRUListA) (LPVOID lpcml);
962 DWORD WINAPI (*pFreeMRUListA) (HANDLE hMRUList);
963 INT WINAPI (*pAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
964 INT WINAPI (*pFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
965 INT WINAPI (*pEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
967 static HINSTANCE hComctl32;
969 LONG shell32_ObjCount = 0;
970 HINSTANCE shell32_hInstance = 0;
971 HIMAGELIST ShellSmallIconList = 0;
972 HIMAGELIST ShellBigIconList = 0;
975 /*************************************************************************
976 * SHELL32 LibMain
978 * NOTES
979 * calling oleinitialize here breaks sone apps.
982 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
984 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
986 switch (fdwReason)
988 case DLL_PROCESS_ATTACH:
989 shell32_hInstance = hinstDLL;
990 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
991 DisableThreadLibraryCalls(shell32_hInstance);
993 if (!hComctl32)
995 ERR("P A N I C SHELL32 loading failed\n");
996 return FALSE;
999 /* comctl32 */
1000 pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
1001 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
1002 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
1003 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
1004 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
1005 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
1006 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
1007 pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
1008 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
1009 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
1010 pCreateMRUListA=(void*)GetProcAddress(hComctl32, "CreateMRUListA");
1011 pFreeMRUListA=(void*)GetProcAddress(hComctl32, "FreeMRUList");
1012 pAddMRUData=(void*)GetProcAddress(hComctl32, "AddMRUData");
1013 pFindMRUData=(void*)GetProcAddress(hComctl32, "FindMRUData");
1014 pEnumMRUListA=(void*)GetProcAddress(hComctl32, "EnumMRUListA");
1016 /* initialize the common controls */
1017 if (pDLLInitComctl)
1019 pDLLInitComctl(NULL);
1022 SIC_Initialize();
1023 SYSTRAY_Init();
1024 InitChangeNotifications();
1025 SHInitRestricted(NULL, NULL);
1026 break;
1028 case DLL_THREAD_ATTACH:
1029 break;
1031 case DLL_THREAD_DETACH:
1032 break;
1034 case DLL_PROCESS_DETACH:
1035 shell32_hInstance = 0;
1037 if (pdesktopfolder)
1039 IShellFolder_Release(pdesktopfolder);
1040 pdesktopfolder = NULL;
1043 SIC_Destroy();
1044 FreeChangeNotifications();
1046 /* this one is here to check if AddRef/Release is balanced */
1047 if (shell32_ObjCount)
1049 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
1051 break;
1053 return TRUE;
1056 /*************************************************************************
1057 * DllInstall [SHELL32.@]
1059 * PARAMETERS
1061 * BOOL bInstall - TRUE for install, FALSE for uninstall
1062 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1065 HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
1067 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1069 return S_OK; /* indicate success */
1072 /***********************************************************************
1073 * DllCanUnloadNow (SHELL32.@)
1075 HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
1077 FIXME("(void): stub\n");
1079 return S_FALSE;