Large-scale renaming of all Win32 functions and types to use the
[wine/hacks.git] / dlls / shell32 / shell32_main.c
blobf0b3c605d4174c45f46a0250932d5e03543ecdf7
1 /*
2 * Shell basics
4 * 1998 Marcus Meissner
5 * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
6 */
7 #include <stdlib.h>
8 #include <string.h>
10 #include "wine/winuser16.h"
11 #include "winerror.h"
12 #include "heap.h"
13 #include "resource.h"
14 #include "dlgs.h"
15 #include "win.h"
16 #include "sysmetrics.h"
17 #include "debug.h"
18 #include "winreg.h"
19 #include "authors.h"
21 #include "shell.h"
22 #include "shellapi.h"
23 #include "pidl.h"
24 #include "shlobj.h"
25 #include "shell32_main.h"
27 #include "shlguid.h"
29 /*************************************************************************
30 * CommandLineToArgvW [SHELL32.7]
32 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
33 { LPWSTR *argv,s,t;
34 int i;
35 TRACE(shell,"\n");
37 /* to get writeable copy */
38 cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
39 s=cmdline;i=0;
40 while (*s)
41 { /* space */
42 if (*s==0x0020)
43 { i++;
44 s++;
45 while (*s && *s==0x0020)
46 s++;
47 continue;
49 s++;
51 argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
52 s=t=cmdline;
53 i=0;
54 while (*s)
55 { if (*s==0x0020)
56 { *s=0;
57 argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
58 *s=0x0020;
59 while (*s && *s==0x0020)
60 s++;
61 if (*s)
62 t=s+1;
63 else
64 t=s;
65 continue;
67 s++;
69 if (*t)
70 argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
71 HeapFree( GetProcessHeap(), 0, cmdline );
72 argv[i]=NULL;
73 *numargs=i;
74 return argv;
77 /*************************************************************************
78 * Control_RunDLL [SHELL32.12]
80 * Wild speculation in the following!
82 * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
85 void WINAPI Control_RunDLL( HWND hwnd, LPCVOID code, LPCSTR cmd, DWORD arg4 )
87 FIXME(shell, "(0x%08x, %p, %s, 0x%08lx): stub\n", hwnd, code,
88 debugstr_a(cmd), arg4);
91 /*************************************************************************
92 * SHGetFileInfoA [SHELL32.254]
94 * FIXME
98 DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
99 SHFILEINFOA *psfi, UINT sizeofpsfi,
100 UINT flags )
101 { CHAR szTemp[MAX_PATH];
102 LPPIDLDATA pData;
103 LPITEMIDLIST pPidlTemp = NULL;
104 DWORD ret=0;
106 TRACE(shell,"(%s,0x%lx,%p,0x%x,0x%x)\n",
107 path,dwFileAttributes,psfi,sizeofpsfi,flags);
109 /* translate the pidl to a path*/
110 if (flags & SHGFI_PIDL)
111 { pPidlTemp = (LPCITEMIDLIST)path;
112 SHGetPathFromIDListA (pPidlTemp, szTemp);
113 TRACE(shell,"pidl=%p is %s\n", path, szTemp);
115 else
116 { strcpy(szTemp,path);
117 TRACE(shell,"path=%s\n", szTemp);
120 if (flags & SHGFI_ATTRIBUTES)
121 { if (flags & SHGFI_PIDL)
122 { pData = _ILGetDataPointer((LPCITEMIDLIST)path);
123 switch (pData->type)
124 { case PT_DESKTOP:
125 psfi->dwAttributes = SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK;
126 case PT_MYCOMP:
127 psfi->dwAttributes = SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
128 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK ;
129 case PT_SPECIAL:
130 psfi->dwAttributes = SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_CAPABILITYMASK;
131 case PT_DRIVE:
132 psfi->dwAttributes = SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
133 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK;
134 case PT_FOLDER:
135 psfi->dwAttributes = SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_CAPABILITYMASK;
136 case PT_VALUE:
137 psfi->dwAttributes = SFGAO_FILESYSTEM | SFGAO_CAPABILITYMASK;
139 ret=TRUE;
141 else
142 { psfi->dwAttributes=SFGAO_FILESYSTEM;
143 ret=TRUE;
145 FIXME(shell,"file attributes, stub\n");
148 if (flags & SHGFI_DISPLAYNAME)
149 { if (flags & SHGFI_PIDL)
150 { strcpy(psfi->szDisplayName,szTemp);
152 else
153 { strcpy(psfi->szDisplayName,path);
155 TRACE(shell,"displayname=%s\n", psfi->szDisplayName);
156 ret=TRUE;
159 if (flags & SHGFI_TYPENAME)
160 { FIXME(shell,"get the file type, stub\n");
161 strcpy(psfi->szTypeName,"FIXME: Type");
162 ret=TRUE;
165 if (flags & SHGFI_ICONLOCATION)
166 { FIXME(shell,"location of icon, stub\n");
167 strcpy(psfi->szDisplayName,"");
168 ret=TRUE;
171 if (flags & SHGFI_EXETYPE)
172 FIXME(shell,"type of executable, stub\n");
174 if (flags & SHGFI_LINKOVERLAY)
175 FIXME(shell,"set icon to link, stub\n");
177 if (flags & SHGFI_OPENICON)
178 FIXME(shell,"set to open icon, stub\n");
180 if (flags & SHGFI_SELECTED)
181 FIXME(shell,"set icon to selected, stub\n");
183 if (flags & SHGFI_SHELLICONSIZE)
184 FIXME(shell,"set icon to shell size, stub\n");
186 if (flags & SHGFI_USEFILEATTRIBUTES)
187 FIXME(shell,"use the dwFileAttributes, stub\n");
189 if (flags & SHGFI_ICON)
190 { FIXME(shell,"icon handle\n");
191 if (flags & SHGFI_SMALLICON)
192 { TRACE(shell,"set to small icon\n");
193 psfi->hIcon=pImageList_GetIcon(ShellSmallIconList,32,ILD_NORMAL);
194 ret = (DWORD) ShellSmallIconList;
196 else
197 { TRACE(shell,"set to big icon\n");
198 psfi->hIcon=pImageList_GetIcon(ShellBigIconList,32,ILD_NORMAL);
199 ret = (DWORD) ShellBigIconList;
203 if (flags & SHGFI_SYSICONINDEX)
204 { if (!pPidlTemp)
205 { pPidlTemp = ILCreateFromPath (szTemp);
207 psfi->iIcon = SHMapPIDLToSystemImageListIndex (NULL, pPidlTemp, 0);
208 TRACE(shell,"-- SYSICONINDEX %i\n", psfi->iIcon);
210 if (flags & SHGFI_SMALLICON)
211 { TRACE(shell,"set to small icon\n");
212 ret = (DWORD) ShellSmallIconList;
214 else
215 { TRACE(shell,"set to big icon\n");
216 ret = (DWORD) ShellBigIconList;
220 return ret;
223 /*************************************************************************
224 * SHGetFileInfo32W [SHELL32.255]
226 * FIXME
230 DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
231 SHFILEINFOW *psfi, UINT sizeofpsfi,
232 UINT flags )
233 { FIXME(shell,"(%s,0x%lx,%p,0x%x,0x%x)\n",
234 debugstr_w(path),dwFileAttributes,psfi,sizeofpsfi,flags);
235 return 0;
238 /*************************************************************************
239 * ExtractIcon32A (SHELL32.133)
241 HICON WINAPI ExtractIconA( HINSTANCE hInstance, LPCSTR lpszExeFileName,
242 UINT nIconIndex )
243 { HGLOBAL16 handle = InternalExtractIcon16(hInstance,lpszExeFileName,nIconIndex, 1);
244 TRACE(shell,"\n");
245 if( handle )
247 HICON16* ptr = (HICON16*)GlobalLock16(handle);
248 HICON16 hIcon = *ptr;
250 GlobalFree16(handle);
251 return hIcon;
253 return 0;
256 /*************************************************************************
257 * ExtractIcon32W (SHELL32.180)
259 HICON WINAPI ExtractIconW( HINSTANCE hInstance, LPCWSTR lpszExeFileName,
260 UINT nIconIndex )
261 { LPSTR exefn;
262 HICON ret;
263 TRACE(shell,"\n");
265 exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
266 ret = ExtractIconA(hInstance,exefn,nIconIndex);
268 HeapFree(GetProcessHeap(),0,exefn);
269 return ret;
272 /*************************************************************************
273 * FindExecutable32A (SHELL32.184)
275 HINSTANCE WINAPI FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory,
276 LPSTR lpResult )
277 { HINSTANCE retval=31; /* default - 'No association was found' */
278 char old_dir[1024];
280 TRACE(shell, "File %s, Dir %s\n",
281 (lpFile != NULL?lpFile:"-"),
282 (lpDirectory != NULL?lpDirectory:"-"));
284 lpResult[0]='\0'; /* Start off with an empty return string */
286 /* trap NULL parameters on entry */
287 if (( lpFile == NULL ) || ( lpResult == NULL ))
288 { /* FIXME - should throw a warning, perhaps! */
289 return 2; /* File not found. Close enough, I guess. */
292 if (lpDirectory)
293 { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
294 SetCurrentDirectoryA( lpDirectory );
297 retval = SHELL_FindExecutable( lpFile, "open", lpResult );
299 TRACE(shell, "returning %s\n", lpResult);
300 if (lpDirectory)
301 SetCurrentDirectoryA( old_dir );
302 return retval;
305 /*************************************************************************
306 * FindExecutable32W (SHELL32.219)
308 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory,
309 LPWSTR lpResult)
311 FIXME(shell, "(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
312 return 31; /* default - 'No association was found' */
315 typedef struct
316 { LPCSTR szApp;
317 LPCSTR szOtherStuff;
318 HICON hIcon;
319 } ABOUT_INFO;
321 #define IDC_STATIC_TEXT 100
322 #define IDC_LISTBOX 99
323 #define IDC_WINE_TEXT 98
325 #define DROP_FIELD_TOP (-15)
326 #define DROP_FIELD_HEIGHT 15
328 extern HICON hIconTitleFont;
330 static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
331 { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT);
332 if( hWndCtl )
333 { GetWindowRect( hWndCtl, lprect );
334 MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
335 lprect->bottom = (lprect->top += DROP_FIELD_TOP);
336 return TRUE;
338 return FALSE;
341 /*************************************************************************
342 * SHAppBarMessage32 [SHELL32.207]
344 UINT WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
345 { FIXME(shell,"(0x%08lx,%p): stub\n", msg, data);
346 #if 0
347 switch (msg)
348 { case ABM_ACTIVATE:
349 case ABM_GETAUTOHIDEBAR:
350 case ABM_GETSTATE:
351 case ABM_GETTASKBARPOS:
352 case ABM_NEW:
353 case ABM_QUERYPOS:
354 case ABM_REMOVE:
355 case ABM_SETAUTOHIDEBAR:
356 case ABM_SETPOS:
357 case ABM_WINDOWPOSCHANGED:
360 #endif
361 return 0;
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;
387 } else {
388 lpclf = IClassFactory_Constructor();
389 /* fixme: the buildin IClassFactory_Constructor is at the moment only
390 for rclsid=CLSID_ShellDesktop, so we get the right Interface (jsch)*/
391 if(lpclf) {
392 hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
393 IClassFactory_Release(lpclf);
397 if (pdesktopfolder) {
398 *shellfolder = pdesktopfolder;
399 pdesktopfolder->lpvtbl->fnAddRef(pdesktopfolder);
400 } else {
401 *shellfolder=NULL;
404 TRACE(shell,"-- %p->(%p)\n",shellfolder, *shellfolder);
405 return hres;
408 /*************************************************************************
409 * SHGetPathFromIDList [SHELL32.221][NT 4.0: SHELL32.219]
411 BOOL WINAPI SHGetPathFromIDListAW(LPCITEMIDLIST pidl,LPSTR pszPath)
412 { TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
413 return SHGetPathFromIDListA(pidl,pszPath);
416 /*************************************************************************
417 * SHGetSpecialFolderLocation [SHELL32.223]
418 * gets the folder locations from the registry and creates a pidl
419 * creates missing reg keys and directorys
421 * PARAMS
422 * hwndOwner [I]
423 * nFolder [I] CSIDL_xxxxx
424 * ppidl [O] PIDL of a special folder
426 * RETURNS
427 * HResult
429 * FIXME
430 * - look for "User Shell Folder" first
433 HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST * ppidl)
434 { LPSHELLFOLDER shellfolder;
435 DWORD pchEaten,tpathlen=MAX_PATH,type,dwdisp,res;
436 CHAR pszTemp[256],buffer[256],tpath[MAX_PATH],npath[MAX_PATH];
437 LPWSTR lpszDisplayName = (LPWSTR)&pszTemp[0];
438 HKEY key;
440 enum
441 { FT_UNKNOWN= 0x00000000,
442 FT_DIR= 0x00000001,
443 FT_DESKTOP= 0x00000002,
444 FT_SPECIAL= 0x00000003
445 } tFolder;
447 TRACE(shell,"(%04x,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
449 strcpy(buffer,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\");
451 res=RegCreateKeyExA(HKEY_CURRENT_USER,buffer,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&key,&dwdisp);
452 if (res)
453 { ERR(shell,"Could not create key %s %08lx \n",buffer,res);
454 return E_OUTOFMEMORY;
457 tFolder=FT_DIR;
458 switch (nFolder)
459 { case CSIDL_BITBUCKET:
460 strcpy (buffer,"xxx"); /*not in the registry*/
461 TRACE (shell,"looking for Recycler\n");
462 tFolder=FT_UNKNOWN;
463 break;
464 case CSIDL_CONTROLS:
465 strcpy (buffer,"xxx"); /*virtual folder*/
466 TRACE (shell,"looking for Control\n");
467 tFolder=FT_UNKNOWN;
468 break;
469 case CSIDL_DESKTOP:
470 strcpy (buffer,"xxx"); /*virtual folder*/
471 TRACE (shell,"looking for Desktop\n");
472 tFolder=FT_DESKTOP;
473 break;
474 case CSIDL_DESKTOPDIRECTORY:
475 case CSIDL_COMMON_DESKTOPDIRECTORY:
476 strcpy (buffer,"Desktop");
477 break;
478 case CSIDL_DRIVES:
479 strcpy (buffer,"xxx"); /*virtual folder*/
480 TRACE (shell,"looking for Drives\n");
481 tFolder=FT_SPECIAL;
482 break;
483 case CSIDL_FONTS:
484 strcpy (buffer,"Fonts");
485 break;
486 case CSIDL_NETHOOD:
487 strcpy (buffer,"NetHood");
488 break;
489 case CSIDL_PRINTHOOD:
490 strcpy (buffer,"PrintHood");
491 break;
492 case CSIDL_NETWORK:
493 strcpy (buffer,"xxx"); /*virtual folder*/
494 TRACE (shell,"looking for Network\n");
495 tFolder=FT_UNKNOWN;
496 break;
497 case CSIDL_APPDATA:
498 strcpy (buffer,"Appdata");
499 break;
500 case CSIDL_PERSONAL:
501 strcpy (buffer,"Personal");
502 break;
503 case CSIDL_FAVORITES:
504 strcpy (buffer,"Favorites");
505 break;
506 case CSIDL_PRINTERS:
507 strcpy (buffer,"PrintHood");
508 break;
509 case CSIDL_COMMON_PROGRAMS:
510 case CSIDL_PROGRAMS:
511 strcpy (buffer,"Programs");
512 break;
513 case CSIDL_RECENT:
514 strcpy (buffer,"Recent");
515 break;
516 case CSIDL_SENDTO:
517 strcpy (buffer,"SendTo");
518 break;
519 case CSIDL_COMMON_STARTMENU:
520 case CSIDL_STARTMENU:
521 strcpy (buffer,"Start Menu");
522 break;
523 case CSIDL_COMMON_STARTUP:
524 case CSIDL_STARTUP:
525 strcpy (buffer,"Startup");
526 break;
527 case CSIDL_TEMPLATES:
528 strcpy (buffer,"Templates");
529 break;
530 default:
531 ERR (shell,"unknown CSIDL 0x%08x\n", nFolder);
532 tFolder=FT_UNKNOWN;
533 break;
536 TRACE(shell,"Key=%s\n",buffer);
538 type=REG_SZ;
540 switch (tFolder)
541 { case FT_DIR:
542 /* Directory: get the value from the registry, if its not there
543 create it and the directory*/
544 if (RegQueryValueExA(key,buffer,NULL,&type,(LPBYTE)tpath,&tpathlen))
545 { GetWindowsDirectoryA(npath,MAX_PATH);
546 PathAddBackslashA(npath);
547 switch (nFolder)
548 { case CSIDL_DESKTOPDIRECTORY:
549 case CSIDL_COMMON_DESKTOPDIRECTORY:
550 strcat (npath,"Desktop");
551 break;
552 case CSIDL_FONTS:
553 strcat (npath,"Fonts");
554 break;
555 case CSIDL_NETHOOD:
556 strcat (npath,"NetHood");
557 break;
558 case CSIDL_PRINTHOOD:
559 strcat (npath,"PrintHood");
560 break;
561 case CSIDL_APPDATA:
562 strcat (npath,"Appdata");
563 break;
564 case CSIDL_PERSONAL:
565 strcpy (npath,"C:\\Personal");
566 break;
567 case CSIDL_FAVORITES:
568 strcat (npath,"Favorites");
569 break;
570 case CSIDL_PRINTERS:
571 strcat (npath,"PrintHood");
572 break;
573 case CSIDL_COMMON_PROGRAMS:
574 case CSIDL_PROGRAMS:
575 strcat (npath,"Start Menu");
576 CreateDirectoryA(npath,NULL);
577 strcat (npath,"\\Programs");
578 break;
579 case CSIDL_RECENT:
580 strcat (npath,"Recent");
581 break;
582 case CSIDL_SENDTO:
583 strcat (npath,"SendTo");
584 break;
585 case CSIDL_COMMON_STARTMENU:
586 case CSIDL_STARTMENU:
587 strcat (npath,"Start Menu");
588 break;
589 case CSIDL_COMMON_STARTUP:
590 case CSIDL_STARTUP:
591 strcat (npath,"Start Menu");
592 CreateDirectoryA(npath,NULL);
593 strcat (npath,"\\Startup");
594 break;
595 case CSIDL_TEMPLATES:
596 strcat (npath,"Templates");
597 break;
598 default:
599 RegCloseKey(key);
600 return E_OUTOFMEMORY;
602 if (RegSetValueExA(key,buffer,0,REG_SZ,(LPBYTE)npath,sizeof(npath)+1))
603 { ERR(shell,"could not create value %s\n",buffer);
604 RegCloseKey(key);
605 return E_OUTOFMEMORY;
607 TRACE(shell,"value %s=%s created\n",buffer,npath);
608 CreateDirectoryA(npath,NULL);
609 strcpy(tpath,npath);
611 break;
612 case FT_DESKTOP:
613 strcpy (tpath,"Desktop");
614 break;
615 case FT_SPECIAL:
616 if (nFolder==CSIDL_DRIVES)
617 strcpy (tpath,"My Computer");
618 break;
619 default:
620 RegCloseKey(key);
621 return E_OUTOFMEMORY;
624 RegCloseKey(key);
626 TRACE(shell,"Value=%s\n",tpath);
627 LocalToWideChar(lpszDisplayName, tpath, 256);
629 if (SHGetDesktopFolder(&shellfolder)==S_OK)
630 { shellfolder->lpvtbl->fnParseDisplayName(shellfolder,hwndOwner, NULL,lpszDisplayName,&pchEaten,ppidl,NULL);
631 shellfolder->lpvtbl->fnRelease(shellfolder);
634 TRACE(shell, "-- (new pidl %p)\n",*ppidl);
635 return NOERROR;
637 /*************************************************************************
638 * SHHelpShortcuts_RunDLL [SHELL32.224]
641 DWORD WINAPI SHHelpShortcuts_RunDLL (DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, DWORD dwArg4)
642 { FIXME (exec, "(%lx, %lx, %lx, %lx) empty stub!\n",
643 dwArg1, dwArg2, dwArg3, dwArg4);
645 return 0;
648 /*************************************************************************
649 * SHLoadInProc [SHELL32.225]
653 DWORD WINAPI SHLoadInProc (DWORD dwArg1)
654 { FIXME (shell, "(%lx) empty stub!\n", dwArg1);
655 return 0;
658 /*************************************************************************
659 * ShellExecute32A (SHELL32.245)
661 HINSTANCE WINAPI ShellExecuteA( HWND hWnd, LPCSTR lpOperation,
662 LPCSTR lpFile, LPCSTR lpParameters,
663 LPCSTR lpDirectory, INT iShowCmd )
664 { TRACE(shell,"\n");
665 return ShellExecute16( hWnd, lpOperation, lpFile, lpParameters,
666 lpDirectory, iShowCmd );
669 /*************************************************************************
670 * ShellExecute32W [SHELL32.294]
671 * from shellapi.h
672 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
673 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
675 HINSTANCE WINAPI
676 ShellExecuteW(
677 HWND hwnd,
678 LPCWSTR lpOperation,
679 LPCWSTR lpFile,
680 LPCWSTR lpParameters,
681 LPCWSTR lpDirectory,
682 INT nShowCmd) {
684 FIXME(shell,": stub\n");
685 return 0;
688 /*************************************************************************
689 * AboutDlgProc32 (not an exported API function)
691 BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
692 LPARAM lParam )
693 { HWND hWndCtl;
694 char Template[512], AppTitle[512];
696 TRACE(shell,"\n");
698 switch(msg)
699 { case WM_INITDIALOG:
700 { ABOUT_INFO *info = (ABOUT_INFO *)lParam;
701 if (info)
702 { const char* const *pstr = SHELL_People;
703 SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
704 GetWindowTextA( hWnd, Template, sizeof(Template) );
705 sprintf( AppTitle, Template, info->szApp );
706 SetWindowTextA( hWnd, AppTitle );
707 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT),
708 info->szOtherStuff );
709 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
710 SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
711 SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
712 while (*pstr)
713 { SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
714 pstr++;
716 SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
719 return 1;
721 case WM_PAINT:
722 { RECT rect;
723 PAINTSTRUCT ps;
724 HDC hDC = BeginPaint( hWnd, &ps );
726 if( __get_dropline( hWnd, &rect ) ) {
727 SelectObject( hDC, GetStockObject( BLACK_PEN ) );
728 MoveToEx( hDC, rect.left, rect.top, NULL );
729 LineTo( hDC, rect.right, rect.bottom );
731 EndPaint( hWnd, &ps );
733 break;
735 case WM_LBTRACKPOINT:
736 hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
737 if( (INT16)GetKeyState16( VK_CONTROL ) < 0 )
738 { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) )
739 { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 );
740 if( idx != -1 )
741 { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 );
742 HGLOBAL16 hMemObj = GlobalAlloc16( GMEM_MOVEABLE, length + 1 );
743 char* pstr = (char*)GlobalLock16( hMemObj );
745 if( pstr )
746 { HCURSOR16 hCursor = LoadCursor16( 0, MAKEINTRESOURCE16(OCR_DRAGOBJECT) );
747 SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
748 SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
749 UpdateWindow( hWndCtl );
750 if( !DragObject16((HWND16)hWnd, (HWND16)hWnd, DRAGOBJ_DATA, 0, (WORD)hMemObj, hCursor) )
751 SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
753 if( hMemObj )
754 GlobalFree16( hMemObj );
758 break;
760 case WM_QUERYDROPOBJECT:
761 if( wParam == 0 )
762 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
763 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
764 { RECT rect;
765 if( __get_dropline( hWnd, &rect ) )
766 { POINT pt;
767 pt.x=lpDragInfo->pt.x;
768 pt.x=lpDragInfo->pt.y;
769 rect.bottom += DROP_FIELD_HEIGHT;
770 if( PtInRect( &rect, pt ) )
771 { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
772 return TRUE;
777 break;
779 case WM_DROPOBJECT:
780 if( wParam == hWnd )
781 { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam);
782 if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
783 { char* pstr = (char*)GlobalLock16( (HGLOBAL16)(lpDragInfo->hList) );
784 if( pstr )
785 { static char __appendix_str[] = " with";
787 hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT );
788 SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
789 if( !lstrncmpA( Template, "WINE", 4 ) )
790 SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
791 else
792 { char* pch = Template + strlen(Template) - strlen(__appendix_str);
793 *pch = '\0';
794 SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
795 (WPARAM)-1, (LPARAM)Template );
798 lstrcpyA( Template, pstr );
799 lstrcatA( Template, __appendix_str );
800 SetWindowTextA( hWndCtl, Template );
801 SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
802 return TRUE;
806 break;
808 case WM_COMMAND:
809 if (wParam == IDOK)
810 { EndDialog(hWnd, TRUE);
811 return TRUE;
813 break;
815 return 0;
819 /*************************************************************************
820 * ShellAbout32A (SHELL32.243)
822 BOOL WINAPI ShellAboutA( HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
823 HICON hIcon )
824 { ABOUT_INFO info;
825 TRACE(shell,"\n");
826 info.szApp = szApp;
827 info.szOtherStuff = szOtherStuff;
828 info.hIcon = hIcon;
829 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
830 return DialogBoxIndirectParamA( WIN_GetWindowInstance( hWnd ),
831 SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
832 hWnd, AboutDlgProc, (LPARAM)&info );
836 /*************************************************************************
837 * ShellAbout32W (SHELL32.244)
839 BOOL WINAPI ShellAboutW( HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
840 HICON hIcon )
841 { BOOL ret;
842 ABOUT_INFO info;
844 TRACE(shell,"\n");
846 info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
847 info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
848 info.hIcon = hIcon;
849 if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE16(OIC_WINEICON) );
850 ret = DialogBoxIndirectParamA( WIN_GetWindowInstance( hWnd ),
851 SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
852 hWnd, AboutDlgProc, (LPARAM)&info );
853 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
854 HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
855 return ret;
858 /*************************************************************************
859 * Shell_NotifyIcon [SHELL32.296]
860 * FIXME
861 * This function is supposed to deal with the systray.
862 * Any ideas on how this is to be implimented?
864 BOOL WINAPI Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATA pnid )
865 { TRACE(shell,"\n");
866 return FALSE;
869 /*************************************************************************
870 * Shell_NotifyIcon [SHELL32.297]
871 * FIXME
872 * This function is supposed to deal with the systray.
873 * Any ideas on how this is to be implimented?
875 BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATA pnid )
876 { TRACE(shell,"\n");
877 return FALSE;
880 /*************************************************************************
881 * FreeIconList
883 void WINAPI FreeIconList( DWORD dw )
884 { FIXME(shell, "(%lx): stub\n",dw);
887 /*************************************************************************
888 * SHGetPathFromIDList32A [SHELL32.261][NT 4.0: SHELL32.220]
890 * PARAMETERS
891 * pidl, [IN] pidl
892 * pszPath [OUT] path
894 * RETURNS
895 * path from a passed PIDL.
897 * NOTES
898 * exported by name
900 * FIXME
901 * fnGetDisplayNameOf can return different types of OLEString
903 DWORD WINAPI SHGetPathFromIDListA (LPCITEMIDLIST pidl,LPSTR pszPath)
904 { STRRET lpName;
905 LPSHELLFOLDER shellfolder;
906 CHAR buffer[MAX_PATH],tpath[MAX_PATH];
907 DWORD type,tpathlen=MAX_PATH,dwdisp;
908 HKEY key;
910 TRACE(shell,"(pidl=%p,%p)\n",pidl,pszPath);
912 if (!pidl)
913 { strcpy(buffer,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\");
915 if (RegCreateKeyExA(HKEY_CURRENT_USER,buffer,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&key,&dwdisp))
916 { return E_OUTOFMEMORY;
918 type=REG_SZ;
919 strcpy (buffer,"Desktop"); /*registry name*/
920 if ( RegQueryValueExA(key,buffer,NULL,&type,(LPBYTE)tpath,&tpathlen))
921 { GetWindowsDirectoryA(tpath,MAX_PATH);
922 PathAddBackslashA(tpath);
923 strcat (tpath,"Desktop"); /*folder name*/
924 RegSetValueExA(key,buffer,0,REG_SZ,(LPBYTE)tpath,tpathlen);
925 CreateDirectoryA(tpath,NULL);
927 RegCloseKey(key);
928 strcpy(pszPath,tpath);
930 else
931 { if (SHGetDesktopFolder(&shellfolder)==S_OK)
932 { shellfolder->lpvtbl->fnGetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&lpName);
933 shellfolder->lpvtbl->fnRelease(shellfolder);
935 /*WideCharToLocal32(pszPath, lpName.u.pOleStr, MAX_PATH);*/
936 strcpy(pszPath,lpName.u.cStr);
937 /* fixme free the olestring*/
939 TRACE(shell,"-- (%s)\n",pszPath);
940 return NOERROR;
942 /*************************************************************************
943 * SHGetPathFromIDList32W [SHELL32.262]
945 DWORD WINAPI SHGetPathFromIDListW (LPCITEMIDLIST pidl,LPWSTR pszPath)
946 { char sTemp[MAX_PATH];
948 TRACE (shell,"(pidl=%p)\n", pidl);
950 SHGetPathFromIDListA (pidl, sTemp);
951 lstrcpyAtoW(pszPath, sTemp);
953 TRACE(shell,"-- (%s)\n",debugstr_w(pszPath));
955 return NOERROR;
958 /*************************************************************************
959 * global variables of the shell32.dll
962 void (WINAPI* pDLLInitComctl)(LPVOID);
963 INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
964 INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
965 HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
966 HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
967 INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
969 LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
970 BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
972 HDPA (WINAPI* pDPA_Create) (INT);
973 INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
974 BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
975 LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
976 BOOL (WINAPI* pDPA_Destroy) (const HDPA);
977 INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
979 /* user32 */
980 HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
981 HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
983 static BOOL bShell32IsInitialized = 0;
984 static HINSTANCE hComctl32;
985 static INT shell32_RefCount = 0;
987 INT shell32_ObjCount = 0;
988 HINSTANCE shell32_hInstance;
989 /*************************************************************************
990 * SHELL32 LibMain
994 BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
995 { HMODULE hUser32;
997 TRACE(shell,"0x%x 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
999 shell32_hInstance = hinstDLL;
1001 switch (fdwReason)
1002 { case DLL_PROCESS_ATTACH:
1003 if (!bShell32IsInitialized)
1004 { hComctl32 = LoadLibraryA("COMCTL32.DLL");
1005 hUser32 = GetModuleHandleA("USER32");
1006 if (hComctl32 && hUser32)
1007 { pDLLInitComctl=(void*)GetProcAddress(hComctl32,"InitCommonControlsEx");
1008 if (pDLLInitComctl)
1009 { pDLLInitComctl(NULL);
1011 pImageList_Create=(void*)GetProcAddress(hComctl32,"ImageList_Create");
1012 pImageList_AddIcon=(void*)GetProcAddress(hComctl32,"ImageList_AddIcon");
1013 pImageList_ReplaceIcon=(void*)GetProcAddress(hComctl32,"ImageList_ReplaceIcon");
1014 pImageList_GetIcon=(void*)GetProcAddress(hComctl32,"ImageList_GetIcon");
1015 pImageList_GetImageCount=(void*)GetProcAddress(hComctl32,"ImageList_GetImageCount");
1017 /* imports by ordinal, pray that it works*/
1018 pCOMCTL32_Alloc=(void*)GetProcAddress(hComctl32, (LPCSTR)71L);
1019 pCOMCTL32_Free=(void*)GetProcAddress(hComctl32, (LPCSTR)73L);
1020 pDPA_Create=(void*)GetProcAddress(hComctl32, (LPCSTR)328L);
1021 pDPA_Destroy=(void*)GetProcAddress(hComctl32, (LPCSTR)329L);
1022 pDPA_GetPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)332L);
1023 pDPA_InsertPtr=(void*)GetProcAddress(hComctl32, (LPCSTR)334L);
1024 pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
1025 pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
1026 /* user32 */
1027 pLookupIconIdFromDirectoryEx=(void*)GetProcAddress(hUser32,"LookupIconIdFromDirectoryEx");
1028 pCreateIconFromResourceEx=(void*)GetProcAddress(hUser32,"CreateIconFromResourceEx");
1030 else
1031 { ERR(shell,"P A N I C SHELL32 loading failed\n");
1032 return FALSE;
1034 SIC_Initialize();
1035 bShell32IsInitialized = TRUE;
1037 shell32_RefCount++;
1038 break;
1040 case DLL_THREAD_ATTACH:
1041 shell32_RefCount++;
1042 break;
1044 case DLL_THREAD_DETACH:
1045 shell32_RefCount--;
1046 break;
1048 case DLL_PROCESS_DETACH:
1049 shell32_RefCount--;
1050 if ( !shell32_RefCount )
1051 { FreeLibrary(hComctl32);
1052 bShell32IsInitialized = FALSE;
1054 if (pdesktopfolder)
1055 { pdesktopfolder->lpvtbl->fnRelease(pdesktopfolder);
1058 /* this one is here ot check if AddRef/Release is balanced */
1059 if (shell32_ObjCount)
1060 { FIXME(shell,"%u objects left\n", shell32_ObjCount);
1063 TRACE(shell, "refcount=%u objcount=%u \n", shell32_RefCount, shell32_ObjCount);
1064 break;
1067 return TRUE;