New stubs NTSHChangeNotifyRegister, NTSHChangeNotifyDeregister.
[wine/multimedia.git] / dlls / shell32 / shell32_main.c
blob5acf03c8e1119ac157eeb193ffb33d07571909aa
1 /*
2 * Shell basics
4 * 1998 Marcus Meissner
5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
6 */
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <ctype.h>
12 #include "windows.h"
13 #include "wine/winuser16.h"
14 #include "winerror.h"
15 #include "file.h"
16 #include "shell.h"
17 #include "heap.h"
18 #include "module.h"
19 #include "neexe.h"
20 #include "resource.h"
21 #include "dlgs.h"
22 #include "win.h"
23 #include "cursoricon.h"
24 #include "interfaces.h"
25 #include "sysmetrics.h"
26 #include "shlobj.h"
27 #include "debug.h"
28 #include "winreg.h"
29 #include "imagelist.h"
30 #include "sysmetrics.h"
31 #include "commctrl.h"
32 #include "authors.h"
33 #include "pidl.h"
34 #include "shell32_main.h"
36 /*************************************************************************
37 * CommandLineToArgvW [SHELL32.7]
39 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
40 { LPWSTR *argv,s,t;
41 int i;
42 TRACE(shell,"\n");
44 /* to get writeable copy */
45 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
46 s=cmdline;i=0;
47 while (*s)
48 { /* space */
49 if (*s==0x0020)
50 { i++;
51 s++;
52 while (*s && *s==0x0020)
53 s++;
54 continue;
56 s++;
58 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
59 s=t=cmdline;
60 i=0;
61 while (*s)
62 { if (*s==0x0020)
63 { *s=0;
64 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
65 *s=0x0020;
66 while (*s && *s==0x0020)
67 s++;
68 if (*s)
69 t=s+1;
70 else
71 t=s;
72 continue;
74 s++;
76 if (*t)
77 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
78 HeapFree( GetProcessHeap(), 0, cmdline );
79 argv[i]=NULL;
80 *numargs=i;
81 return argv;
84 /*************************************************************************
85 * Control_RunDLL [SHELL32.12]
87 * Wild speculation in the following!
89 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
92 void WINAPI Control_RunDLL( HWND32 hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
94 FIXME(shell, "(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
95 debugstr_a(cmd), arg4);
98 /*************************************************************************
99 * SHGetFileInfoA [SHELL32.254]
101 * FIXME
105 DWORD WINAPI SHGetFileInfo32A(LPCSTR path,DWORD dwFileAttributes,
106 SHFILEINFO32A *psfi, UINT32 sizeofpsfi,
107 UINT32 flags )
108 { CHAR szTemp[MAX_PATH];
109 LPPIDLDATA pData;
110 LPITEMIDLIST pPidlTemp = NULL;
111 DWORD ret=0;
113 TRACE(shell,"(%s,0x%lx,%p,0x%x,0x%x)\n",
114 path,dwFileAttributes,psfi,sizeofpsfi,flags);
116 /* translate the pidl to a path*/
117 if (flags & SHGFI_PIDL)
118 { pPidlTemp = (LPCITEMIDLIST)path;
119 SHGetPathFromIDList32A (pPidlTemp, szTemp);
120 TRACE(shell,"pidl=%p is %s\n", path, szTemp);
122 else
123 { strcpy(szTemp,path);
124 TRACE(shell,"path=%s\n", szTemp);
127 if (flags & SHGFI_ATTRIBUTES)
128 { if (flags & SHGFI_PIDL)
129 { pData = _ILGetDataPointer((LPCITEMIDLIST)path);
130 psfi->dwAttributes = pData->u.generic.dwSFGAO; /* fixme: no direct access*/
131 ret=TRUE;
133 else
134 { psfi->dwAttributes=SFGAO_FILESYSTEM;
135 ret=TRUE;
137 FIXME(shell,"file attributes, stub\n");
140 if (flags & SHGFI_DISPLAYNAME)
141 { if (flags & SHGFI_PIDL)
142 { strcpy(psfi->szDisplayName,szTemp);
144 else
145 { strcpy(psfi->szDisplayName,path);
147 TRACE(shell,"displayname=%s\n", psfi->szDisplayName);
148 ret=TRUE;
151 if (flags & SHGFI_TYPENAME)
152 { FIXME(shell,"get the file type, stub\n");
153 strcpy(psfi->szTypeName,"FIXME: Type");
154 ret=TRUE;
157 if (flags & SHGFI_ICONLOCATION)
158 { FIXME(shell,"location of icon, stub\n");
159 strcpy(psfi->szDisplayName,"");
160 ret=TRUE;
163 if (flags & SHGFI_EXETYPE)
164 FIXME(shell,"type of executable, stub\n");
166 if (flags & SHGFI_LINKOVERLAY)
167 FIXME(shell,"set icon to link, stub\n");
169 if (flags & SHGFI_OPENICON)
170 FIXME(shell,"set to open icon, stub\n");
172 if (flags & SHGFI_SELECTED)
173 FIXME(shell,"set icon to selected, stub\n");
175 if (flags & SHGFI_SHELLICONSIZE)
176 FIXME(shell,"set icon to shell size, stub\n");
178 if (flags & SHGFI_USEFILEATTRIBUTES)
179 FIXME(shell,"use the dwFileAttributes, stub\n");
181 if (flags & SHGFI_ICON)
182 { FIXME(shell,"icon handle\n");
183 if (flags & SHGFI_SMALLICON)
184 { TRACE(shell,"set to small icon\n");
185 psfi->hIcon=pImageList_GetIcon(ShellSmallIconList,32,ILD_NORMAL);
186 ret = (DWORD) ShellSmallIconList;
188 else
189 { TRACE(shell,"set to big icon\n");
190 psfi->hIcon=pImageList_GetIcon(ShellBigIconList,32,ILD_NORMAL);
191 ret = (DWORD) ShellBigIconList;
195 if (flags & SHGFI_SYSICONINDEX)
196 { if (!pPidlTemp)
197 { pPidlTemp = ILCreateFromPath (szTemp);
199 psfi->iIcon = SHMapPIDLToSystemImageListIndex (NULL, pPidlTemp, 0);
200 TRACE(shell,"-- SYSICONINDEX %i\n", psfi->iIcon);
202 if (flags & SHGFI_SMALLICON)
203 { TRACE(shell,"set to small icon\n");
204 ret = (DWORD) ShellSmallIconList;
206 else
207 { TRACE(shell,"set to big icon\n");
208 ret = (DWORD) ShellBigIconList;
212 return ret;
215 /*************************************************************************
216 * SHGetFileInfo32W [SHELL32.255]
218 * FIXME
222 DWORD WINAPI SHGetFileInfo32W(LPCWSTR path,DWORD dwFileAttributes,
223 SHFILEINFO32W *psfi, UINT32 sizeofpsfi,
224 UINT32 flags )
225 { FIXME(shell,"(%s,0x%lx,%p,0x%x,0x%x)\n",
226 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
227 return 0;
230 /*************************************************************************
231 * ExtractIcon32A (SHELL32.133)
233 HICON32 WINAPI ExtractIcon32A( HINSTANCE32 hInstance, LPCSTR lpszExeFileName,
234 UINT32 nIconIndex )
235 { HGLOBAL16 handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
236 TRACE(shell,"\n");
237 if( handle )
239 HICON16* ptr = (HICON16*)GlobalLock16(handle);
240 HICON16 hIcon = *ptr;
242 GlobalFree16(handle);
243 return hIcon;
245 return 0;
248 /*************************************************************************
249 * ExtractIcon32W (SHELL32.180)
251 HICON32 WINAPI ExtractIcon32W( HINSTANCE32 hInstance, LPCWSTR lpszExeFileName,
252 UINT32 nIconIndex )
253 { LPSTR exefn;
254 HICON32 ret;
255 TRACE(shell,"\n");
257 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
258 ret = ExtractIcon32A(hInstance,exefn,nIconIndex);
260 HeapFree(GetProcessHeap(),0,exefn);
261 return ret;
264 /*************************************************************************
265 * FindExecutable32A (SHELL32.184)
267 HINSTANCE32 WINAPI FindExecutable32A( LPCSTR lpFile, LPCSTR lpDirectory,
268 LPSTR lpResult )
269 { HINSTANCE32 retval=31; /* default - 'No association was found' */
270 char old_dir[1024];
272 TRACE(shell, "File %s, Dir %s\n",
273 (lpFile != NULL?lpFile:"-"),
274 (lpDirectory != NULL?lpDirectory:"-"));
276 lpResult[0]='\0'; /* Start off with an empty return string */
278 /* trap NULL parameters on entry */
279 if (( lpFile == NULL ) || ( lpResult == NULL ))
280 { /* FIXME - should throw a warning, perhaps! */
281 return 2; /* File not found. Close enough, I guess. */
284 if (lpDirectory)
285 { GetCurrentDirectory32A( sizeof(old_dir), old_dir );
286 SetCurrentDirectory32A( lpDirectory );
289 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
291 TRACE(shell, "returning %s\n", lpResult);
292 if (lpDirectory)
293 SetCurrentDirectory32A( old_dir );
294 return retval;
297 /*************************************************************************
298 * FindExecutable32W (SHELL32.219)
300 HINSTANCE32 WINAPI FindExecutable32W(LPCWSTR lpFile, LPCWSTR lpDirectory,
301 LPWSTR lpResult)
303 FIXME(shell, "(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
304 return 31; /* default - 'No association was found' */
307 typedef struct
308 { LPCSTR szApp;
309 LPCSTR szOtherStuff;
310 HICON32 hIcon;
311 } ABOUT_INFO;
313 #define IDC_STATIC_TEXT 100
314 #define IDC_LISTBOX 99
315 #define IDC_WINE_TEXT 98
317 #define DROP_FIELD_TOP (-15)
318 #define DROP_FIELD_HEIGHT 15
320 extern HICON32 hIconTitleFont;
322 static BOOL32 __get_dropline( HWND32 hWnd, LPRECT32 lprect )
323 { HWND32 hWndCtl = GetDlgItem32(hWnd, IDC_WINE_TEXT);
324 if( hWndCtl )
325 { GetWindowRect32( hWndCtl, lprect );
326 MapWindowPoints32( 0, hWnd, (LPPOINT32)lprect, 2 );
327 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
328 return TRUE;
330 return FALSE;
333 /*************************************************************************
334 * SHAppBarMessage32 [SHELL32.207]
336 UINT32 WINAPI SHAppBarMessage32(DWORD msg, PAPPBARDATA data)
337 { FIXME(shell,"(0x%08lx,%p): stub\n", msg, data);
338 #if 0
339 switch (msg)
340 { case ABM_ACTIVATE:
341 case ABM_GETAUTOHIDEBAR:
342 case ABM_GETSTATE:
343 case ABM_GETTASKBARPOS:
344 case ABM_NEW:
345 case ABM_QUERYPOS:
346 case ABM_REMOVE:
347 case ABM_SETAUTOHIDEBAR:
348 case ABM_SETPOS:
349 case ABM_WINDOWPOSCHANGED:
352 #endif
353 return 0;
356 /*************************************************************************
357 * SHBrowseForFolderA [SHELL32.209]
360 LPITEMIDLIST WINAPI SHBrowseForFolder32A (LPBROWSEINFO32A lpbi)
361 { FIXME (shell, "(%lx,%s) empty stub!\n", (DWORD)lpbi, lpbi->lpszTitle);
362 return NULL;
365 /*************************************************************************
366 * SHGetDesktopFolder [SHELL32.216]
368 * SDK header win95/shlobj.h: This is equivalent to call CoCreateInstance with
369 * CLSID_ShellDesktop
370 * CoCreateInstance(CLSID_Desktop, NULL, CLSCTX_INPROC, IID_IShellFolder, &pshf);
372 * RETURNS
373 * the interface to the shell desktop folder.
375 * FIXME
376 * the pdesktopfolder has to be released at the end (at dll unloading???)
378 LPSHELLFOLDER pdesktopfolder=NULL;
380 DWORD WINAPI SHGetDesktopFolder(LPSHELLFOLDER *shellfolder)
381 { HRESULT hres = E_OUTOFMEMORY;
382 LPCLASSFACTORY lpclf;
383 TRACE(shell,"%p->(%p)\n",shellfolder,*shellfolder);
385 if (pdesktopfolder)
386 { hres = NOERROR;
388 else
389 { lpclf = IClassFactory_Constructor();
390 /* fixme: the buildin IClassFactory_Constructor is at the moment only
391 for rclsid=CLSID_ShellDesktop, so we get the right Interface (jsch)*/
392 if(lpclf)
393 { hres = lpclf->lpvtbl->fnCreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
394 lpclf->lpvtbl->fnRelease(lpclf);
398 if (pdesktopfolder)
399 { *shellfolder = pdesktopfolder;
400 pdesktopfolder->lpvtbl->fnAddRef(pdesktopfolder);
402 else
403 { *shellfolder=NULL;
406 TRACE(shell,"-- %p->(%p)\n",shellfolder, *shellfolder);
407 return hres;
409 /*************************************************************************
410 * SHGetPathFromIDList [SHELL32.221][NT 4.0: SHELL32.219]
412 BOOL32 WINAPI SHGetPathFromIDList32(LPCITEMIDLIST pidl,LPSTR pszPath)
413 { TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
414 return SHGetPathFromIDList32A(pidl,pszPath);
417 /*************************************************************************
418 * SHGetSpecialFolderLocation [SHELL32.223]
419 * gets the folder locations from the registry and creates a pidl
420 * creates missing reg keys and directorys
422 * PARAMS
423 * hwndOwner [I]
424 * nFolder [I] CSIDL_xxxxx
425 * ppidl [O] PIDL of a special folder
427 * RETURNS
428 * HResult
430 * FIXME
431 * - look for "User Shell Folder" first
434 HRESULT WINAPI SHGetSpecialFolderLocation(HWND32 hwndOwner, INT32 nFolder, LPITEMIDLIST * ppidl)
435 { LPSHELLFOLDER shellfolder;
436 DWORD pchEaten,tpathlen=MAX_PATH,type,dwdisp,res;
437 CHAR pszTemp[256],buffer[256],tpath[MAX_PATH],npath[MAX_PATH];
438 LPWSTR lpszDisplayName = (LPWSTR)&pszTemp[0];
439 HKEY key;
441 enum
442 { FT_UNKNOWN= 0x00000000,
443 FT_DIR= 0x00000001,
444 FT_DESKTOP= 0x00000002,
445 FT_SPECIAL= 0x00000003
446 } tFolder;
448 TRACE(shell,"(%04x,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
450 strcpy(buffer,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\");
452 res=RegCreateKeyEx32A(HKEY_CURRENT_USER,buffer,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&key,&dwdisp);
453 if (res)
454 { ERR(shell,"Could not create key %s %08lx \n",buffer,res);
455 return E_OUTOFMEMORY;
458 tFolder=FT_DIR;
459 switch (nFolder)
460 { case CSIDL_BITBUCKET:
461 strcpy (buffer,"xxx"); /*not in the registry*/
462 TRACE (shell,"looking for Recycler\n");
463 tFolder=FT_UNKNOWN;
464 break;
465 case CSIDL_CONTROLS:
466 strcpy (buffer,"xxx"); /*virtual folder*/
467 TRACE (shell,"looking for Control\n");
468 tFolder=FT_UNKNOWN;
469 break;
470 case CSIDL_DESKTOP:
471 strcpy (buffer,"xxx"); /*virtual folder*/
472 TRACE (shell,"looking for Desktop\n");
473 tFolder=FT_DESKTOP;
474 break;
475 case CSIDL_DESKTOPDIRECTORY:
476 case CSIDL_COMMON_DESKTOPDIRECTORY:
477 strcpy (buffer,"Desktop");
478 break;
479 case CSIDL_DRIVES:
480 strcpy (buffer,"xxx"); /*virtual folder*/
481 TRACE (shell,"looking for Drives\n");
482 tFolder=FT_SPECIAL;
483 break;
484 case CSIDL_FONTS:
485 strcpy (buffer,"Fonts");
486 break;
487 case CSIDL_NETHOOD:
488 strcpy (buffer,"NetHood");
489 break;
490 case CSIDL_PRINTHOOD:
491 strcpy (buffer,"PrintHood");
492 break;
493 case CSIDL_NETWORK:
494 strcpy (buffer,"xxx"); /*virtual folder*/
495 TRACE (shell,"looking for Network\n");
496 tFolder=FT_UNKNOWN;
497 break;
498 case CSIDL_APPDATA:
499 strcpy (buffer,"Appdata");
500 break;
501 case CSIDL_PERSONAL:
502 strcpy (buffer,"Personal");
503 break;
504 case CSIDL_FAVORITES:
505 strcpy (buffer,"Favorites");
506 break;
507 case CSIDL_PRINTERS:
508 strcpy (buffer,"PrintHood");
509 break;
510 case CSIDL_COMMON_PROGRAMS:
511 case CSIDL_PROGRAMS:
512 strcpy (buffer,"Programs");
513 break;
514 case CSIDL_RECENT:
515 strcpy (buffer,"Recent");
516 break;
517 case CSIDL_SENDTO:
518 strcpy (buffer,"SendTo");
519 break;
520 case CSIDL_COMMON_STARTMENU:
521 case CSIDL_STARTMENU:
522 strcpy (buffer,"Start Menu");
523 break;
524 case CSIDL_COMMON_STARTUP:
525 case CSIDL_STARTUP:
526 strcpy (buffer,"Startup");
527 break;
528 case CSIDL_TEMPLATES:
529 strcpy (buffer,"Templates");
530 break;
531 default:
532 ERR (shell,"unknown CSIDL 0x%08x\n", nFolder);
533 tFolder=FT_UNKNOWN;
534 break;
537 TRACE(shell,"Key=%s\n",buffer);
539 type=REG_SZ;
541 switch (tFolder)
542 { case FT_DIR:
543 /* Directory: get the value from the registry, if its not there
544 create it and the directory*/
545 if (RegQueryValueEx32A(key,buffer,NULL,&type,(LPBYTE)tpath,&tpathlen))
546 { GetWindowsDirectory32A(npath,MAX_PATH);
547 PathAddBackslash32A(npath);
548 switch (nFolder)
549 { case CSIDL_DESKTOPDIRECTORY:
550 case CSIDL_COMMON_DESKTOPDIRECTORY:
551 strcat (npath,"Desktop");
552 break;
553 case CSIDL_FONTS:
554 strcat (npath,"Fonts");
555 break;
556 case CSIDL_NETHOOD:
557 strcat (npath,"NetHood");
558 break;
559 case CSIDL_PRINTHOOD:
560 strcat (npath,"PrintHood");
561 break;
562 case CSIDL_APPDATA:
563 strcat (npath,"Appdata");
564 break;
565 case CSIDL_PERSONAL:
566 strcpy (npath,"C:\\Personal");
567 break;
568 case CSIDL_FAVORITES:
569 strcat (npath,"Favorites");
570 break;
571 case CSIDL_PRINTERS:
572 strcat (npath,"PrintHood");
573 break;
574 case CSIDL_COMMON_PROGRAMS:
575 case CSIDL_PROGRAMS:
576 strcat (npath,"Start Menu");
577 CreateDirectory32A(npath,NULL);
578 strcat (npath,"\\Programs");
579 break;
580 case CSIDL_RECENT:
581 strcat (npath,"Recent");
582 break;
583 case CSIDL_SENDTO:
584 strcat (npath,"SendTo");
585 break;
586 case CSIDL_COMMON_STARTMENU:
587 case CSIDL_STARTMENU:
588 strcat (npath,"Start Menu");
589 break;
590 case CSIDL_COMMON_STARTUP:
591 case CSIDL_STARTUP:
592 strcat (npath,"Start Menu");
593 CreateDirectory32A(npath,NULL);
594 strcat (npath,"\\Startup");
595 break;
596 case CSIDL_TEMPLATES:
597 strcat (npath,"Templates");
598 break;
599 default:
600 RegCloseKey(key);
601 return E_OUTOFMEMORY;
603 if (RegSetValueEx32A(key,buffer,0,REG_SZ,(LPBYTE)npath,sizeof(npath)+1))
604 { ERR(shell,"could not create value %s\n",buffer);
605 RegCloseKey(key);
606 return E_OUTOFMEMORY;
608 TRACE(shell,"value %s=%s created\n",buffer,npath);
609 CreateDirectory32A(npath,NULL);
610 strcpy(tpath,npath);
612 break;
613 case FT_DESKTOP:
614 strcpy (tpath,"Desktop");
615 break;
616 case FT_SPECIAL:
617 if (nFolder==CSIDL_DRIVES)
618 strcpy (tpath,"My Computer");
619 break;
620 default:
621 RegCloseKey(key);
622 return E_OUTOFMEMORY;
625 RegCloseKey(key);
627 TRACE(shell,"Value=%s\n",tpath);
628 LocalToWideChar32(lpszDisplayName, tpath, 256);
630 if (SHGetDesktopFolder(&shellfolder)==S_OK)
631 { shellfolder->lpvtbl->fnParseDisplayName(shellfolder,hwndOwner, NULL,lpszDisplayName,&pchEaten,ppidl,NULL);
632 shellfolder->lpvtbl->fnRelease(shellfolder);
635 TRACE(shell, "-- (new pidl %p)\n",*ppidl);
636 return NOERROR;
638 /*************************************************************************
639 * SHHelpShortcuts_RunDLL [SHELL32.224]
642 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
643 { FIXME (exec, "(%lx, %lx, %lx, %lx) empty stub!\n",
644 dwArg1, dwArg2, dwArg3, dwArg4);
646 return 0;
649 /*************************************************************************
650 * SHLoadInProc [SHELL32.225]
654 DWORD WINAPI SHLoadInProc (DWORD dwArg1)
655 { FIXME (shell, "(%lx) empty stub!\n", dwArg1);
656 return 0;
659 /*************************************************************************
660 * ShellExecute32A (SHELL32.245)
662 HINSTANCE32 WINAPI ShellExecute32A( HWND32 hWnd, LPCSTR lpOperation,
663 LPCSTR lpFile, LPCSTR lpParameters,
664 LPCSTR lpDirectory, INT32 iShowCmd )
665 { TRACE(shell,"\n");
666 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
667 lpDirectory, iShowCmd );
670 /*************************************************************************
671 * ShellExecute32W [SHELL32.294]
672 * from shellapi.h
673 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
674 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
676 HINSTANCE32 WINAPI
677 ShellExecute32W(
678 HWND32 hwnd,
679 LPCWSTR lpOperation,
680 LPCWSTR lpFile,
681 LPCWSTR lpParameters,
682 LPCWSTR lpDirectory,
683 INT32 nShowCmd) {
685 FIXME(shell,": stub\n");
686 return 0;
694 /*************************************************************************
695 * AboutDlgProc32 (not an exported API function)
697 LRESULT WINAPI AboutDlgProc32( HWND32 hWnd, UINT32 msg, WPARAM32 wParam,
698 LPARAM lParam )
699 { HWND32 hWndCtl;
700 char Template[512], AppTitle[512];
702 TRACE(shell,"\n");
704 switch(msg)
705 { case WM_INITDIALOG:
706 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
707 if (info)
708 { const char* const *pstr = SHELL_People;
709 SendDlgItemMessage32A(hWnd, stc1, STM_SETICON32,info->hIcon, 0);
710 GetWindowText32A( hWnd, Template, sizeof(Template) );
711 sprintf( AppTitle, Template, info->szApp );
712 SetWindowText32A( hWnd, AppTitle );
713 SetWindowText32A( GetDlgItem32(hWnd, IDC_STATIC_TEXT),
714 info->szOtherStuff );
715 hWndCtl = GetDlgItem32(hWnd, IDC_LISTBOX);
716 SendMessage32A( hWndCtl, WM_SETREDRAW, 0, 0 );
717 SendMessage32A( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
718 while (*pstr)
719 { SendMessage32A( hWndCtl, LB_ADDSTRING32, (WPARAM32)-1, (LPARAM)*pstr );
720 pstr++;
722 SendMessage32A( hWndCtl, WM_SETREDRAW, 1, 0 );
725 return 1;
727 case WM_PAINT:
728 { RECT32 rect;
729 PAINTSTRUCT32 ps;
730 HDC32 hDC = BeginPaint32( hWnd, &ps );
732 if( __get_dropline( hWnd, &rect ) ) {
733 SelectObject32( hDC, GetStockObject32( BLACK_PEN ) );
734 MoveToEx32( hDC, rect.left, rect.top, NULL );
735 LineTo32( hDC, rect.right, rect.bottom );
737 EndPaint32( hWnd, &ps );
739 break;
741 case WM_LBTRACKPOINT:
742 hWndCtl = GetDlgItem32(hWnd, IDC_LISTBOX);
743 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
744 { if( DragDetect32( hWndCtl, *((LPPOINT32)&lParam) ) )
745 { INT32 idx = SendMessage32A( hWndCtl, LB_GETCURSEL32, 0, 0 );
746 if( idx != -1 )
747 { INT32 length = SendMessage32A( hWndCtl, LB_GETTEXTLEN32, (WPARAM32)idx, 0 );
748 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
749 char* pstr = (char*)GlobalLock16( hMemObj );
751 if( pstr )
752 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
753 SendMessage32A( hWndCtl, LB_GETTEXT32, (WPARAM32)idx, (LPARAM)pstr );
754 SendMessage32A( hWndCtl, LB_DELETESTRING32, (WPARAM32)idx, 0 );
755 UpdateWindow32( hWndCtl );
756 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
757 SendMessage32A( hWndCtl, LB_ADDSTRING32, (WPARAM32)-1, (LPARAM)pstr );
759 if( hMemObj )
760 GlobalFree16( hMemObj );
764 break;
766 case WM_QUERYDROPOBJECT:
767 if( wParam == 0 )
768 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
769 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
770 { RECT32 rect;
771 if( __get_dropline( hWnd, &rect ) )
772 { POINT32 pt;
773 pt.x=lpDragInfo->pt.x;
774 pt.x=lpDragInfo->pt.y;
775 rect.bottom += DROP_FIELD_HEIGHT;
776 if( PtInRect32( &rect, pt ) )
777 { SetWindowLong32A( hWnd, DWL_MSGRESULT, 1 );
778 return TRUE;
783 break;
785 case WM_DROPOBJECT:
786 if( wParam == hWnd )
787 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
788 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
789 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
790 if( pstr )
791 { static char __appendix_str[] = " with";
793 hWndCtl = GetDlgItem32( hWnd, IDC_WINE_TEXT );
794 SendMessage32A( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
795 if( !lstrncmp32A( Template, "WINE", 4 ) )
796 SetWindowText32A( GetDlgItem32(hWnd, IDC_STATIC_TEXT), Template );
797 else
798 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
799 *pch = '\0';
800 SendMessage32A( GetDlgItem32(hWnd, IDC_LISTBOX), LB_ADDSTRING32,
801 (WPARAM32)-1, (LPARAM)Template );
804 lstrcpy32A( Template, pstr );
805 lstrcat32A( Template, __appendix_str );
806 SetWindowText32A( hWndCtl, Template );
807 SetWindowLong32A( hWnd, DWL_MSGRESULT, 1 );
808 return TRUE;
812 break;
814 case WM_COMMAND:
815 if (wParam == IDOK)
816 { EndDialog32(hWnd, TRUE);
817 return TRUE;
819 break;
821 return 0;
825 /*************************************************************************
826 * ShellAbout32A (SHELL32.243)
828 BOOL32 WINAPI ShellAbout32A( HWND32 hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
829 HICON32 hIcon )
830 { ABOUT_INFO info;
831 TRACE(shell,"\n");
832 info.szApp = szApp;
833 info.szOtherStuff = szOtherStuff;
834 info.hIcon = hIcon;
835 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
836 return DialogBoxIndirectParam32A( WIN_GetWindowInstance( hWnd ),
837 SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
838 hWnd, AboutDlgProc32, (LPARAM)&info );
842 /*************************************************************************
843 * ShellAbout32W (SHELL32.244)
845 BOOL32 WINAPI ShellAbout32W( HWND32 hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
846 HICON32 hIcon )
847 { BOOL32 ret;
848 ABOUT_INFO info;
850 TRACE(shell,"\n");
852 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
853 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
854 info.hIcon = hIcon;
855 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
856 ret = DialogBoxIndirectParam32A( WIN_GetWindowInstance( hWnd ),
857 SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
858 hWnd, AboutDlgProc32, (LPARAM)&info );
859 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
860 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
861 return ret;
864 /*************************************************************************
865 * Shell_NotifyIcon [SHELL32.296]
866 * FIXME
867 * This function is supposed to deal with the systray.
868 * Any ideas on how this is to be implimented?
870 BOOL32 WINAPI Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATA pnid )
871 { TRACE(shell,"\n");
872 return FALSE;
875 /*************************************************************************
876 * Shell_NotifyIcon [SHELL32.297]
877 * FIXME
878 * This function is supposed to deal with the systray.
879 * Any ideas on how this is to be implimented?
881 BOOL32 WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATA pnid )
882 { TRACE(shell,"\n");
883 return FALSE;
886 /*************************************************************************
887 * FreeIconList
889 void WINAPI FreeIconList( DWORD dw )
890 { FIXME(shell, "(%lx): stub\n",dw);
893 /*************************************************************************
894 * SHGetPathFromIDList32A [SHELL32.261][NT 4.0: SHELL32.220]
896 * PARAMETERS
897 * pidl, [IN] pidl
898 * pszPath [OUT] path
900 * RETURNS
901 * path from a passed PIDL.
903 * NOTES
904 * exported by name
906 * FIXME
907 * fnGetDisplayNameOf can return different types of OLEString
909 DWORD WINAPI SHGetPathFromIDList32A (LPCITEMIDLIST pidl,LPSTR pszPath)
910 { STRRET lpName;
911 LPSHELLFOLDER shellfolder;
912 CHAR buffer[MAX_PATH],tpath[MAX_PATH];
913 DWORD type,tpathlen=MAX_PATH,dwdisp;
914 HKEY key;
916 TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
918 if (!pidl)
919 { strcpy(buffer,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\");
921 if (RegCreateKeyEx32A(HKEY_CURRENT_USER,buffer,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&key,&dwdisp))
922 { return E_OUTOFMEMORY;
924 type=REG_SZ;
925 strcpy (buffer,"Desktop"); /*registry name*/
926 if ( RegQueryValueEx32A(key,buffer,NULL,&type,(LPBYTE)tpath,&tpathlen))
927 { GetWindowsDirectory32A(tpath,MAX_PATH);
928 PathAddBackslash32A(tpath);
929 strcat (tpath,"Desktop"); /*folder name*/
930 RegSetValueEx32A(key,buffer,0,REG_SZ,(LPBYTE)tpath,tpathlen);
931 CreateDirectory32A(tpath,NULL);
933 RegCloseKey(key);
934 strcpy(pszPath,tpath);
936 else
937 { if (SHGetDesktopFolder(&shellfolder)==S_OK)
938 { shellfolder->lpvtbl->fnGetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&lpName);
939 shellfolder->lpvtbl->fnRelease(shellfolder);
941 /*WideCharToLocal32(pszPath, lpName.u.pOleStr, MAX_PATH);*/
942 strcpy(pszPath,lpName.u.cStr);
943 /* fixme free the olestring*/
945 TRACE(shell,"-- (%s)\n",pszPath);
946 return NOERROR;
948 /*************************************************************************
949 * SHGetPathFromIDList32W [SHELL32.262]
951 DWORD WINAPI SHGetPathFromIDList32W (LPCITEMIDLIST pidl,LPWSTR pszPath)
952 { char sTemp[MAX_PATH];
954 TRACE (shell,"(pidl=%p)\n", pidl);
956 SHGetPathFromIDList32A (pidl, sTemp);
957 lstrcpyAtoW(pszPath, sTemp);
959 TRACE(shell,"-- (%s)\n",debugstr_w(pszPath));
961 return NOERROR;
965 void (CALLBACK* pDLLInitComctl)(void);
966 INT32 (CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
967 INT32 (CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
968 HIMAGELIST (CALLBACK * pImageList_Create) (INT32,INT32,UINT32,INT32,INT32);
969 HICON32 (CALLBACK * pImageList_GetIcon) (HIMAGELIST, INT32, UINT32);
970 INT32 (CALLBACK* pImageList_GetImageCount)(HIMAGELIST);
972 LPVOID (CALLBACK* pCOMCTL32_Alloc) (INT32);
973 BOOL32 (CALLBACK* pCOMCTL32_Free) (LPVOID);
975 HDPA (CALLBACK* pDPA_Create) (INT32);
976 INT32 (CALLBACK* pDPA_InsertPtr) (const HDPA, INT32, LPVOID);
977 BOOL32 (CALLBACK* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
978 LPVOID (CALLBACK* pDPA_GetPtr) (const HDPA, INT32);
979 BOOL32 (CALLBACK* pDPA_Destroy) (const HDPA);
980 INT32 (CALLBACK *pDPA_Search) (const HDPA, LPVOID, INT32, PFNDPACOMPARE, LPARAM, UINT32);
981 static BOOL32 bShell32IsInitialized=0;
982 /*************************************************************************
983 * SHELL32 LibMain
985 * FIXME
986 * at the moment the icons are extracted from shell32.dll
987 * free the imagelists
989 HINSTANCE32 shell32_hInstance;
991 BOOL32 WINAPI Shell32LibMain(HINSTANCE32 hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
992 { HINSTANCE32 hComctl32;
994 TRACE(shell,"0x%x 0x%lx %p\n", hinstDLL, fdwReason, lpvReserved);
996 shell32_hInstance = hinstDLL;
998 if (fdwReason==DLL_PROCESS_ATTACH && !bShell32IsInitialized)
999 { hComctl32 = LoadLibrary32A("COMCTL32.DLL");
1000 if (hComctl32)
1001 { pDLLInitComctl=GetProcAddress32(hComctl32,"InitCommonControlsEx");
1002 if (pDLLInitComctl)
1003 { pDLLInitComctl();
1005 pImageList_Create=GetProcAddress32(hComctl32,"ImageList_Create");
1006 pImageList_AddIcon=GetProcAddress32(hComctl32,"ImageList_AddIcon");
1007 pImageList_ReplaceIcon=GetProcAddress32(hComctl32,"ImageList_ReplaceIcon");
1008 pImageList_GetIcon=GetProcAddress32(hComctl32,"ImageList_GetIcon");
1009 pImageList_GetImageCount=GetProcAddress32(hComctl32,"ImageList_GetImageCount");
1011 /* imports by ordinal, pray that it works*/
1012 pCOMCTL32_Alloc=GetProcAddress32(hComctl32, (LPCSTR)71L);
1013 pCOMCTL32_Free=GetProcAddress32(hComctl32, (LPCSTR)73L);
1014 pDPA_Create=GetProcAddress32(hComctl32, (LPCSTR)328L);
1015 pDPA_Destroy=GetProcAddress32(hComctl32, (LPCSTR)329L);
1016 pDPA_GetPtr=GetProcAddress32(hComctl32, (LPCSTR)332L);
1017 pDPA_InsertPtr=GetProcAddress32(hComctl32, (LPCSTR)334L);
1018 pDPA_Sort=GetProcAddress32(hComctl32, (LPCSTR)338L);
1019 pDPA_Search=GetProcAddress32(hComctl32, (LPCSTR)339L);
1021 FreeLibrary32(hComctl32);
1023 else
1024 { /* panic, imediately exit wine*/
1025 ERR(shell,"P A N I C error getting functionpointers\n");
1026 exit (1);
1028 SIC_Initialize();
1029 bShell32IsInitialized = TRUE;
1031 return TRUE;