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

Last change on this file since 21464 was 21464, checked in by dmik, 15 years ago

Added argcA and argvA (valid only after WinMain() is entered) that may be used by applications to access ANSI versions of command line arguments w/o performing manual command line conversion and parsing. The standard argc and argv arguments, as opposed, are always in the OEM codepage.

File size: 30.1 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 ICOM_CINTERFACE 1
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 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
323 temppath = HeapAlloc(GetProcessHeap(), 0, len);
324 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
325
326 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
327 sizeof(temppsfi.szDisplayName), NULL, NULL);
328 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
329 sizeof(temppsfi.szTypeName), NULL, NULL);
330
331 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
332
333 HeapFree(GetProcessHeap(), 0, temppath);
334
335 return ret;
336}
337
338/*************************************************************************
339 * SHGetFileInfo [SHELL32.@]
340 */
341DWORD WINAPI SHGetFileInfoAW(
342 LPCVOID path,
343 DWORD dwFileAttributes,
344 LPVOID psfi,
345 UINT sizeofpsfi,
346 UINT flags)
347{
348 if(SHELL_OsIsUnicode())
349 return SHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags );
350 return SHGetFileInfoA(path, dwFileAttributes, psfi, sizeofpsfi, flags );
351}
352
353/*************************************************************************
354 * DuplicateIcon [SHELL32.188]
355 */
356HICON WINAPI DuplicateIcon( HINSTANCE hInstance, HICON hIcon)
357{
358 ICONINFO IconInfo;
359 HICON hDupIcon = 0;
360
361 TRACE("(%04x, %04x)\n", hInstance, hIcon);
362
363 if(GetIconInfo(hIcon, &IconInfo))
364 {
365 hDupIcon = CreateIconIndirect(&IconInfo);
366
367 /* clean up hbmMask and hbmColor */
368 DeleteObject(IconInfo.hbmMask);
369 DeleteObject(IconInfo.hbmColor);
370 }
371
372 return hDupIcon;
373}
374
375
376/*************************************************************************
377 * ExtractIconA [SHELL32.133]
378 *
379 * fixme
380 * is the filename is not a file return 1
381 */
382#ifdef __WIN32OS2__
383HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
384 UINT nIconIndex )
385{
386 HGLOBAL handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
387 TRACE_(shell)("\n");
388 if( handle )
389 {
390 HICON* ptr = (HICON*)GlobalLock(handle);
391 HICON hIcon = *ptr;
392
393 GlobalFree(handle);
394 return hIcon;
395 }
396 return 0;
397}
398#else
399HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
400 UINT nIconIndex )
401{ HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
402 TRACE("\n");
403 if( handle )
404 {
405 HICON16* ptr = (HICON16*)GlobalLock16(handle);
406 HICON16 hIcon = *ptr;
407
408 GlobalFree16(handle);
409 return hIcon;
410 }
411 return 0;
412}
413#endif
414
415/*************************************************************************
416 * ExtractIconW [SHELL32.180]
417 *
418 * fixme
419 * is the filename is not a file return 1
420 */
421HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
422 UINT nIconIndex )
423{ LPSTR exefn;
424 HICON ret;
425 TRACE("\n");
426
427 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
428 ret = ExtractIconA(hInstance,exefn,nIconIndex);
429
430 HeapFree(GetProcessHeap(),0,exefn);
431 return ret;
432}
433
434/*************************************************************************
435 * FindExecutableA [SHELL32.184]
436 */
437HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
438 LPSTR lpResult )
439{ HINSTANCE retval=31; /* default - 'No association was found' */
440 char old_dir[1024];
441
442 TRACE("File %s, Dir %s\n",
443 (lpFile != NULL?lpFile:"-"),
444 (lpDirectory != NULL?lpDirectory:"-"));
445
446 lpResult[0]='\0'; /* Start off with an empty return string */
447
448 /* trap NULL parameters on entry */
449 if (( lpFile == NULL ) || ( lpResult == NULL ))
450 { /* FIXME - should throw a warning, perhaps! */
451 return 2; /* File not found. Close enough, I guess. */
452 }
453
454 if (lpDirectory)
455 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
456 SetCurrentDirectoryA( lpDirectory );
457 }
458
459 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
460
461 TRACE("returning %s\n", lpResult);
462 if (lpDirectory)
463 SetCurrentDirectoryA( old_dir );
464 return retval;
465}
466
467/*************************************************************************
468 * FindExecutableW [SHELL32.219]
469 */
470HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
471 LPWSTR lpResult)
472{
473 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
474 return 31; /* default - 'No association was found' */
475}
476
477typedef struct
478{ LPCSTR szApp;
479 LPCSTR szOtherStuff;
480 HICON hIcon;
481} ABOUT_INFO;
482
483#define IDC_STATIC_TEXT 100
484#define IDC_LISTBOX 99
485#define IDC_WINE_TEXT 98
486
487#define DROP_FIELD_TOP (-15)
488#define DROP_FIELD_HEIGHT 15
489
490extern HICON hIconTitleFont;
491
492static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
493{ HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
494 if( hWndCtl )
495 { GetWindowRect( hWndCtl, lprect );
496 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
497 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
498 return TRUE;
499 }
500 return FALSE;
501}
502
503/*************************************************************************
504 * SHAppBarMessage [SHELL32.207]
505 */
506UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
507{
508 int width=data->rc.right - data->rc.left;
509 int height=data->rc.bottom - data->rc.top;
510 RECT rec=data->rc;
511 switch (msg)
512 { case ABM_GETSTATE:
513 return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
514 case ABM_GETTASKBARPOS:
515 GetWindowRect(data->hWnd, &rec);
516 data->rc=rec;
517 return TRUE;
518 case ABM_ACTIVATE:
519 SetActiveWindow(data->hWnd);
520 return TRUE;
521 case ABM_GETAUTOHIDEBAR:
522 data->hWnd=GetActiveWindow();
523 return TRUE;
524 case ABM_NEW:
525 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
526 width,height,SWP_SHOWWINDOW);
527 return TRUE;
528 case ABM_QUERYPOS:
529 GetWindowRect(data->hWnd, &(data->rc));
530 return TRUE;
531 case ABM_REMOVE:
532 FIXME("ABM_REMOVE broken\n");
533 /* FIXME: this is wrong; should it be DestroyWindow instead? */
534 /*CloseHandle(data->hWnd);*/
535 return TRUE;
536 case ABM_SETAUTOHIDEBAR:
537 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
538 width,height,SWP_SHOWWINDOW);
539 return TRUE;
540 case ABM_SETPOS:
541 data->uEdge=(ABE_RIGHT | ABE_LEFT);
542 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
543 width,height,SWP_SHOWWINDOW);
544 return TRUE;
545 case ABM_WINDOWPOSCHANGED:
546 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
547 width,height,SWP_SHOWWINDOW);
548 return TRUE;
549 }
550 return FALSE;
551}
552
553/*************************************************************************
554 * SHHelpShortcuts_RunDLL [SHELL32.224]
555 *
556 */
557DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
558{ FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
559 dwArg1, dwArg2, dwArg3, dwArg4);
560
561 return 0;
562}
563
564/*************************************************************************
565 * SHLoadInProc [SHELL32.225]
566 * Create an instance of specified object class from within
567 * the shell process and release it immediately
568 */
569
570DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
571{
572 IUnknown * pUnk = NULL;
573 TRACE("%s\n", debugstr_guid(rclsid));
574
575 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
576 if(pUnk)
577 {
578 IUnknown_Release(pUnk);
579 return NOERROR;
580 }
581 return DISP_E_MEMBERNOTFOUND;
582}
583
584//replacement in shell32_odin.cpp
585#ifndef __WIN32OS2__
586/*************************************************************************
587 * ShellExecuteA [SHELL32.245]
588 */
589HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
590 LPCSTR lpFile, LPCSTR lpParameters,
591 LPCSTR lpDirectory, INT iShowCmd )
592{ TRACE("\n");
593 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
594 lpDirectory, iShowCmd );
595}
596#endif
597
598/*************************************************************************
599 * ShellExecuteW [SHELL32.294]
600 * from shellapi.h
601 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
602 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
603 */
604HINSTANCE WINAPI
605ShellExecuteW(
606 HWND hwnd,
607 LPCWSTR lpOperation,
608 LPCWSTR lpFile,
609 LPCWSTR lpParameters,
610 LPCWSTR lpDirectory,
611 INT nShowCmd) {
612
613 FIXME(": stub\n");
614 return 0;
615}
616
617//replacement in shell32_odin.cpp
618#ifndef __WIN32OS2__
619/*************************************************************************
620 * AboutDlgProc (internal)
621 */
622BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
623 LPARAM lParam )
624{ HWND hWndCtl;
625 char Template[512], AppTitle[512];
626
627 TRACE("\n");
628
629 switch(msg)
630 { case WM_INITDIALOG:
631 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
632 if (info)
633 { const char* const *pstr = SHELL_People;
634 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
635 GetWindowTextA( hWnd, Template, sizeof(Template) );
636 sprintf( AppTitle, Template, info->szApp );
637 SetWindowTextA( hWnd, AppTitle );
638 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
639 info->szOtherStuff );
640 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
641 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
642 if (!hIconTitleFont)
643 {
644 LOGFONTA logFont;
645 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
646 hIconTitleFont = CreateFontIndirectA( &logFont );
647 }
648 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
649 while (*pstr)
650 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
651 pstr++;
652 }
653 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
654 }
655 }
656 return 1;
657
658 case WM_PAINT:
659 { RECT rect;
660 PAINTSTRUCT ps;
661 HDC hDC = BeginPaint( hWnd, &ps );
662
663 if( __get_dropline( hWnd, &rect ) ) {
664 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
665 MoveToEx( hDC, rect.left, rect.top, NULL );
666 LineTo( hDC, rect.right, rect.bottom );
667 }
668 EndPaint( hWnd, &ps );
669 }
670 break;
671
672 case WM_LBTRACKPOINT:
673 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
674 if( (INT16)GetKeyState( VK_CONTROL ) < 0 )
675 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
676 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
677 if( idx != -1 )
678 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
679 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
680 char* pstr = (char*)GlobalLock16( hMemObj );
681
682 if( pstr )
683 { HCURSOR hCursor = LoadCursorA( 0, MAKEINTRESOURCEA(OCR_DRAGOBJECT) );
684 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
685 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
686 UpdateWindow( hWndCtl );
687 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
688 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
689 }
690 if( hMemObj )
691 GlobalFree16( hMemObj );
692 }
693 }
694 }
695 break;
696
697 case WM_QUERYDROPOBJECT:
698 if( wParam == 0 )
699 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
700 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
701 { RECT rect;
702 if( __get_dropline( hWnd, &rect ) )
703 { POINT pt;
704 pt.x=lpDragInfo->pt.x;
705 pt.x=lpDragInfo->pt.y;
706 rect.bottom += DROP_FIELD_HEIGHT;
707 if( PtInRect( &rect, pt ) )
708 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
709 return TRUE;
710 }
711 }
712 }
713 }
714 break;
715
716 case WM_DROPOBJECT:
717 if( wParam == hWnd )
718 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
719 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
720 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
721 if( pstr )
722 { static char __appendix_str[] = " with";
723
724 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
725 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
726 if( !strncmp( Template, "WINE", 4 ) )
727 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
728 else
729 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
730 *pch = '\0';
731 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
732 (WPARAM)-1, (LPARAM)Template );
733 }
734
735 strcpy( Template, pstr );
736 strcat( Template, __appendix_str );
737 SetWindowTextA( hWndCtl, Template );
738 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
739 return TRUE;
740 }
741 }
742 }
743 break;
744
745 case WM_COMMAND:
746 if (wParam == IDOK)
747 { EndDialog(hWnd, TRUE);
748 return TRUE;
749 }
750 break;
751 case WM_CLOSE:
752 EndDialog(hWnd, TRUE);
753 break;
754 }
755
756 return 0;
757}
758
759
760/*************************************************************************
761 * ShellAboutA [SHELL32.243]
762 */
763BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
764 HICON hIcon )
765{ ABOUT_INFO info;
766 HRSRC hRes;
767 LPVOID template;
768 TRACE("\n");
769
770 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
771 return FALSE;
772 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
773 return FALSE;
774
775 info.szApp = szApp;
776 info.szOtherStuff = szOtherStuff;
777 info.hIcon = hIcon;
778 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
779 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
780 template, hWnd, AboutDlgProc, (LPARAM)&info );
781}
782
783
784/*************************************************************************
785 * ShellAboutW [SHELL32.244]
786 */
787BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
788 HICON hIcon )
789{ BOOL ret;
790 ABOUT_INFO info;
791 HRSRC hRes;
792 LPVOID template;
793
794 TRACE("\n");
795
796 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
797 return FALSE;
798 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
799 return FALSE;
800
801 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
802 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
803 info.hIcon = hIcon;
804 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
805 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
806 template, hWnd, AboutDlgProc, (LPARAM)&info );
807 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
808 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
809 return ret;
810}
811#endif //#ifndef __WIN32OS2__
812
813/*************************************************************************
814 * FreeIconList
815 */
816void WINAPI FreeIconList( DWORD dw )
817{ FIXME("(%lx): stub\n",dw);
818}
819
820/***********************************************************************
821 * DllGetVersion [SHELL32]
822 *
823 * Retrieves version information of the 'SHELL32.DLL'
824 *
825 * PARAMS
826 * pdvi [O] pointer to version information structure.
827 *
828 * RETURNS
829 * Success: S_OK
830 * Failure: E_INVALIDARG
831 *
832 * NOTES
833 * Returns version of a shell32.dll from IE4.01 SP1.
834 */
835
836HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
837{
838 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
839 {
840 WARN("wrong DLLVERSIONINFO size from app");
841 return E_INVALIDARG;
842 }
843
844 pdvi->dwMajorVersion = 4;
845 pdvi->dwMinorVersion = 72;
846 pdvi->dwBuildNumber = 3110;
847 pdvi->dwPlatformID = 1;
848
849 TRACE("%lu.%lu.%lu.%lu\n",
850 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
851 pdvi->dwBuildNumber, pdvi->dwPlatformID);
852
853 return S_OK;
854}
855/*************************************************************************
856 * global variables of the shell32.dll
857 * all are once per process
858 *
859 */
860void (* WINAPI pDLLInitComctl)(LPVOID);
861LPVOID (* WINAPI pCOMCTL32_Alloc) (INT);
862BOOL (* WINAPI pCOMCTL32_Free) (LPVOID);
863
864/* 2001-10-17 @@@PH
865 either me or VAC308 seems to be confused here:
866 if complains about redeclaration of the corresponding functions
867 in commctrl.h
868
869 Even more strangely, all variables "pFunction" are automatically
870 percieved as "Function".
871*/
872#if 0
873HDPA (* WINAPI lpDPA_Create) (INT);
874INT (* WINAPI lpDPA_InsertPtr) (const HDPA, INT, LPVOID);
875BOOL (* WINAPI lpDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
876LPVOID (* WINAPI lpDPA_GetPtr) (const HDPA, INT);
877BOOL (* WINAPI lpDPA_Destroy) (const HDPA);
878INT (* WINAPI lpDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
879LPVOID (* WINAPI lpDPA_DeletePtr) (const HDPA hdpa, INT i);
880HANDLE (* WINAPI lpCreateMRUListA) (LPVOID lpcml);
881DWORD (* WINAPI lpFreeMRUListA) (HANDLE hMRUList);
882INT (* WINAPI lpAddMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData);
883INT (* WINAPI lpFindMRUData) (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
884INT (* WINAPI lpEnumMRUListA) (HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
885#endif
886
887static HINSTANCE hComctl32;
888static INT shell32_RefCount = 0;
889
890LONG shell32_ObjCount = 0;
891HINSTANCE shell32_hInstance = 0;
892HIMAGELIST ShellSmallIconList = 0;
893HIMAGELIST ShellBigIconList = 0;
894
895
896/*************************************************************************
897 * SHELL32 LibMain
898 *
899 * NOTES
900 * calling oleinitialize here breaks sone apps.
901 */
902
903BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
904{
905 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
906
907 switch (fdwReason)
908 {
909 case DLL_PROCESS_ATTACH:
910 shell32_RefCount++;
911 if (shell32_hInstance) return TRUE;
912
913 shell32_hInstance = hinstDLL;
914 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
915 DisableThreadLibraryCalls(shell32_hInstance);
916
917 if (!hComctl32)
918 {
919 ERR("P A N I C SHELL32 loading failed\n");
920 return FALSE;
921 }
922
923 /* comctl32 */
924 pDLLInitComctl=(void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
925 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
926 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
927#if 0
928 lpDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
929 lpDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
930 lpDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
931 lpDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
932 lpDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
933 lpDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
934 lpDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
935 lpCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
936 lpFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
937 lpAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
938 lpFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
939 lpEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
940#endif
941 /* initialize the common controls */
942 if (pDLLInitComctl)
943 {
944 pDLLInitComctl(NULL);
945 }
946 InitCommonControlsEx(NULL);
947
948 SIC_Initialize();
949 SYSTRAY_Init();
950 InitChangeNotifications();
951 SHInitRestricted(NULL, NULL);
952 break;
953
954 case DLL_THREAD_ATTACH:
955 shell32_RefCount++;
956 break;
957
958 case DLL_THREAD_DETACH:
959 shell32_RefCount--;
960 break;
961
962 case DLL_PROCESS_DETACH:
963 shell32_RefCount--;
964
965 if ( !shell32_RefCount )
966 {
967 shell32_hInstance = 0;
968
969 if (pdesktopfolder)
970 {
971 IShellFolder_Release(pdesktopfolder);
972 pdesktopfolder = NULL;
973 }
974
975 SIC_Destroy();
976 FreeChangeNotifications();
977
978 /* this one is here to check if AddRef/Release is balanced */
979 if (shell32_ObjCount)
980 {
981 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
982 }
983 }
984
985 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
986 break;
987 }
988 return TRUE;
989}
990
991/*************************************************************************
992 * DllInstall [SHELL32.202]
993 *
994 * PARAMETERS
995 *
996 * BOOL bInstall - TRUE for install, FALSE for uninstall
997 * LPCWSTR pszCmdLine - command line (unused by shell32?)
998 */
999
1000HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
1001{
1002 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
1003
1004 return S_OK; /* indicate success */
1005}
1006
1007/***********************************************************************
1008 * DllCanUnloadNow (SHELL32.@)
1009 */
1010HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
1011{
1012 FIXME("(void): stub\n");
1013
1014 return S_FALSE;
1015}
Note: See TracBrowser for help on using the repository browser.