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

Last change on this file since 6666 was 5861, checked in by sandervl, 24 years ago

ifdefs added

File size: 27.3 KB
Line 
1/* $Id: shell32_main.c,v 1.5 2001-06-01 08:22:10 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 "wine/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 */
48LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
49{ LPWSTR *argv,s,t;
50 int i;
51 TRACE("\n");
52
53 /* to get writeable copy */
54 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
55 s=cmdline;i=0;
56 while (*s)
57 { /* space */
58 if (*s==0x0020)
59 { i++;
60 s++;
61 while (*s && *s==0x0020)
62 s++;
63 continue;
64 }
65 s++;
66 }
67 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
68 s=t=cmdline;
69 i=0;
70 while (*s)
71 { if (*s==0x0020)
72 { *s=0;
73 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
74 *s=0x0020;
75 while (*s && *s==0x0020)
76 s++;
77 t=s;
78 continue;
79 }
80 s++;
81 }
82 if (*t)
83 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
84
85 HeapFree( GetProcessHeap(), 0, cmdline );
86 argv[i]=NULL;
87 *numargs=i;
88 return argv;
89}
90
91
92/*************************************************************************
93 * SHGetFileInfoA [SHELL32.@]
94 *
95 */
96
97DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
98 SHFILEINFOA *psfi, UINT sizeofpsfi,
99 UINT flags )
100{
101 char szLoaction[MAX_PATH];
102 int iIndex;
103 DWORD ret = TRUE, dwAttributes = 0;
104 IShellFolder * psfParent = NULL;
105 IExtractIconA * pei = NULL;
106 LPITEMIDLIST pidlLast = NULL, pidl = NULL;
107 HRESULT hr = S_OK;
108
109 TRACE("(%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x)\n",
110 (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, psfi->dwAttributes, sizeofpsfi, flags);
111
112 if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
113 return FALSE;
114
115 /* windows initializes this values regardless of the flags */
116 psfi->szDisplayName[0] = '\0';
117 psfi->szTypeName[0] = '\0';
118 psfi->iIcon = 0;
119
120 if (flags & SHGFI_EXETYPE) {
121 BOOL status = FALSE;
122 HANDLE hfile;
123 DWORD BinaryType;
124 IMAGE_DOS_HEADER mz_header;
125 IMAGE_NT_HEADERS nt;
126 DWORD len;
127 char magic[4];
128
129 if (flags != SHGFI_EXETYPE) return 0;
130
131 status = GetBinaryTypeA (path, &BinaryType);
132 if (!status) return 0;
133 if ((BinaryType == SCS_DOS_BINARY)
134 || (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
135
136 hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
137 NULL, OPEN_EXISTING, 0, 0 );
138 if ( hfile == INVALID_HANDLE_VALUE ) return 0;
139
140 /* The next section is adapted from MODULE_GetBinaryType, as we need
141 * to examine the image header to get OS and version information. We
142 * know from calling GetBinaryTypeA that the image is valid and either
143 * an NE or PE, so much error handling can be omitted.
144 * Seek to the start of the file and read the header information.
145 */
146
147 SetFilePointer( hfile, 0, NULL, SEEK_SET );
148 ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
149
150 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
151 ReadFile( hfile, magic, sizeof(magic), &len, NULL );
152 if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
153 {
154 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
155 ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
156 CloseHandle( hfile );
157 if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
158 return IMAGE_NT_SIGNATURE
159 | (nt.OptionalHeader.MajorSubsystemVersion << 24)
160 | (nt.OptionalHeader.MinorSubsystemVersion << 16);
161 }
162 return IMAGE_NT_SIGNATURE;
163 }
164 else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
165 {
166 IMAGE_OS2_HEADER ne;
167 SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
168 ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
169 CloseHandle( hfile );
170 if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
171 | (ne.ne_expver << 16);
172 return 0;
173 }
174 CloseHandle( hfile );
175 return 0;
176 }
177
178
179 /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
180 the pidl functions fail on not existing file names */
181 if (flags & SHGFI_PIDL)
182 {
183 pidl = (LPCITEMIDLIST) path;
184 if (!pidl )
185 {
186 ERR("pidl is null!\n");
187 return FALSE;
188 }
189 }
190 else if (!(flags & SHGFI_USEFILEATTRIBUTES))
191 {
192 hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
193 /* note: the attributes in ISF::ParseDisplayName are not implemented */
194 }
195
196 /* get the parent shellfolder */
197 if (pidl)
198 {
199 hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
200 }
201
202 /* get the attributes of the child */
203 if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
204 {
205 if (!(flags & SHGFI_ATTR_SPECIFIED))
206 {
207 psfi->dwAttributes = 0xffffffff;
208 }
209 IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
210 }
211
212 /* get the displayname */
213 if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
214 {
215 if (flags & SHGFI_USEFILEATTRIBUTES)
216 {
217 strcpy (psfi->szDisplayName, PathFindFileNameA(path));
218 }
219 else
220 {
221 STRRET str;
222 hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
223 StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
224 }
225 }
226
227 /* get the type name */
228 if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
229 {
230 _ILGetFileType(pidlLast, psfi->szTypeName, 80);
231 }
232
233 /* ### icons ###*/
234 if (flags & SHGFI_LINKOVERLAY)
235 FIXME("set icon to link, stub\n");
236
237 if (flags & SHGFI_SELECTED)
238 FIXME("set icon to selected, stub\n");
239
240 if (flags & SHGFI_SHELLICONSIZE)
241 FIXME("set icon to shell size, stub\n");
242
243 /* get the iconlocation */
244 if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
245 {
246 UINT uDummy,uFlags;
247 hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
248
249 if (SUCCEEDED(hr))
250 {
251 hr = IExtractIconA_GetIconLocation(pei, (flags & SHGFI_OPENICON)? GIL_OPENICON : 0,szLoaction, MAX_PATH, &iIndex, &uFlags);
252 /* fixme what to do with the index? */
253
254 if(uFlags != GIL_NOTFILENAME)
255 strcpy (psfi->szDisplayName, szLoaction);
256 else
257 ret = FALSE;
258
259 IExtractIconA_Release(pei);
260 }
261 }
262
263 /* get icon index (or load icon)*/
264 if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
265 {
266 if (flags & SHGFI_USEFILEATTRIBUTES)
267 {
268 char sTemp [MAX_PATH];
269 char * szExt;
270 DWORD dwNr=0;
271
272 lstrcpynA(sTemp, path, MAX_PATH);
273 szExt = (LPSTR) PathFindExtensionA(sTemp);
274 if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
275 && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
276 {
277 if (!strcmp("%1",sTemp)) /* icon is in the file */
278 {
279 strcpy(sTemp, path);
280 }
281 /* FIXME: if sTemp contains a valid filename, get the icon
282 from there, index is in dwNr
283 */
284 psfi->iIcon = 2;
285 }
286 else /* default icon */
287 {
288 psfi->iIcon = 0;
289 }
290 }
291 else
292 {
293 if (!(PidlToSicIndex(psfParent, pidlLast, (flags & SHGFI_LARGEICON),
294 (flags & SHGFI_OPENICON)? GIL_OPENICON : 0, &(psfi->iIcon))))
295 {
296 ret = FALSE;
297 }
298 }
299 if (ret)
300 {
301 ret = (DWORD) ((flags & SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
302 }
303 }
304
305 /* icon handle */
306 if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
307 psfi->hIcon = ImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
308
309 if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
310 FIXME("unknown attribute!\n");
311
312 if (psfParent)
313 IShellFolder_Release(psfParent);
314
315 if (hr != S_OK)
316 ret = FALSE;
317
318 if(pidlLast) SHFree(pidlLast);
319#ifdef MORE_DEBUG
320 TRACE ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s ret=0x%08lx\n",
321 psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName, ret);
322#endif
323 return ret;
324}
325/*************************************************************************
326 * SHGetFileInfoW [SHELL32.@]
327 */
328
329DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
330 SHFILEINFOW *psfi, UINT sizeofpsfi,
331 UINT flags )
332{
333 INT len;
334 LPSTR temppath;
335 DWORD ret;
336 SHFILEINFOA temppsfi;
337
338 len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
339 temppath = HeapAlloc(GetProcessHeap(), 0, len);
340 WideCharToMultiByte(CP_ACP, 0, path, -1, temppath, len, NULL, NULL);
341
342 WideCharToMultiByte(CP_ACP, 0, psfi->szDisplayName, -1, temppsfi.szDisplayName,
343 sizeof(temppsfi.szDisplayName), NULL, NULL);
344 WideCharToMultiByte(CP_ACP, 0, psfi->szTypeName, -1, temppsfi.szTypeName,
345 sizeof(temppsfi.szTypeName), NULL, NULL);
346
347 ret = SHGetFileInfoA(temppath, dwFileAttributes, &temppsfi, sizeof(temppsfi), flags);
348
349 HeapFree(GetProcessHeap(), 0, temppath);
350
351 return ret;
352}
353
354/*************************************************************************
355 * SHGetFileInfoAW [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 = NULL;
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 CloseHandle(data->hWnd);
549 return TRUE;
550 case ABM_SETAUTOHIDEBAR:
551 SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
552 width,height,SWP_SHOWWINDOW);
553 return TRUE;
554 case ABM_SETPOS:
555 data->uEdge=(ABE_RIGHT | ABE_LEFT);
556 SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
557 width,height,SWP_SHOWWINDOW);
558 return TRUE;
559 case ABM_WINDOWPOSCHANGED:
560 SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
561 width,height,SWP_SHOWWINDOW);
562 return TRUE;
563 }
564 return FALSE;
565}
566
567/*************************************************************************
568 * SHHelpShortcuts_RunDLL [SHELL32.224]
569 *
570 */
571DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
572{ FIXME("(%lx, %lx, %lx, %lx) empty stub!\n",
573 dwArg1, dwArg2, dwArg3, dwArg4);
574
575 return 0;
576}
577
578/*************************************************************************
579 * SHLoadInProc [SHELL32.225]
580 * Create an instance of specified object class from within
581 * the shell process and release it immediately
582 */
583
584DWORD WINAPI SHLoadInProc (REFCLSID rclsid)
585{
586 IUnknown * pUnk = NULL;
587 TRACE("%s\n", debugstr_guid(rclsid));
588
589 CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,(LPVOID*)pUnk);
590 if(pUnk)
591 {
592 IUnknown_Release(pUnk);
593 return NOERROR;
594 }
595 return DISP_E_MEMBERNOTFOUND;
596}
597
598//replacement in shell32_odin.cpp
599#ifndef __WIN32OS2__
600/*************************************************************************
601 * ShellExecuteA [SHELL32.245]
602 */
603HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
604 LPCSTR lpFile, LPCSTR lpParameters,
605 LPCSTR lpDirectory, INT iShowCmd )
606{ TRACE("\n");
607 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
608 lpDirectory, iShowCmd );
609}
610#endif
611
612/*************************************************************************
613 * ShellExecuteW [SHELL32.294]
614 * from shellapi.h
615 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
616 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
617 */
618HINSTANCE WINAPI
619ShellExecuteW(
620 HWND hwnd,
621 LPCWSTR lpOperation,
622 LPCWSTR lpFile,
623 LPCWSTR lpParameters,
624 LPCWSTR lpDirectory,
625 INT nShowCmd) {
626
627 FIXME(": stub\n");
628 return 0;
629}
630
631//replacement in shell32_odin.cpp
632#ifndef __WIN32OS2__
633/*************************************************************************
634 * AboutDlgProc (internal)
635 */
636BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
637 LPARAM lParam )
638{ HWND hWndCtl;
639 char Template[512], AppTitle[512];
640
641 TRACE("\n");
642
643 switch(msg)
644 { case WM_INITDIALOG:
645 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
646 if (info)
647 { const char* const *pstr = SHELL_People;
648 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
649 GetWindowTextA( hWnd, Template, sizeof(Template) );
650 sprintf( AppTitle, Template, info->szApp );
651 SetWindowTextA( hWnd, AppTitle );
652 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
653 info->szOtherStuff );
654 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
655 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
656 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
657 while (*pstr)
658 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
659 pstr++;
660 }
661 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
662 }
663 }
664 return 1;
665
666 case WM_PAINT:
667 { RECT rect;
668 PAINTSTRUCT ps;
669 HDC hDC = BeginPaint( hWnd, &ps );
670
671 if( __get_dropline( hWnd, &rect ) ) {
672 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
673 MoveToEx( hDC, rect.left, rect.top, NULL );
674 LineTo( hDC, rect.right, rect.bottom );
675 }
676 EndPaint( hWnd, &ps );
677 }
678 break;
679
680 case WM_LBTRACKPOINT:
681 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
682 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
683 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
684 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
685 if( idx != -1 )
686 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
687 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
688 char* pstr = (char*)GlobalLock16( hMemObj );
689
690 if( pstr )
691 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
692 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
693 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
694 UpdateWindow( hWndCtl );
695 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
696 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
697 }
698 if( hMemObj )
699 GlobalFree16( hMemObj );
700 }
701 }
702 }
703 break;
704
705 case WM_QUERYDROPOBJECT:
706 if( wParam == 0 )
707 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
708 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
709 { RECT rect;
710 if( __get_dropline( hWnd, &rect ) )
711 { POINT pt;
712 pt.x=lpDragInfo->pt.x;
713 pt.x=lpDragInfo->pt.y;
714 rect.bottom += DROP_FIELD_HEIGHT;
715 if( PtInRect( &rect, pt ) )
716 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
717 return TRUE;
718 }
719 }
720 }
721 }
722 break;
723
724 case WM_DROPOBJECT:
725 if( wParam == hWnd )
726 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
727 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
728 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
729 if( pstr )
730 { static char __appendix_str[] = " with";
731
732 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
733 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
734 if( !strncmp( Template, "WINE", 4 ) )
735 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
736 else
737 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
738 *pch = '\0';
739 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
740 (WPARAM)-1, (LPARAM)Template );
741 }
742
743 strcpy( Template, pstr );
744 strcat( Template, __appendix_str );
745 SetWindowTextA( hWndCtl, Template );
746 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
747 return TRUE;
748 }
749 }
750 }
751 break;
752
753 case WM_COMMAND:
754 if (wParam == IDOK)
755 { EndDialog(hWnd, TRUE);
756 return TRUE;
757 }
758 break;
759 case WM_CLOSE:
760 EndDialog(hWnd, TRUE);
761 break;
762 }
763
764 return 0;
765}
766
767
768/*************************************************************************
769 * ShellAboutA [SHELL32.243]
770 */
771BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
772 HICON hIcon )
773{ ABOUT_INFO info;
774 HRSRC hRes;
775 LPVOID template;
776 TRACE("\n");
777
778 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
779 return FALSE;
780 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
781 return FALSE;
782
783 info.szApp = szApp;
784 info.szOtherStuff = szOtherStuff;
785 info.hIcon = hIcon;
786 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
787 return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
788 template, hWnd, AboutDlgProc, (LPARAM)&info );
789}
790
791
792/*************************************************************************
793 * ShellAboutW [SHELL32.244]
794 */
795BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
796 HICON hIcon )
797{ BOOL ret;
798 ABOUT_INFO info;
799 HRSRC hRes;
800 LPVOID template;
801
802 TRACE("\n");
803
804 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
805 return FALSE;
806 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
807 return FALSE;
808
809 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
810 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
811 info.hIcon = hIcon;
812 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
813 ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
814 template, hWnd, AboutDlgProc, (LPARAM)&info );
815 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
816 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
817 return ret;
818}
819#endif //#ifndef __WIN32OS2__
820
821/*************************************************************************
822 * FreeIconList
823 */
824void WINAPI FreeIconList( DWORD dw )
825{ FIXME("(%lx): stub\n",dw);
826}
827
828/***********************************************************************
829 * DllGetVersion [SHELL32]
830 *
831 * Retrieves version information of the 'SHELL32.DLL'
832 *
833 * PARAMS
834 * pdvi [O] pointer to version information structure.
835 *
836 * RETURNS
837 * Success: S_OK
838 * Failure: E_INVALIDARG
839 *
840 * NOTES
841 * Returns version of a shell32.dll from IE4.01 SP1.
842 */
843
844HRESULT WINAPI SHELL32_DllGetVersion (DLLVERSIONINFO *pdvi)
845{
846 if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
847 {
848 WARN("wrong DLLVERSIONINFO size from app");
849 return E_INVALIDARG;
850 }
851
852 pdvi->dwMajorVersion = 4;
853 pdvi->dwMinorVersion = 72;
854 pdvi->dwBuildNumber = 3110;
855 pdvi->dwPlatformID = 1;
856
857 TRACE("%lu.%lu.%lu.%lu\n",
858 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
859 pdvi->dwBuildNumber, pdvi->dwPlatformID);
860
861 return S_OK;
862}
863/*************************************************************************
864 * global variables of the shell32.dll
865 * all are once per process
866 *
867 */
868void (* WINAPI pDLLInitComctl)(LPVOID);
869
870LPVOID (* WINAPI pCOMCTL32_Alloc) (INT);
871BOOL (* WINAPI pCOMCTL32_Free) (LPVOID);
872
873static HINSTANCE hComctl32;
874static INT shell32_RefCount = 0;
875
876LONG shell32_ObjCount = 0;
877HINSTANCE shell32_hInstance = 0;
878HIMAGELIST ShellSmallIconList = 0;
879HIMAGELIST ShellBigIconList = 0;
880
881
882/*************************************************************************
883 * SHELL32 LibMain
884 *
885 * NOTES
886 * calling oleinitialize here breaks sone apps.
887 */
888
889BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
890{
891 TRACE("0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
892
893 switch (fdwReason)
894 {
895 case DLL_PROCESS_ATTACH:
896 shell32_RefCount++;
897 if (shell32_hInstance) return TRUE;
898
899 shell32_hInstance = hinstDLL;
900 hComctl32 = GetModuleHandleA("COMCTL32.DLL");
901 DisableThreadLibraryCalls(shell32_hInstance);
902
903 if (!hComctl32)
904 {
905 ERR("P A N I C SHELL32 loading failed\n");
906 return FALSE;
907 }
908
909 /* comctl32 */
910 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
911 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
912
913 /* initialize the common controls */
914 InitCommonControlsEx(NULL);
915
916 SIC_Initialize();
917 SYSTRAY_Init();
918 InitChangeNotifications();
919 SHInitRestricted(NULL, NULL);
920 break;
921
922 case DLL_THREAD_ATTACH:
923 shell32_RefCount++;
924 break;
925
926 case DLL_THREAD_DETACH:
927 shell32_RefCount--;
928 break;
929
930 case DLL_PROCESS_DETACH:
931 shell32_RefCount--;
932
933 if ( !shell32_RefCount )
934 {
935 shell32_hInstance = 0;
936
937 if (pdesktopfolder)
938 {
939 IShellFolder_Release(pdesktopfolder);
940 pdesktopfolder = NULL;
941 }
942
943 SIC_Destroy();
944 FreeChangeNotifications();
945
946 /* this one is here to check if AddRef/Release is balanced */
947 if (shell32_ObjCount)
948 {
949 WARN("leaving with %lu objects left (memory leak)\n", shell32_ObjCount);
950 }
951 }
952
953 TRACE("refcount=%u objcount=%lu \n", shell32_RefCount, shell32_ObjCount);
954 break;
955 }
956 return TRUE;
957}
958
959/*************************************************************************
960 * DllInstall [SHELL32.202]
961 *
962 * PARAMETERS
963 *
964 * BOOL bInstall - TRUE for install, FALSE for uninstall
965 * LPCWSTR pszCmdLine - command line (unused by shell32?)
966 */
967
968HRESULT WINAPI SHELL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
969{
970 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
971
972 return S_OK; /* indicate success */
973}
974
975/***********************************************************************
976 * DllCanUnloadNow (SHELL32.@)
977 */
978HRESULT WINAPI SHELL32_DllCanUnloadNow(void)
979{
980 FIXME("(void): stub\n");
981
982 return S_FALSE;
983}
Note: See TracBrowser for help on using the repository browser.