source: trunk/src/shell32/shell32_main.c@ 21637

Last change on this file since 21637 was 21637, checked in by dmik, 14 years ago

shell32: Fixed SHGetFileInfoW(): PIDL input argument was misinterpreted as a string and the display name and type name fields SHFILEINFOW were not properly set on output resulting in garbage on the caller's side.

File size: 30.6 KB
Line 
1/* $Id: shell32_main.c,v 1.9 2003-10-16 10:30:54 sandervl Exp $ */
2/*
3 * Shell basics
4 *
5 * 1998 Marcus Meissner
6 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
7 */
8#ifdef __WIN32OS2__
9#define CINTERFACE
10#include <odin.h>
11#endif
12
13#include <stdlib.h>
14#include <string.h>
15#include <stdio.h>
16
17#include "windef.h"
18#include "wingdi.h"
19#include "wine/winuser16.h"
20#include "winerror.h"
21#include "heap.h"
22#include "dlgs.h"
23#include "ldt.h"
24#include "debugtools.h"
25#include "winreg.h"
26#include "authors.h"
27
28#include "shellapi.h"
29#include "pidl.h"
30
31#include "shell32_main.h"
32#include "undocshell.h"
33#include "shlobj.h"
34#include "shlguid.h"
35#include "shlwapi.h"
36
37#ifdef __WIN32OS2__
38#include <heapstring.h>
39#include <misc.h>
40#endif
41
42DEFAULT_DEBUG_CHANNEL(shell);
43
44#define MORE_DEBUG 1
45/*************************************************************************
46 * CommandLineToArgvW [SHELL32.7]
47 */
48/*************************************************************************
49 * CommandLineToArgvW[SHELL32.@]
50 *
51 * NOTE: The procedure is moved to KERNEL32.DLL (wprocess.cpp) and is now simply
52 * re-exported from SHELL32.DLL by importing it from there.
53 */
54
55/*************************************************************************
56 * SHGetFileInfoA [SHELL32.@]
57 *
58 */
59
60DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
61 SHFILEINFOA *psfi, UINT sizeofpsfi,
62 UINT flags )
63{
64 char szLoaction[MAX_PATH];
65 int iIndex;
66 DWORD ret = TRUE, dwAttributes = 0;
67 IShellFolder * psfParent = NULL;
68 IExtractIconA * pei = NULL;
69 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
70 HRESULT hr = S_OK;
71 BOOL IconNotYetLoaded=TRUE;
72
73 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
74 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
75
76 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
77 return FALSE;
78
79 /* windows initializes this values regardless of the flags */
80 psfi->szDisplayName[0] = '\0';
81 psfi->szTypeName[0] = '\0';
82 psfi->iIcon = 0;
83
84 if (flags & SHGFI_EXETYPE) {
85 BOOL status = FALSE;
86 HANDLE hfile;
87 DWORD BinaryType;
88 IMAGE_DOS_HEADER mz_header;
89 IMAGE_NT_HEADERS nt;
90 DWORD len;
91 char magic[4];
92
93 if (flags != SHGFI_EXETYPE) return 0;
94
95 status = GetBinaryTypeA (path, &BinaryType);
96 if (!status) return 0;
97 if ((BinaryType == SCS_DOS_BINARY)
98 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
99
100 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
101 NULL, OPEN_EXISTING, 0, 0 );
102 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
103
104 /* The next section is adapted from MODULE_GetBinaryType, as we need
105 * to examine the image header to get OS and version information. We
106 * know from calling GetBinaryTypeA that the image is valid and either
107 * an NE or PE, so much error handling can be omitted.
108 * Seek to the start of the file and read the header information.
109 */
110
111 SetFilePointer( hfile, 0, NULL, SEEK_SET );
112 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
113
114 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
115 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
116 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
117 {
118 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
119 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
120 CloseHandle( hfile );
121 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
122 return IMAGE_NT_SIGNATURE
123 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
124 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
125 }
126 return IMAGE_NT_SIGNATURE;
127 }
128 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
129 {
130 IMAGE_OS2_HEADER ne;
131 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
132 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
133 CloseHandle( hfile );
134 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
135 | (ne.ne_expver << 16);
136 return 0;
137 }
138 CloseHandle( hfile );
139 return 0;
140 }
141
142
143 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
144 the pidl functions fail on not existing file names */
145 if (flags & SHGFI_PIDL)
146 {
147 pidl = (LPCITEMIDLIST) path;
148 if (!pidl )
149 {
150 ERR("pidl is null!\n");
151 return FALSE;
152 }
153 }
154 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
155 {
156 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
157 /* note: the attributes in ISF::ParseDisplayName are not implemented */
158 }
159
160 /* get the parent shellfolder */
161 if (pidl)
162 {
163 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
164 }
165
166 /* get the attributes of the child */
167 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
168 {
169 if (!(flags & SHGFI_ATTR_SPECIFIED))
170 {
171 psfi->dwAttributes = 0xffffffff;
172 }
173 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
174 }
175
176 /* get the displayname */
177 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
178 {
179 if (flags & SHGFI_USEFILEATTRIBUTES)
180 {
181 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
182 }
183 else
184 {
185 STRRET str;
186 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
187 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
188 }
189 }
190
191 /* get the type name */
192 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
193 {
194 if (!(flags & SHGFI_USEFILEATTRIBUTES))
195 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
196 else
197 {
198 char sTemp[64];
199 strcpy(sTemp,PathFindExtensionA(path));
200 if (!( HCR_MapTypeToValue(sTemp, sTemp, 64, TRUE)
201 && HCR_MapTypeToValue(sTemp, psfi->szTypeName, 80, FALSE )))
202 {
203 lstrcpynA (psfi->szTypeName, sTemp, 80 - 6);
204 strcat (psfi->szTypeName, "-file");
205 }
206 }
207 }
208
209 /* ### icons ###*/
210 if (flags & SHGFI_LINKOVERLAY)
211 FIXME("set icon to link, stub\n");
212
213 if (flags & SHGFI_SELECTED)
214 FIXME("set icon to selected, stub\n");
215
216 if (flags & SHGFI_SHELLICONSIZE)
217 FIXME("set icon to shell size, stub\n");
218
219 /* get the iconlocation */
220 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
221 {
222 UINT uDummy,uFlags;
223 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
224
225 if (SUCCEEDED(hr))
226 {
227 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
228 /* FIXME what to do with the index? */
229
230 if(uFlags != GIL_NOTFILENAME)
231 strcpy (psfi->szDisplayName, szLoaction);
232 else
233 ret = FALSE;
234
235 IExtractIconA_Release(pei);
236 }
237 }
238
239 /* get icon index (or load icon)*/
240 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
241 {
242
243 if (flags & SHGFI_USEFILEATTRIBUTES)
244 {
245 char sTemp [MAX_PATH];
246 char * szExt;
247 DWORD dwNr=0;
248
249 lstrcpynA(sTemp, path, MAX_PATH);
250 szExt = (LPSTR) PathFindExtensionA(sTemp);
251 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
252 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
253 {
254 if (!strcmp("%1",sTemp)) /* icon is in the file */
255 {
256 strcpy(sTemp, path);
257 }
258 IconNotYetLoaded=FALSE;
259 psfi->iIcon = 0;
260 if (SHGFI_LARGEICON)
261 PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXICON),
262 GetSystemMetrics(SM_CYICON),
263 &psfi->hIcon,0,1,0);
264 else
265 PrivateExtractIconsA(sTemp,dwNr,GetSystemMetrics(SM_CXSMICON),
266 GetSystemMetrics(SM_CYSMICON),
267 &psfi->hIcon,0,1,0);
268 }
269 else /* default icon */
270 {
271 psfi->iIcon = 0;
272 }
273 }
274 else
275 {
276 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
277 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
278 {
279 ret = FALSE;
280 }
281 }
282 if (ret)
283 {
284 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
285 }
286 }
287
288 /* icon handle */
289 if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded)
290 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
291
292 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
293 FIXME("unknown attribute!\n");
294
295 if (psfParent)
296 IShellFolder_Release(psfParent);
297
298 if (hr != S_OK)
299 ret = FALSE;
300
301 if(pidlLast) SHFree(pidlLast);
302#ifdef MORE_DEBUG
303 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
304 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
305#endif
306 return ret;
307}
308
309/*************************************************************************
310 * SHGetFileInfoW [SHELL32.@]
311 */
312
313DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
314 SHFILEINFOW *psfi, UINT sizeofpsfi,
315 UINT flags )
316{
317 INT len;
318 LPSTR temppath;
319 DWORD ret;
320 SHFILEINFOA temppsfi;
321
322 memset(&temppsfi, 0, sizeof(temppsfi));
323
324 if (flags & SHGFI_PIDL)
325 {
326 temppath = (LPSTR)path;
327 }
328 else
329 {
330 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
331 temppath = HeapAlloc(GetProcessHeap(), 0, len);
332 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
333 }
334
335 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
336 sizeof(temppsfi.szDisplayName), NULL, NULL);
337 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
338 sizeof(temppsfi.szTypeName), NULL, NULL);
339
340 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
341
342 MultiByteToWideChar(CP_ACP, 0, temppsfi.szTypeName, -1,
343 psfi->szTypeName,
344 sizeof(psfi->szTypeName) / sizeof(WCHAR));
345 MultiByteToWideChar(CP_ACP, 0, temppsfi.szDisplayName, -1,
346 psfi->szDisplayName,
347 sizeof(psfi->szDisplayName) / sizeof(WCHAR));
348
349 HeapFree(GetProcessHeap(), 0, temppath);
350
351 return ret;
352}
353
354/*************************************************************************
355 * SHGetFileInfo [SHELL32.@]
356 */
357DWORD WINAPI SHGetFileInfoAW(
358 LPCVOID path,
359 DWORD dwFileAttributes,
360 LPVOID psfi,
361 UINT sizeofpsfi,
362 UINT flags)
363{
364 if(SHELL_OsIsUnicode())
365 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
366 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
367}
368
369/*************************************************************************
370 * DuplicateIcon [SHELL32.188]
371 */
372HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
373{
374 ICONINFO IconInfo;
375 HICON hDupIcon = 0;
376
377 TRACE("(%04x, %04x)\n", hInstance, hIcon);
378
379 if(GetIconInfo(hIcon, &IconInfo))
380 {
381 hDupIcon = CreateIconIndirect(&IconInfo);
382
383 /* clean up hbmMask and hbmColor */
384 DeleteObject(IconInfo.hbmMask);
385 DeleteObject(IconInfo.hbmColor);
386 }
387
388 return hDupIcon;
389}
390
391
392/*************************************************************************
393 * ExtractIconA [SHELL32.133]
394 *
395 * fixme
396 * is the filename is not a file return 1
397 */
398#ifdef __WIN32OS2__
399HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
400 UINT nIconIndex )
401{
402 HGLOBAL handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
403 TRACE_(shell)("\n");
404 if( handle )
405 {
406 HICON* ptr = (HICON*)GlobalLock(handle);
407 HICON hIcon = *ptr;
408
409 GlobalFree(handle);
410 return hIcon;
411 }
412 return 0;
413}
414#else
415HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
416 UINT nIconIndex )
417{ HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
418 TRACE("\n");
419 if( handle )
420 {
421 HICON16* ptr = (HICON16*)GlobalLock16(handle);
422 HICON16 hIcon = *ptr;
423
424 GlobalFree16(handle);
425 return hIcon;
426 }
427 return 0;
428}
429#endif
430
431/*************************************************************************
432 * ExtractIconW [SHELL32.180]
433 *
434 * fixme
435 * is the filename is not a file return 1
436 */
437HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
438 UINT nIconIndex )
439{ LPSTR exefn;
440 HICON ret;
441 TRACE("\n");
442
443 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
444 ret = ExtractIconA(hInstance,exefn,nIconIndex);
445
446 HeapFree(GetProcessHeap(),0,exefn);
447 return ret;
448}
449
450/*************************************************************************
451 * FindExecutableA [SHELL32.184]
452 */
453HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
454 LPSTR lpResult )
455{ HINSTANCE retval=31; /* default - 'No association was found' */
456 char old_dir[1024];
457
458 TRACE("File %s, Dir %s\n",
459 (lpFile != NULL?lpFile:"-"),
460 (lpDirectory != NULL?lpDirectory:"-"));
461
462 lpResult[0]='\0'; /* Start off with an empty return string */
463
464 /* trap NULL parameters on entry */
465 if (( lpFile == NULL ) || ( lpResult == NULL ))
466 { /* FIXME - should throw a warning, perhaps! */
467 return 2; /* File not found. Close enough, I guess. */
468 }
469
470 if (lpDirectory)
471 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
472 SetCurrentDirectoryA( lpDirectory );
473 }
474
475 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
476
477 TRACE("returning %s\n", lpResult);
478 if (lpDirectory)
479 SetCurrentDirectoryA( old_dir );
480 return retval;
481}
482
483/*************************************************************************
484 * FindExecutableW [SHELL32.219]
485 */
486HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
487 LPWSTR lpResult)
488{
489 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
490 return 31; /* default - 'No association was found' */
491}
492
493typedef struct
494{ LPCSTR szApp;
495 LPCSTR szOtherStuff;
496 HICON hIcon;
497} ABOUT_INFO;
498
499#define IDC_STATIC_TEXT 100
500#define IDC_LISTBOX 99
501#define IDC_WINE_TEXT 98
502
503#define DROP_FIELD_TOP (-15)
504#define DROP_FIELD_HEIGHT 15
505
506extern HICON hIconTitleFont;
507
508static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
509{ HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
510 if( hWndCtl )
511 { GetWindowRect( hWndCtl, lprect );
512 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
513 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
514 return TRUE;
515 }
516 return FALSE;
517}
518
519/*************************************************************************
520 * SHAppBarMessage [SHELL32.207]
521 */
522UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
523{
524 int width=data->rc.right - data->rc.left;
525 int height=data->rc.bottom - data->rc.top;
526 RECT rec=data->rc;
527 switch (msg)
528 { case ABM_GETSTATE:
529 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
530 case ABM_GETTASKBARPOS:
531 GetWindowRect(data->hWnd, &rec);
532 data->rc=rec;
533 return TRUE;
534 case ABM_ACTIVATE:
535 SetActiveWindow(data->hWnd);
536 return TRUE;
537 case ABM_GETAUTOHIDEBAR:
538 data->hWnd=GetActiveWindow();
539 return TRUE;
540 case ABM_NEW:
541 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
542 width,height,SWP_SHOWWINDOW);
543 return TRUE;
544 case ABM_QUERYPOS:
545 GetWindowRect(data->hWnd, &(data->rc));
546 return TRUE;
547 case ABM_REMOVE:
548 FIXME("ABM_REMOVE broken\n");
549 /* FIXME: this is wrong; should it be DestroyWindow instead? */
550 /*CloseHandle(data->hWnd);*/
551 return TRUE;
552 case ABM_SETAUTOHIDEBAR:
553 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
554 width,height,SWP_SHOWWINDOW);
555 return TRUE;
556 case ABM_SETPOS:
557 data->uEdge=(ABE_RIGHT | ABE_LEFT);
558 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
559 width,height,SWP_SHOWWINDOW);
560 return TRUE;
561 case ABM_WINDOWPOSCHANGED:
562 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
563 width,height,SWP_SHOWWINDOW);
564 return TRUE;
565 }
566 return FALSE;
567}
568
569/*************************************************************************
570 * SHHelpShortcuts_RunDLL [SHELL32.224]
571 *
572 */
573DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
574{ FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
575 dwArg1, dwArg2, dwArg3, dwArg4);
576
577 return 0;
578}
579
580/*************************************************************************
581 * SHLoadInProc [SHELL32.225]
582 * Create an instance of specified object class from within
583 * the shell process and release it immediately
584 */
585
586DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
587{
588 IUnknown * pUnk = NULL;
589 TRACE("%s\n", debugstr_guid(rclsid));
590
591 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
592 if(pUnk)
593 {
594 IUnknown_Release(pUnk);
595 return NOERROR;
596 }
597 return DISP_E_MEMBERNOTFOUND;
598}
599
600//replacement in shell32_odin.cpp
601#ifndef __WIN32OS2__
602/*************************************************************************
603 * ShellExecuteA [SHELL32.245]
604 */
605HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
606 LPCSTR lpFile, LPCSTR lpParameters,
607 LPCSTR lpDirectory, INT iShowCmd )
608{ TRACE("\n");
609 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
610 lpDirectory, iShowCmd );
611}
612#endif
613
614/*************************************************************************
615 * ShellExecuteW [SHELL32.294]
616 * from shellapi.h
617 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
618 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
619 */
620HINSTANCE WINAPI
621ShellExecuteW(
622 HWND hwnd,
623 LPCWSTR lpOperation,
624 LPCWSTR lpFile,
625 LPCWSTR lpParameters,
626 LPCWSTR lpDirectory,
627 INT nShowCmd) {
628
629 FIXME(": stub\n");
630 return 0;
631}
632
633//replacement in shell32_odin.cpp
634#ifndef __WIN32OS2__
635/*************************************************************************
636 * AboutDlgProc (internal)
637 */
638BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
639 LPARAM lParam )
640{ HWND hWndCtl;
641 char Template[512], AppTitle[512];
642
643 TRACE("\n");
644
645 switch(msg)
646 { case WM_INITDIALOG:
647 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
648 if (info)
649 { const char* const *pstr = SHELL_People;
650 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
651 GetWindowTextA( hWnd, Template, sizeof(Template) );
652 sprintf( AppTitle, Template, info->szApp );
653 SetWindowTextA( hWnd, AppTitle );
654 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
655 info->szOtherStuff );
656 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
657 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
658 if (!hIconTitleFont)
659 {
660 LOGFONTA logFont;
661 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
662 hIconTitleFont = CreateFontIndirectA( &logFont );
663 }
664 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
665 while (*pstr)
666 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
667 pstr++;
668 }
669 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
670 }
671 }
672 return 1;
673
674 case WM_PAINT:
675 { RECT rect;
676 PAINTSTRUCT ps;
677 HDC hDC = BeginPaint( hWnd, &ps );
678
679 if( __get_dropline( hWnd, &rect ) ) {
680 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
681 MoveToEx( hDC, rect.left, rect.top, NULL );
682 LineTo( hDC, rect.right, rect.bottom );
683 }
684 EndPaint( hWnd, &ps );
685 }
686 break;
687
688 case WM_LBTRACKPOINT:
689 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
690 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
691 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
692 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
693 if( idx != -1 )
694 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
695 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
696 char* pstr = (char*)GlobalLock16( hMemObj );
697
698 if( pstr )
699 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
700 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
701 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
702 UpdateWindow( hWndCtl );
703 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
704 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
705 }
706 if( hMemObj )
707 GlobalFree16( hMemObj );
708 }
709 }
710 }
711 break;
712
713 case WM_QUERYDROPOBJECT:
714 if( wParam == 0 )
715 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
716 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
717 { RECT rect;
718 if( __get_dropline( hWnd, &rect ) )
719 { POINT pt;
720 pt.x=lpDragInfo->pt.x;
721 pt.x=lpDragInfo->pt.y;
722 rect.bottom += DROP_FIELD_HEIGHT;
723 if( PtInRect( &rect, pt ) )
724 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
725 return TRUE;
726 }
727 }
728 }
729 }
730 break;
731
732 case WM_DROPOBJECT:
733 if( wParam == hWnd )
734 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
735 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
736 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
737 if( pstr )
738 { static char __appendix_str[] = " with";
739
740 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
741 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
742 if( !strncmp( Template, "WINE", 4 ) )
743 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
744 else
745 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
746 *pch = '\0';
747 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
748 (WPARAM)-1, (LPARAM)Template );
749 }
750
751 strcpy( Template, pstr );
752 strcat( Template, __appendix_str );
753 SetWindowTextA( hWndCtl, Template );
754 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
755 return TRUE;
756 }
757 }
758 }
759 break;
760
761 case WM_COMMAND:
762 if (wParam == IDOK)
763 { EndDialog(hWnd, TRUE);
764 return TRUE;
765 }
766 break;
767 case WM_CLOSE:
768 EndDialog(hWnd, TRUE);
769 break;
770 }
771
772 return 0;
773}
774
775
776/*************************************************************************
777 * ShellAboutA [SHELL32.243]
778 */
779BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
780 HICON hIcon )
781{ ABOUT_INFO info;
782 HRSRC hRes;
783 LPVOID template;
784 TRACE("\n");
785
786 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
787 return FALSE;
788 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
789 return FALSE;
790
791 info.szApp = szApp;
792 info.szOtherStuff = szOtherStuff;
793 info.hIcon = hIcon;
794 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
795 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
796 template, hWnd, AboutDlgProc, (LPARAM)&info );
797}
798
799
800/*************************************************************************
801 * ShellAboutW [SHELL32.244]
802 */
803BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
804 HICON hIcon )
805{ BOOL ret;
806 ABOUT_INFO info;
807 HRSRC hRes;
808 LPVOID template;
809
810 TRACE("\n");
811
812 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
813 return FALSE;
814 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
815 return FALSE;
816
817 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
818 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
819 info.hIcon = hIcon;
820 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
821 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
822 template, hWnd, AboutDlgProc, (LPARAM)&info );
823 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
824 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
825 return ret;
826}
827#endif //#ifndef __WIN32OS2__
828
829/*************************************************************************
830 * FreeIconList
831 */
832void WINAPI FreeIconList( DWORD dw )
833{ FIXME("(%lx): stub\n",dw);
834}
835
836/***********************************************************************
837 * DllGetVersion [SHELL32]
838 *
839 * Retrieves version information of the 'SHELL32.DLL'
840 *
841 * PARAMS
842 * pdvi [O] pointer to version information structure.
843 *
844 * RETURNS
845 * Success: S_OK
846 * Failure: E_INVALIDARG
847 *
848 * NOTES
849 * Returns version of a shell32.dll from IE4.01 SP1.
850 */
851
852HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
853{
854 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
855 {
856 WARN("wrong DLLVERSIONINFO size from app");
857 return E_INVALIDARG;
858 }
859
860 pdvi->dwMajorVersion = 4;
861 pdvi->dwMinorVersion = 72;
862 pdvi->dwBuildNumber = 3110;
863 pdvi->dwPlatformID = 1;
864
865 TRACE("%lu.%lu.%lu.%lu\n",
866 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
867 pdvi->dwBuildNumber, pdvi->dwPlatformID);
868
869 return S_OK;
870}
871/*************************************************************************
872 * global variables of the shell32.dll
873 * all are once per process
874 *
875 */
876void (* WINAPI pDLLInitComctl)(LPVOID);
877LPVOID (* WINAPI pCOMCTL32_Alloc) (INT);
878BOOL (* WINAPI pCOMCTL32_Free) (LPVOID);
879
880/* 2001-10-17 @@@PH
881 either me or VAC308 seems to be confused here:
882 if complains about redeclaration of the corresponding functions
883 in commctrl.h
884
885 Even more strangely, all variables "pFunction" are automatically
886 percieved as "Function".
887*/
888#if 0
889HDPA (* WINAPI lpDPA_Create) (INT);
890INT (* WINAPI lpDPA_InsertPtr) (const HDPA, INT, LPVOID);
891BOOL (* WINAPI lpDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
892LPVOID (* WINAPI lpDPA_GetPtr) (const HDPA, INT);
893BOOL (* WINAPI lpDPA_Destroy) (const HDPA);
894INT (* WINAPI lpDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
895LPVOID (* WINAPI lpDPA_DeletePtr) (const HDPA hdpa, INT i);
896HANDLE (* WINAPI lpCreateMRUListA) (LPVOID lpcml);
897DWORD (* WINAPI lpFreeMRUListA) (HANDLE hMRUList);
898INT (* WINAPI lpAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
899INT (* WINAPI lpFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
900INT (* WINAPI lpEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
901#endif
902
903static HINSTANCE hComctl32;
904static INT shell32_RefCount = 0;
905
906LONG shell32_ObjCount = 0;
907HINSTANCE shell32_hInstance = 0;
908HIMAGELIST ShellSmallIconList = 0;
909HIMAGELIST ShellBigIconList = 0;
910
911
912/*************************************************************************
913 * SHELL32 LibMain
914 *
915 * NOTES
916 * calling oleinitialize here breaks sone apps.
917 */
918
919BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
920{
921 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
922
923 switch (fdwReason)
924 {
925 case DLL_PROCESS_ATTACH:
926 shell32_RefCount++;
927 if (shell32_hInstance) return TRUE;
928
929 shell32_hInstance = hinstDLL;
930 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
931 DisableThreadLibraryCalls(shell32_hInstance);
932
933 if (!hComctl32)
934 {
935 ERR("P A N I C SHELL32 loading failed\n");
936 return FALSE;
937 }
938
939 /* comctl32 */
940 pDLLInitComctl=(void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
941 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
942 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
943#if 0
944 lpDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
945 lpDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
946 lpDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
947 lpDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
948 lpDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
949 lpDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
950 lpDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
951 lpCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
952 lpFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
953 lpAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
954 lpFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
955 lpEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
956#endif
957 /* initialize the common controls */
958 if (pDLLInitComctl)
959 {
960 pDLLInitComctl(NULL);
961 }
962 InitCommonControlsEx(NULL);
963
964 SIC_Initialize();
965 SYSTRAY_Init();
966 InitChangeNotifications();
967 SHInitRestricted(NULL, NULL);
968 break;
969
970 case DLL_THREAD_ATTACH:
971 shell32_RefCount++;
972 break;
973
974 case DLL_THREAD_DETACH:
975 shell32_RefCount--;
976 break;
977
978 case DLL_PROCESS_DETACH:
979 shell32_RefCount--;
980
981 if ( !shell32_RefCount )
982 {
983 shell32_hInstance = 0;
984
985 if (pdesktopfolder)
986 {
987 IShellFolder_Release(pdesktopfolder);
988 pdesktopfolder = NULL;
989 }
990
991 SIC_Destroy();
992 FreeChangeNotifications();
993
994 /* this one is here to check if AddRef/Release is balanced */
995 if (shell32_ObjCount)
996 {
997 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
998 }
999 }
1000
1001 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
1002 break;
1003 }
1004 return TRUE;
1005}
1006
1007/*************************************************************************
1008 * DllInstall [SHELL32.202]
1009 *
1010 * PARAMETERS
1011 *
1012 * BOOL bInstall - TRUE for install, FALSE for uninstall
1013 * LPCWSTR pszCmdLine - command line (unused by shell32?)
1014 */
1015
1016HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
1017{
1018 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1019
1020 return S_OK; /* indicate success */
1021}
1022
1023/***********************************************************************
1024 * DllCanUnloadNow (SHELL32.@)
1025 */
1026HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
1027{
1028 FIXME("(void): stub\n");
1029
1030 return S_FALSE;
1031}
Note: See TracBrowser for help on using the repository browser.