1 | /* $Id: shell32_main.cpp,v 1.10 2000-03-27 15:09:21 cbratschi Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 SHELL32 for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | * Shell basics
|
---|
10 | *
|
---|
11 | * 1998 Marcus Meissner
|
---|
12 | * 1998 Juergen Schmied (jsch) * <juergen.schmied@metronet.de>
|
---|
13 | *
|
---|
14 | * Corel WINE 20000324 level
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*****************************************************************************
|
---|
18 | * Includes *
|
---|
19 | *****************************************************************************/
|
---|
20 |
|
---|
21 | #include <odin.h>
|
---|
22 | #include <odinwrap.h>
|
---|
23 | #include <os2sel.h>
|
---|
24 |
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 |
|
---|
28 | #define ICOM_CINTERFACE 1
|
---|
29 | #define CINTERFACE 1
|
---|
30 |
|
---|
31 | #include "wine/winuser16.h"
|
---|
32 | #include "winerror.h"
|
---|
33 | #include "heap.h"
|
---|
34 | #include "resource.h"
|
---|
35 | #include "dlgs.h"
|
---|
36 | //#include "ldt.h"
|
---|
37 | #include "sysmetrics.h"
|
---|
38 | #include "debugtools.h"
|
---|
39 | #include "winreg.h"
|
---|
40 | #include "authors.h"
|
---|
41 | #include "winversion.h"
|
---|
42 |
|
---|
43 | #include "shellapi.h"
|
---|
44 | #include "pidl.h"
|
---|
45 |
|
---|
46 | #include "shlobj.h"
|
---|
47 | #include "shell32_main.h"
|
---|
48 | #include "shlguid.h"
|
---|
49 | #include "wine/undocshell.h"
|
---|
50 | #include "shpolicy.h"
|
---|
51 |
|
---|
52 | #include <heapstring.h>
|
---|
53 | #include <misc.h>
|
---|
54 |
|
---|
55 |
|
---|
56 | /*****************************************************************************
|
---|
57 | * Local Variables *
|
---|
58 | *****************************************************************************/
|
---|
59 |
|
---|
60 | ODINDEBUGCHANNEL(SHELL32-MAIN)
|
---|
61 |
|
---|
62 |
|
---|
63 | #define MORE_DEBUG 1
|
---|
64 |
|
---|
65 | BOOL VERSION_OsIsUnicode(VOID)
|
---|
66 | {
|
---|
67 | return FALSE;
|
---|
68 | }
|
---|
69 |
|
---|
70 | /*************************************************************************
|
---|
71 | * CommandLineToArgvW [SHELL32.7]
|
---|
72 | */
|
---|
73 |
|
---|
74 | ODINFUNCTION2(LPWSTR*, CommandLineToArgvW, LPWSTR, cmdline,
|
---|
75 | LPDWORD, numargs)
|
---|
76 | { LPWSTR *argv,s,t;
|
---|
77 | int i;
|
---|
78 |
|
---|
79 | /* to get writeable copy */
|
---|
80 | cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline);
|
---|
81 | s=cmdline;i=0;
|
---|
82 | while (*s)
|
---|
83 | { /* space */
|
---|
84 | if (*s==0x0020)
|
---|
85 | { i++;
|
---|
86 | s++;
|
---|
87 | while (*s && *s==0x0020)
|
---|
88 | s++;
|
---|
89 | continue;
|
---|
90 | }
|
---|
91 | s++;
|
---|
92 | }
|
---|
93 | argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) );
|
---|
94 | s=t=cmdline;
|
---|
95 | i=0;
|
---|
96 | while (*s)
|
---|
97 | { if (*s==0x0020)
|
---|
98 | { *s=0;
|
---|
99 | argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t );
|
---|
100 | *s=0x0020;
|
---|
101 | while (*s && *s==0x0020)
|
---|
102 | s++;
|
---|
103 | if (*s)
|
---|
104 | t=s+1;
|
---|
105 | else
|
---|
106 | t=s;
|
---|
107 | continue;
|
---|
108 | }
|
---|
109 | s++;
|
---|
110 | }
|
---|
111 | if (*t)
|
---|
112 | argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t );
|
---|
113 |
|
---|
114 | HeapFree( GetProcessHeap(), 0, cmdline );
|
---|
115 | argv[i]=NULL;
|
---|
116 | *numargs=i;
|
---|
117 | return argv;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /*************************************************************************
|
---|
121 | * Control_RunDLL [SHELL32.12]
|
---|
122 | *
|
---|
123 | * Wild speculation in the following!
|
---|
124 | *
|
---|
125 | * http://premium.microsoft.com/msdn/library/techart/msdn193.htm
|
---|
126 | */
|
---|
127 |
|
---|
128 | ODINPROCEDURE4(Control_RunDLL,HWND, hwnd,
|
---|
129 | LPCVOID,code,
|
---|
130 | LPCSTR, cmd,
|
---|
131 | DWORD, arg4)
|
---|
132 | {
|
---|
133 | dprintf(("SHELL32:Shell32_Main:Control_RunDLL not implemented.\n"));
|
---|
134 | }
|
---|
135 |
|
---|
136 | /*************************************************************************
|
---|
137 | * SHGetFileInfoA [SHELL32.254]
|
---|
138 | */
|
---|
139 |
|
---|
140 | ODINFUNCTION5(DWORD, SHGetFileInfoA, LPCSTR, path,
|
---|
141 | DWORD, dwFileAttributes,
|
---|
142 | SHFILEINFOA*, psfi,
|
---|
143 | UINT, sizeofpsfi,
|
---|
144 | UINT, flags )
|
---|
145 | {
|
---|
146 | char szLoaction[MAX_PATH];
|
---|
147 | int iIndex;
|
---|
148 | DWORD ret = TRUE, dwAttributes = 0;
|
---|
149 | IShellFolder * psfParent = NULL;
|
---|
150 | IExtractIcon * pei = NULL;
|
---|
151 | LPITEMIDLIST pidlLast = NULL, pidl = NULL;
|
---|
152 | HRESULT hr = S_OK;
|
---|
153 |
|
---|
154 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA (%s,0x%lx,%p,0x%x,0x%x)\n",
|
---|
155 | (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, sizeofpsfi, flags));
|
---|
156 |
|
---|
157 | #ifdef MORE_DEBUG
|
---|
158 | ZeroMemory(psfi, sizeof(SHFILEINFOA));
|
---|
159 | #endif
|
---|
160 | if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
|
---|
161 | return FALSE;
|
---|
162 |
|
---|
163 | /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
|
---|
164 | the pidl functions fail on not existing file names */
|
---|
165 | if (flags & SHGFI_PIDL)
|
---|
166 | {
|
---|
167 | pidl = (LPCITEMIDLIST) path;
|
---|
168 | if (!pidl )
|
---|
169 | {
|
---|
170 | dprintf(("pidl is null!\n"));
|
---|
171 | return FALSE;
|
---|
172 | }
|
---|
173 | }
|
---|
174 | else if (!(flags & SHGFI_USEFILEATTRIBUTES))
|
---|
175 | {
|
---|
176 | hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes);
|
---|
177 | /* note: the attributes in ISF::ParseDisplayName are not implemented */
|
---|
178 | }
|
---|
179 |
|
---|
180 | /* get the parent shellfolder */
|
---|
181 | if (pidl)
|
---|
182 | {
|
---|
183 | hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
|
---|
184 | }
|
---|
185 |
|
---|
186 | /* get the attributes of the child */
|
---|
187 | if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES))
|
---|
188 | {
|
---|
189 | if (!(flags & SHGFI_ATTR_SPECIFIED))
|
---|
190 | {
|
---|
191 | psfi->dwAttributes = 0xffffffff;
|
---|
192 | }
|
---|
193 | IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes));
|
---|
194 | }
|
---|
195 |
|
---|
196 | /* get the displayname */
|
---|
197 | if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME))
|
---|
198 | {
|
---|
199 | if (flags & SHGFI_USEFILEATTRIBUTES)
|
---|
200 | {
|
---|
201 | strcpy (psfi->szDisplayName, PathFindFilenameA(path));
|
---|
202 | }
|
---|
203 | else
|
---|
204 | {
|
---|
205 | STRRET str;
|
---|
206 | hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str);
|
---|
207 | StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast);
|
---|
208 | }
|
---|
209 | }
|
---|
210 |
|
---|
211 | /* get the type name */
|
---|
212 | if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME))
|
---|
213 | {
|
---|
214 | _ILGetFileType(pidlLast, psfi->szTypeName, 80);
|
---|
215 | }
|
---|
216 |
|
---|
217 | /* ### icons ###*/
|
---|
218 | if (flags & SHGFI_LINKOVERLAY)
|
---|
219 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set icon to link, stub\n"));
|
---|
220 |
|
---|
221 | if (flags & SHGFI_OPENICON)
|
---|
222 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set to open icon, stub\n"));
|
---|
223 |
|
---|
224 | if (flags & SHGFI_SELECTED)
|
---|
225 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set icon to selected, stub\n"));
|
---|
226 |
|
---|
227 | if (flags & SHGFI_SHELLICONSIZE)
|
---|
228 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set icon to shell size, stub\n"));
|
---|
229 |
|
---|
230 | /* get the iconlocation */
|
---|
231 | if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION ))
|
---|
232 | {
|
---|
233 | UINT uDummy,uFlags;
|
---|
234 | hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei);
|
---|
235 |
|
---|
236 | if (SUCCEEDED(hr))
|
---|
237 | {
|
---|
238 | hr = IExtractIconA_GetIconLocation(pei, 0, szLoaction, MAX_PATH, &iIndex, &uFlags);
|
---|
239 | /* fixme what to do with the index? */
|
---|
240 |
|
---|
241 | if(uFlags != GIL_NOTFILENAME)
|
---|
242 | strcpy (psfi->szDisplayName, szLoaction);
|
---|
243 | else
|
---|
244 | ret = FALSE;
|
---|
245 |
|
---|
246 | IExtractIconA_Release(pei);
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 | /* get icon index (or load icon)*/
|
---|
251 | if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX)))
|
---|
252 | {
|
---|
253 | if (flags & SHGFI_USEFILEATTRIBUTES)
|
---|
254 | {
|
---|
255 | char sTemp [MAX_PATH];
|
---|
256 | char * szExt;
|
---|
257 | DWORD dwNr=0;
|
---|
258 |
|
---|
259 | lstrcpynA(sTemp, path, MAX_PATH);
|
---|
260 | szExt = (LPSTR) PathFindExtensionA(sTemp);
|
---|
261 | if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE)
|
---|
262 | && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr))
|
---|
263 | {
|
---|
264 | if (!strcmp("%1",sTemp)) /* icon is in the file */
|
---|
265 | {
|
---|
266 | strcpy(sTemp, path);
|
---|
267 | }
|
---|
268 | /* FIXME: if sTemp contains a valid filename, get the icon
|
---|
269 | from there, index is in dwNr
|
---|
270 | */
|
---|
271 | psfi->iIcon = 2;
|
---|
272 | }
|
---|
273 | else /* default icon */
|
---|
274 | {
|
---|
275 | psfi->iIcon = 0;
|
---|
276 | }
|
---|
277 | }
|
---|
278 | else
|
---|
279 | {
|
---|
280 | if (!(PidlToSicIndex(psfParent, pidlLast, (flags && SHGFI_LARGEICON), (PUINT)&(psfi->iIcon))))
|
---|
281 | {
|
---|
282 | ret = FALSE;
|
---|
283 | }
|
---|
284 | }
|
---|
285 | if (ret)
|
---|
286 | {
|
---|
287 | ret = (DWORD) ((flags && SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList);
|
---|
288 | }
|
---|
289 | }
|
---|
290 |
|
---|
291 | /* icon handle */
|
---|
292 | if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
|
---|
293 | psfi->hIcon = pImageList_GetIcon((flags && SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
|
---|
294 |
|
---|
295 |
|
---|
296 | if (flags & SHGFI_EXETYPE)
|
---|
297 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA type of executable, stub\n"));
|
---|
298 |
|
---|
299 | if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
|
---|
300 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA unknown attribute!\n"));
|
---|
301 |
|
---|
302 | if (psfParent)
|
---|
303 | IShellFolder_Release(psfParent);
|
---|
304 |
|
---|
305 | if (hr != S_OK)
|
---|
306 | ret = FALSE;
|
---|
307 |
|
---|
308 | #ifdef MORE_DEBUG
|
---|
309 | TRACE_(shell) ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s\n",
|
---|
310 | psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName);
|
---|
311 | #endif
|
---|
312 | return ret;
|
---|
313 | }
|
---|
314 |
|
---|
315 | /*************************************************************************
|
---|
316 | * SHGetFileInfoW [SHELL32.255]
|
---|
317 | */
|
---|
318 |
|
---|
319 | ODINFUNCTION5(DWORD, SHGetFileInfoW, LPCWSTR, path,
|
---|
320 | DWORD, dwFileAttributes,
|
---|
321 | SHFILEINFOW*, psfi,
|
---|
322 | UINT, sizeofpsfi,
|
---|
323 | UINT, flags)
|
---|
324 | {
|
---|
325 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoW not implemented\n"));
|
---|
326 | return 0;
|
---|
327 | }
|
---|
328 |
|
---|
329 |
|
---|
330 | /*************************************************************************
|
---|
331 | * ExtractIconA [SHELL32.133]
|
---|
332 | */
|
---|
333 |
|
---|
334 | ODINFUNCTION3(HICON, ExtractIconA, HINSTANCE, hInstance,
|
---|
335 | LPCSTR, lpszExeFileName,
|
---|
336 | UINT, nIconIndex )
|
---|
337 | {
|
---|
338 | HGLOBAL handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
|
---|
339 | TRACE_(shell)("\n");
|
---|
340 | if( handle )
|
---|
341 | {
|
---|
342 | HICON* ptr = (HICON*)GlobalLock(handle);
|
---|
343 | HICON hIcon = *ptr;
|
---|
344 |
|
---|
345 | GlobalFree(handle);
|
---|
346 | return hIcon;
|
---|
347 | }
|
---|
348 | return 0;
|
---|
349 | }
|
---|
350 |
|
---|
351 | /*************************************************************************
|
---|
352 | * ExtractIconW [SHELL32.180]
|
---|
353 | */
|
---|
354 |
|
---|
355 | ODINFUNCTION3(HICON, ExtractIconW, HINSTANCE, hInstance,
|
---|
356 | LPCWSTR, lpszExeFileName,
|
---|
357 | UINT, nIconIndex )
|
---|
358 | { LPSTR exefn;
|
---|
359 | HICON ret;
|
---|
360 |
|
---|
361 | exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
|
---|
362 | ret = ExtractIconA(hInstance,exefn,nIconIndex);
|
---|
363 |
|
---|
364 | HeapFree(GetProcessHeap(),0,exefn);
|
---|
365 | return ret;
|
---|
366 | }
|
---|
367 |
|
---|
368 | /*************************************************************************
|
---|
369 | * FindExecutableA [SHELL32.184]
|
---|
370 | */
|
---|
371 |
|
---|
372 | ODINFUNCTION3(HINSTANCE, FindExecutableA, LPCSTR, lpFile,
|
---|
373 | LPCSTR, lpDirectory,
|
---|
374 | LPSTR, lpResult )
|
---|
375 | { HINSTANCE retval=31; /* default - 'No association was found' */
|
---|
376 | char old_dir[1024];
|
---|
377 |
|
---|
378 | dprintf(("File %s, Dir %s\n",
|
---|
379 | (lpFile != NULL?lpFile:"-"),
|
---|
380 | (lpDirectory != NULL?lpDirectory:"-")));
|
---|
381 |
|
---|
382 | lpResult[0]='\0'; /* Start off with an empty return string */
|
---|
383 |
|
---|
384 | /* trap NULL parameters on entry */
|
---|
385 | if (( lpFile == NULL ) || ( lpResult == NULL ))
|
---|
386 | { /* FIXME - should throw a warning, perhaps! */
|
---|
387 | return 2; /* File not found. Close enough, I guess. */
|
---|
388 | }
|
---|
389 |
|
---|
390 | if (lpDirectory)
|
---|
391 | { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
|
---|
392 | SetCurrentDirectoryA( lpDirectory );
|
---|
393 | }
|
---|
394 |
|
---|
395 | retval = SHELL_FindExecutable( lpFile, "open", lpResult );
|
---|
396 |
|
---|
397 | dprintf(("returning %s\n", lpResult));
|
---|
398 | if (lpDirectory)
|
---|
399 | SetCurrentDirectoryA( old_dir );
|
---|
400 | return retval;
|
---|
401 | }
|
---|
402 |
|
---|
403 | /*************************************************************************
|
---|
404 | * FindExecutableW [SHELL32.219]
|
---|
405 | */
|
---|
406 | ODINFUNCTION3(HINSTANCE, FindExecutableW, LPCWSTR, lpFile,
|
---|
407 | LPCWSTR, lpDirectory,
|
---|
408 | LPWSTR, lpResult )
|
---|
409 | {
|
---|
410 | dprintf(("FindExecutableW not implemented.\n"));
|
---|
411 | return 31; /* default - 'No association was found' */
|
---|
412 | }
|
---|
413 |
|
---|
414 | typedef struct
|
---|
415 | { LPCSTR szApp;
|
---|
416 | LPCSTR szOtherStuff;
|
---|
417 | HICON hIcon;
|
---|
418 | } ABOUT_INFO;
|
---|
419 |
|
---|
420 | #define IDC_STATIC_TEXT 100
|
---|
421 | #define IDC_LISTBOX 99
|
---|
422 | #define IDC_ODIN_TEXT 98
|
---|
423 |
|
---|
424 | #define DROP_FIELD_TOP (-15)
|
---|
425 | #define DROP_FIELD_HEIGHT 15
|
---|
426 |
|
---|
427 | #if 0 //CB: not used
|
---|
428 | extern HICON hIconTitleFont;
|
---|
429 | #endif
|
---|
430 |
|
---|
431 | static BOOL __get_dropline( HWND hWnd, LPRECT lprect )
|
---|
432 | { HWND hWndCtl = GetDlgItem(hWnd, IDC_ODIN_TEXT);
|
---|
433 | if( hWndCtl )
|
---|
434 | { GetWindowRect( hWndCtl, lprect );
|
---|
435 | MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 );
|
---|
436 | lprect->bottom = (lprect->top += DROP_FIELD_TOP);
|
---|
437 | return TRUE;
|
---|
438 | }
|
---|
439 | return FALSE;
|
---|
440 | }
|
---|
441 |
|
---|
442 | /*************************************************************************
|
---|
443 | * SHAppBarMessage32 [SHELL32.207]
|
---|
444 | */
|
---|
445 |
|
---|
446 | ODINFUNCTION2(UINT, SHAppBarMessage, DWORD, msg,
|
---|
447 | PAPPBARDATA, data)
|
---|
448 | {
|
---|
449 | int width=data->rc.right - data->rc.left;
|
---|
450 | int height=data->rc.bottom - data->rc.top;
|
---|
451 | RECT rec=data->rc;
|
---|
452 |
|
---|
453 | dprintf(("SHELL32: SHAppBarMessage.\n"));
|
---|
454 |
|
---|
455 | switch (msg)
|
---|
456 | { case ABM_GETSTATE:
|
---|
457 | return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
|
---|
458 | case ABM_GETTASKBARPOS:
|
---|
459 | GetWindowRect(data->hWnd, &rec);
|
---|
460 | data->rc=rec;
|
---|
461 | return TRUE;
|
---|
462 | case ABM_ACTIVATE:
|
---|
463 | SetActiveWindow(data->hWnd);
|
---|
464 | return TRUE;
|
---|
465 | case ABM_GETAUTOHIDEBAR:
|
---|
466 | data->hWnd=GetActiveWindow();
|
---|
467 | return TRUE;
|
---|
468 | case ABM_NEW:
|
---|
469 | SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
|
---|
470 | width,height,SWP_SHOWWINDOW);
|
---|
471 | return TRUE;
|
---|
472 | case ABM_QUERYPOS:
|
---|
473 | GetWindowRect(data->hWnd, &(data->rc));
|
---|
474 | return TRUE;
|
---|
475 | case ABM_REMOVE:
|
---|
476 | CloseHandle(data->hWnd);
|
---|
477 | return TRUE;
|
---|
478 | case ABM_SETAUTOHIDEBAR:
|
---|
479 | SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
|
---|
480 | width,height,SWP_SHOWWINDOW);
|
---|
481 | return TRUE;
|
---|
482 | case ABM_SETPOS:
|
---|
483 | data->uEdge=(ABE_RIGHT | ABE_LEFT);
|
---|
484 | SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
|
---|
485 | width,height,SWP_SHOWWINDOW);
|
---|
486 | return TRUE;
|
---|
487 | case ABM_WINDOWPOSCHANGED:
|
---|
488 | SetWindowPos(data->hWnd,HWND_TOP,rec.left,rec.top,
|
---|
489 | width,height,SWP_SHOWWINDOW);
|
---|
490 | return TRUE;
|
---|
491 | }
|
---|
492 | return FALSE;
|
---|
493 | }
|
---|
494 |
|
---|
495 | /*************************************************************************
|
---|
496 | * SHHelpShortcuts_RunDLL [SHELL32.224]
|
---|
497 | *
|
---|
498 | */
|
---|
499 |
|
---|
500 | ODINFUNCTION4(DWORD, SHHelpShortcuts_RunDLL, DWORD, dwArg1,
|
---|
501 | DWORD, dwArg2,
|
---|
502 | DWORD, dwArg3,
|
---|
503 | DWORD, dwArg4)
|
---|
504 | {
|
---|
505 | dprintf(("SHELL32:Shell32_Main:SHHelpShortcuts_RunDLL not implemented.\n"));
|
---|
506 | return 0;
|
---|
507 | }
|
---|
508 |
|
---|
509 | /*************************************************************************
|
---|
510 | * SHLoadInProc [SHELL32.225]
|
---|
511 | * Create an instance of specified object class from within the shell process
|
---|
512 | */
|
---|
513 |
|
---|
514 | ODINFUNCTION1(DWORD, SHLoadInProc, DWORD, dwArg1)
|
---|
515 | {
|
---|
516 | CLSID *id;
|
---|
517 |
|
---|
518 | dprintf(("SHELL32: SHLoadInProc\n"));
|
---|
519 |
|
---|
520 | CLSIDFromString((LPCOLESTR) dwArg1, id);
|
---|
521 | if (S_OK==SHCoCreateInstance( (LPSTR) dwArg1, id, NULL, &IID_IUnknown, NULL) )
|
---|
522 | return NOERROR;
|
---|
523 | return DISP_E_MEMBERNOTFOUND;
|
---|
524 | }
|
---|
525 |
|
---|
526 |
|
---|
527 |
|
---|
528 | /*************************************************************************
|
---|
529 | * ShellExecuteA [SHELL32.245]
|
---|
530 | */
|
---|
531 |
|
---|
532 | ODINFUNCTION6(HINSTANCE, ShellExecuteA, HWND, hWnd,
|
---|
533 | LPCSTR, lpOperation,
|
---|
534 | LPCSTR, lpFile,
|
---|
535 | LPCSTR, lpParameters,
|
---|
536 | LPCSTR, lpDirectory,
|
---|
537 | INT, iShowCmd )
|
---|
538 | { HINSTANCE retval=31;
|
---|
539 | char old_dir[1024];
|
---|
540 | char cmd[256];
|
---|
541 |
|
---|
542 | if (lpFile==NULL) return 0; /* should not happen */
|
---|
543 | if (lpOperation==NULL) /* default is open */
|
---|
544 | lpOperation="open";
|
---|
545 |
|
---|
546 | if (lpDirectory)
|
---|
547 | { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
|
---|
548 | SetCurrentDirectoryA( lpDirectory );
|
---|
549 | }
|
---|
550 |
|
---|
551 | cmd[0] = '\0';
|
---|
552 | retval = SHELL_FindExecutable( lpFile, lpOperation, cmd );
|
---|
553 |
|
---|
554 | if (retval > 32) /* Found */
|
---|
555 | {
|
---|
556 | if (lpParameters)
|
---|
557 | {
|
---|
558 | strcat(cmd," ");
|
---|
559 | strcat(cmd,lpParameters);
|
---|
560 | }
|
---|
561 |
|
---|
562 | dprintf(("starting %s\n",cmd));
|
---|
563 | retval = WinExec( cmd, iShowCmd );
|
---|
564 | }
|
---|
565 | else if(PathIsURLA((LPSTR)lpFile)) /* File not found, check for URL */
|
---|
566 | {
|
---|
567 | char lpstrProtocol[256];
|
---|
568 | LONG cmdlen = 512;
|
---|
569 | LPSTR lpstrRes;
|
---|
570 | INT iSize;
|
---|
571 |
|
---|
572 | lpstrRes = strchr(lpFile,':');
|
---|
573 | iSize = lpstrRes - lpFile;
|
---|
574 |
|
---|
575 | /* Looking for ...protocol\shell\lpOperation\command */
|
---|
576 | strncpy(lpstrProtocol,lpFile,iSize);
|
---|
577 | lpstrProtocol[iSize]='\0';
|
---|
578 | strcat( lpstrProtocol, "\\shell\\" );
|
---|
579 | strcat( lpstrProtocol, lpOperation );
|
---|
580 | strcat( lpstrProtocol, "\\command" );
|
---|
581 |
|
---|
582 | /* Remove File Protocol from lpFile */
|
---|
583 | /* In the case file://path/file */
|
---|
584 | if(!strnicmp(lpFile,"file",iSize))
|
---|
585 | {
|
---|
586 | lpFile += iSize;
|
---|
587 | while(*lpFile == ':') lpFile++;
|
---|
588 | }
|
---|
589 |
|
---|
590 |
|
---|
591 | /* Get the application for the protocol and execute it */
|
---|
592 | if (RegQueryValueA( HKEY_CLASSES_ROOT, lpstrProtocol, cmd,
|
---|
593 | &cmdlen ) == ERROR_SUCCESS )
|
---|
594 | {
|
---|
595 | LPSTR tok;
|
---|
596 | LPSTR tmp;
|
---|
597 | char param[256] = "";
|
---|
598 | LONG paramlen = 256;
|
---|
599 |
|
---|
600 | /* Get the parameters needed by the application
|
---|
601 | from the associated ddeexec key */
|
---|
602 | tmp = strstr(lpstrProtocol,"command");
|
---|
603 | tmp[0] = '\0';
|
---|
604 | strcat(lpstrProtocol,"ddeexec");
|
---|
605 |
|
---|
606 | if(RegQueryValueA( HKEY_CLASSES_ROOT, lpstrProtocol, param,¶mlen ) == ERROR_SUCCESS)
|
---|
607 | {
|
---|
608 | strcat(cmd," ");
|
---|
609 | strcat(cmd,param);
|
---|
610 | cmdlen += paramlen;
|
---|
611 | }
|
---|
612 |
|
---|
613 | /* Is there a replace() function anywhere? */
|
---|
614 | cmd[cmdlen]='\0';
|
---|
615 | tok=strstr( cmd, "%1" );
|
---|
616 | if (tok != NULL)
|
---|
617 | {
|
---|
618 | tok[0]='\0'; /* truncate string at the percent */
|
---|
619 | strcat( cmd, lpFile ); /* what if no dir in xlpFile? */
|
---|
620 | tok=strstr( cmd, "%1" );
|
---|
621 | if ((tok!=NULL) && (strlen(tok)>2))
|
---|
622 | {
|
---|
623 | strcat( cmd, &tok[2] );
|
---|
624 | }
|
---|
625 | }
|
---|
626 |
|
---|
627 | retval = WinExec( cmd, iShowCmd );
|
---|
628 | }
|
---|
629 | }
|
---|
630 | /* Check if file specified is in the form www.??????.*** */
|
---|
631 | else if(!strnicmp(lpFile,"www",3))
|
---|
632 | {
|
---|
633 | /* if so, append lpFile http:// and call ShellExecute */
|
---|
634 | char lpstrTmpFile[256] = "http://" ;
|
---|
635 | strcat(lpstrTmpFile,lpFile);
|
---|
636 | retval = ShellExecuteA(hWnd,lpOperation,lpstrTmpFile,NULL,NULL,0);
|
---|
637 | }
|
---|
638 | /* Nothing was done yet, try to execute the cmdline directly,
|
---|
639 | maybe it's an OS/2 program */
|
---|
640 | else
|
---|
641 | {
|
---|
642 | strcpy(cmd,lpFile);
|
---|
643 | strcat(cmd,lpParameters ? lpParameters : "");
|
---|
644 | retval = WinExec( cmd, iShowCmd );
|
---|
645 | }
|
---|
646 |
|
---|
647 | if (lpDirectory)
|
---|
648 | SetCurrentDirectoryA( old_dir );
|
---|
649 | return retval;
|
---|
650 | }
|
---|
651 |
|
---|
652 |
|
---|
653 | /*************************************************************************
|
---|
654 | * ShellExecuteW [SHELL32.294]
|
---|
655 | * from shellapi.h
|
---|
656 | * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
|
---|
657 | * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
|
---|
658 | */
|
---|
659 |
|
---|
660 | ODINFUNCTION6(HINSTANCE, ShellExecuteW, HWND, hWnd,
|
---|
661 | LPCWSTR, lpOperation,
|
---|
662 | LPCWSTR, lpFile,
|
---|
663 | LPCWSTR, lpParameters,
|
---|
664 | LPCWSTR, lpDirectory,
|
---|
665 | INT, iShowCmd )
|
---|
666 | {
|
---|
667 | dprintf(("SHELL32:Shell32_Main:ShellExecuteW not implemented\n"));
|
---|
668 | return 0;
|
---|
669 | }
|
---|
670 |
|
---|
671 |
|
---|
672 | /*************************************************************************
|
---|
673 | * AboutDlgProc32 (internal)
|
---|
674 | */
|
---|
675 | #define IDC_ODINLOGO 2001
|
---|
676 | #define IDB_ODINLOGO 5555
|
---|
677 |
|
---|
678 | BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
|
---|
679 | LPARAM lParam )
|
---|
680 | {
|
---|
681 | HWND hWndCtl;
|
---|
682 | char Template[512], AppTitle[512];
|
---|
683 |
|
---|
684 | switch(msg)
|
---|
685 | {
|
---|
686 | case WM_INITDIALOG:
|
---|
687 | {
|
---|
688 | ABOUT_INFO *info = (ABOUT_INFO *)lParam;
|
---|
689 | if(info)
|
---|
690 | {
|
---|
691 | const char* const *pstr = SHELL_People;
|
---|
692 |
|
---|
693 | SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0);
|
---|
694 | GetWindowTextA( hWnd, Template, sizeof(Template) );
|
---|
695 | sprintf( AppTitle, Template, info->szApp );
|
---|
696 | SetWindowTextA( hWnd, AppTitle );
|
---|
697 | SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), info->szOtherStuff );
|
---|
698 |
|
---|
699 | HWND hwndOdinLogo = GetDlgItem(hWnd, IDC_ODINLOGO);
|
---|
700 | if(hwndOdinLogo) {
|
---|
701 | HBITMAP hBitmap = LoadBitmapA(shell32_hInstance, MAKEINTRESOURCEA(IDB_ODINLOGO));
|
---|
702 | SendMessageA(hwndOdinLogo, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
|
---|
703 | }
|
---|
704 |
|
---|
705 | hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
|
---|
706 | SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 );
|
---|
707 | #if 0 //CB: not used (hIconTitleFont not valid!!!), default font is ok
|
---|
708 | SendMessageA( hWndCtl, WM_SETFONT, hIconTitleFont, 0 );
|
---|
709 | #endif
|
---|
710 | while (*pstr)
|
---|
711 | {
|
---|
712 | SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr );
|
---|
713 | pstr++;
|
---|
714 | }
|
---|
715 | SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 );
|
---|
716 | }
|
---|
717 | return 1;
|
---|
718 | }
|
---|
719 |
|
---|
720 | case WM_PAINT:
|
---|
721 | {
|
---|
722 | RECT rect;
|
---|
723 | PAINTSTRUCT ps;
|
---|
724 | HDC hDC = BeginPaint( hWnd, &ps );
|
---|
725 |
|
---|
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 );
|
---|
730 | }
|
---|
731 | EndPaint( hWnd, &ps );
|
---|
732 | break;
|
---|
733 | }
|
---|
734 |
|
---|
735 | case WM_LBTRACKPOINT:
|
---|
736 | hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX);
|
---|
737 | if( (INT)GetKeyState( 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 | HGLOBAL hMemObj = GlobalAlloc( GMEM_MOVEABLE, length + 1 );
|
---|
743 | char* pstr = (char*)GlobalLock( hMemObj );
|
---|
744 |
|
---|
745 | if( pstr )
|
---|
746 | { HCURSOR hCursor = LoadCursorA( 0, (LPCSTR)OCR_DRAGOBJECT );
|
---|
747 | SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr );
|
---|
748 | SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 );
|
---|
749 | UpdateWindow( hWndCtl );
|
---|
750 |
|
---|
751 | if( !DragObject(hWnd, hWnd, DRAGOBJ_DATA, hMemObj, hCursor) )
|
---|
752 | SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr );
|
---|
753 | }
|
---|
754 | if( hMemObj )
|
---|
755 | GlobalFree( hMemObj );
|
---|
756 | }
|
---|
757 | }
|
---|
758 | }
|
---|
759 | break;
|
---|
760 |
|
---|
761 | case WM_QUERYDROPOBJECT:
|
---|
762 | if( wParam == 0 )
|
---|
763 | { LPDRAGINFO lpDragInfo = (LPDRAGINFO)lParam;
|
---|
764 | if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA )
|
---|
765 | { RECT rect;
|
---|
766 | if( __get_dropline( hWnd, &rect ) )
|
---|
767 | { POINT pt;
|
---|
768 | pt.x=lpDragInfo->pt.x;
|
---|
769 | pt.x=lpDragInfo->pt.y;
|
---|
770 | rect.bottom += DROP_FIELD_HEIGHT;
|
---|
771 | if( PtInRect( &rect, pt ) )
|
---|
772 | { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
|
---|
773 | return TRUE;
|
---|
774 | }
|
---|
775 | }
|
---|
776 | }
|
---|
777 | }
|
---|
778 | break;
|
---|
779 |
|
---|
780 | case WM_DROPOBJECT:
|
---|
781 | if( wParam == hWnd )
|
---|
782 | { LPDRAGINFO lpDragInfo = (LPDRAGINFO)lParam;
|
---|
783 | if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList )
|
---|
784 | { char* pstr = (char*)GlobalLock( (HGLOBAL)(lpDragInfo->hList) );
|
---|
785 | if( pstr )
|
---|
786 | { static char __appendix_str[] = " with";
|
---|
787 |
|
---|
788 | hWndCtl = GetDlgItem( hWnd, IDC_ODIN_TEXT );
|
---|
789 | SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template );
|
---|
790 | if( !strncmp( Template, "ODIN", 4 ) )
|
---|
791 | SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template );
|
---|
792 | else
|
---|
793 | { char* pch = Template + strlen(Template) - strlen(__appendix_str);
|
---|
794 | *pch = '\0';
|
---|
795 | SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING,
|
---|
796 | (WPARAM)-1, (LPARAM)Template );
|
---|
797 | }
|
---|
798 |
|
---|
799 | strcpy( Template, pstr );
|
---|
800 | strcat( Template, __appendix_str );
|
---|
801 | SetWindowTextA( hWndCtl, Template );
|
---|
802 | SetWindowLongA( hWnd, DWL_MSGRESULT, 1 );
|
---|
803 | return TRUE;
|
---|
804 | }
|
---|
805 | }
|
---|
806 | }
|
---|
807 | break;
|
---|
808 |
|
---|
809 | case WM_COMMAND:
|
---|
810 | if (wParam == IDOK)
|
---|
811 | {
|
---|
812 | EndDialog(hWnd, TRUE);
|
---|
813 | return TRUE;
|
---|
814 | }
|
---|
815 | break;
|
---|
816 |
|
---|
817 | case WM_CLOSE:
|
---|
818 | EndDialog(hWnd, TRUE);
|
---|
819 | break;
|
---|
820 | }
|
---|
821 | return 0;
|
---|
822 | }
|
---|
823 |
|
---|
824 |
|
---|
825 | /*************************************************************************
|
---|
826 | * ShellAboutA [SHELL32.243]
|
---|
827 | */
|
---|
828 |
|
---|
829 | ODINFUNCTION4(INT,ShellAboutA, HWND, hWnd,
|
---|
830 | LPCSTR, szApp,
|
---|
831 | LPCSTR, szOtherStuff,
|
---|
832 | HICON, hIcon )
|
---|
833 | { ABOUT_INFO info;
|
---|
834 | HRSRC hRes;
|
---|
835 | LPVOID dlgTemplate;
|
---|
836 |
|
---|
837 | if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
|
---|
838 | return FALSE;
|
---|
839 | if(!(dlgTemplate = (LPVOID)LoadResource(shell32_hInstance, hRes)))
|
---|
840 | return FALSE;
|
---|
841 |
|
---|
842 | info.szApp = szApp;
|
---|
843 | info.szOtherStuff = szOtherStuff;
|
---|
844 | info.hIcon = hIcon;
|
---|
845 | if (!hIcon) info.hIcon = LoadIconA( 0, MAKEINTRESOURCEA(OIC_ODINICON) );
|
---|
846 | return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
|
---|
847 | (DLGTEMPLATE*)dlgTemplate , hWnd, AboutDlgProc, (LPARAM)&info );
|
---|
848 | }
|
---|
849 |
|
---|
850 |
|
---|
851 | /*************************************************************************
|
---|
852 | * ShellAboutW [SHELL32.244]
|
---|
853 | */
|
---|
854 | ODINFUNCTION4(INT,ShellAboutW, HWND, hWnd,
|
---|
855 | LPCWSTR, szApp,
|
---|
856 | LPCWSTR, szOtherStuff,
|
---|
857 | HICON, hIcon )
|
---|
858 | { INT ret;
|
---|
859 | ABOUT_INFO info;
|
---|
860 | HRSRC hRes;
|
---|
861 | LPVOID dlgTemplate;
|
---|
862 |
|
---|
863 | if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA)))
|
---|
864 | return FALSE;
|
---|
865 | if(!(dlgTemplate = (LPVOID)LoadResource(shell32_hInstance, hRes)))
|
---|
866 | return FALSE;
|
---|
867 |
|
---|
868 | info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
|
---|
869 | info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
|
---|
870 | info.hIcon = hIcon;
|
---|
871 | if (!hIcon) info.hIcon = LoadIconA( 0, MAKEINTRESOURCEA(OIC_ODINICON) );
|
---|
872 | ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
|
---|
873 | (DLGTEMPLATE*)dlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info );
|
---|
874 | HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
|
---|
875 | HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
|
---|
876 | return ret;
|
---|
877 | }
|
---|
878 |
|
---|
879 | /*************************************************************************
|
---|
880 | * FreeIconList
|
---|
881 | */
|
---|
882 |
|
---|
883 | ODINPROCEDURE1(FreeIconList,DWORD,dw)
|
---|
884 | {
|
---|
885 | dprintf(("SHELL32:Shell32_Main:FreeIconList not implemented.\n"));
|
---|
886 | }
|
---|
887 |
|
---|
888 | /***********************************************************************
|
---|
889 | * DllGetVersion [COMCTL32.25]
|
---|
890 | *
|
---|
891 | * Retrieves version information of the 'SHELL32.DLL'
|
---|
892 | *
|
---|
893 | * PARAMS
|
---|
894 | * pdvi [O] pointer to version information structure.
|
---|
895 | *
|
---|
896 | * RETURNS
|
---|
897 | * Success: S_OK
|
---|
898 | * Failure: E_INVALIDARG
|
---|
899 | *
|
---|
900 | * NOTES
|
---|
901 | * Returns version of a shell32.dll from IE4.01 SP1.
|
---|
902 | */
|
---|
903 |
|
---|
904 | ODINFUNCTION1(HRESULT, SHELL32_DllGetVersion, DLLVERSIONINFO*, pdvi)
|
---|
905 | {
|
---|
906 | if (pdvi->cbSize != sizeof(DLLVERSIONINFO))
|
---|
907 | { dprintf(("wrong DLLVERSIONINFO size from app\n"));
|
---|
908 | return E_INVALIDARG;
|
---|
909 | }
|
---|
910 |
|
---|
911 | pdvi->dwMajorVersion = 4;
|
---|
912 | pdvi->dwMinorVersion = 72;
|
---|
913 | pdvi->dwBuildNumber = 3110;
|
---|
914 | pdvi->dwPlatformID = 1;
|
---|
915 |
|
---|
916 | dprintf(("%lu.%lu.%lu.%lu\n",
|
---|
917 | pdvi->dwMajorVersion, pdvi->dwMinorVersion,
|
---|
918 | pdvi->dwBuildNumber, pdvi->dwPlatformID));
|
---|
919 |
|
---|
920 | return S_OK;
|
---|
921 | }
|
---|
922 | /*************************************************************************
|
---|
923 | * global variables of the shell32.dll
|
---|
924 | * all are once per process
|
---|
925 | *
|
---|
926 | */
|
---|
927 | void (WINAPI* pDLLInitComctl)(LPVOID);
|
---|
928 | INT (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon);
|
---|
929 | INT (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON);
|
---|
930 | HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT);
|
---|
931 | BOOL (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle);
|
---|
932 | HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT);
|
---|
933 | INT (WINAPI* pImageList_GetImageCount)(HIMAGELIST);
|
---|
934 | COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF);
|
---|
935 |
|
---|
936 | LPVOID (WINAPI* pCOMCTL32_Alloc) (INT);
|
---|
937 | BOOL (WINAPI* pCOMCTL32_Free) (LPVOID);
|
---|
938 |
|
---|
939 | HDPA (WINAPI* pDPA_Create) (INT);
|
---|
940 | INT (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID);
|
---|
941 | BOOL (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM);
|
---|
942 | LPVOID (WINAPI* pDPA_GetPtr) (const HDPA, INT);
|
---|
943 | BOOL (WINAPI* pDPA_Destroy) (const HDPA);
|
---|
944 | INT (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
|
---|
945 | LPVOID (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i);
|
---|
946 |
|
---|
947 | /* user32 */
|
---|
948 | HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag);
|
---|
949 | HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag);
|
---|
950 |
|
---|
951 | /* ole2 */
|
---|
952 | HRESULT (WINAPI* pOleInitialize)(LPVOID reserved);
|
---|
953 | void (WINAPI* pOleUninitialize)(void);
|
---|
954 | HRESULT (WINAPI* pDoDragDrop)(IDataObject* pDataObject, IDropSource * pDropSource, DWORD dwOKEffect, DWORD *pdwEffect);
|
---|
955 | HRESULT (WINAPI* pRegisterDragDrop)(HWND hwnd, IDropTarget* pDropTarget);
|
---|
956 | HRESULT (WINAPI* pRevokeDragDrop)(HWND hwnd);
|
---|
957 |
|
---|
958 | static HINSTANCE hComctl32;
|
---|
959 | static HINSTANCE hOle32;
|
---|
960 | static INT shell32_RefCount = 0;
|
---|
961 |
|
---|
962 | INT shell32_ObjCount = 0;
|
---|
963 | HINSTANCE shell32_hInstance = 0;
|
---|
964 | HIMAGELIST ShellSmallIconList = 0;
|
---|
965 | HIMAGELIST ShellBigIconList = 0;
|
---|
966 |
|
---|
967 | /*************************************************************************
|
---|
968 | * SHELL32 LibMain
|
---|
969 | *
|
---|
970 | * NOTES
|
---|
971 | * calling oleinitialize here breaks sone apps.
|
---|
972 | */
|
---|
973 |
|
---|
974 | static void Shell32ProcLoadHelper(LPVOID* pAddr,
|
---|
975 | HANDLE hModule,
|
---|
976 | LPCSTR lpstrName)
|
---|
977 | {
|
---|
978 | *pAddr = (void*)GetProcAddress(hModule,lpstrName);
|
---|
979 |
|
---|
980 | if (!pAddr)
|
---|
981 | dprintf(("Shell32: Shell32ProcLoadHelper(%08xh,%08xh,%s) failed!\n",
|
---|
982 | pAddr,
|
---|
983 | hModule,
|
---|
984 | lpstrName));
|
---|
985 | }
|
---|
986 |
|
---|
987 |
|
---|
988 | ODINFUNCTION3(BOOL, Shell32LibMain, HINSTANCE, hinstDLL,
|
---|
989 | DWORD, fdwReason,
|
---|
990 | LPVOID, fImpLoad)
|
---|
991 | {
|
---|
992 | HMODULE hUser32;
|
---|
993 |
|
---|
994 | switch (fdwReason)
|
---|
995 | {
|
---|
996 | case DLL_PROCESS_ATTACH:
|
---|
997 | shell32_RefCount++;
|
---|
998 | if (shell32_hInstance)
|
---|
999 | {
|
---|
1000 | dprintf(("shell32.dll instantiated twice in one address space!\n"));
|
---|
1001 | }
|
---|
1002 | else
|
---|
1003 | {
|
---|
1004 | /* we only want to call this the first time shell32 is instantiated */
|
---|
1005 | SHInitRestricted(NULL, NULL);
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | shell32_hInstance = hinstDLL;
|
---|
1009 |
|
---|
1010 | hComctl32 = LoadLibraryA("COMCTL32.DLL");
|
---|
1011 | hOle32 = LoadLibraryA("OLE32.DLL");
|
---|
1012 | hUser32 = GetModuleHandleA("USER32");
|
---|
1013 |
|
---|
1014 | if (!hComctl32 || !hUser32 || !hOle32)
|
---|
1015 | {
|
---|
1016 | dprintf(("P A N I C SHELL32 loading failed\n"));
|
---|
1017 | return FALSE;
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | /* comctl32 */
|
---|
1021 | Shell32ProcLoadHelper((LPVOID*)&pDLLInitComctl,hComctl32,"InitCommonControlsEx");
|
---|
1022 | Shell32ProcLoadHelper((LPVOID*)&pImageList_Create,hComctl32,"ImageList_Create");
|
---|
1023 | Shell32ProcLoadHelper((LPVOID*)&pImageList_AddIcon,hComctl32,"ImageList_AddIcon");
|
---|
1024 | Shell32ProcLoadHelper((LPVOID*)&pImageList_ReplaceIcon,hComctl32,"ImageList_ReplaceIcon");
|
---|
1025 | Shell32ProcLoadHelper((LPVOID*)&pImageList_GetIcon,hComctl32,"ImageList_GetIcon");
|
---|
1026 | Shell32ProcLoadHelper((LPVOID*)&pImageList_GetImageCount,hComctl32,"ImageList_GetImageCount");
|
---|
1027 | Shell32ProcLoadHelper((LPVOID*)&pImageList_Draw,hComctl32,"ImageList_Draw");
|
---|
1028 | Shell32ProcLoadHelper((LPVOID*)&pImageList_SetBkColor,hComctl32,"ImageList_SetBkColor");
|
---|
1029 | Shell32ProcLoadHelper((LPVOID*)&pCOMCTL32_Alloc,hComctl32, (LPCSTR)71L);
|
---|
1030 | Shell32ProcLoadHelper((LPVOID*)&pCOMCTL32_Free,hComctl32, (LPCSTR)73L);
|
---|
1031 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Create,hComctl32, (LPCSTR)328L);
|
---|
1032 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Destroy,hComctl32, (LPCSTR)329L);
|
---|
1033 | Shell32ProcLoadHelper((LPVOID*)&pDPA_GetPtr,hComctl32, (LPCSTR)332L);
|
---|
1034 | Shell32ProcLoadHelper((LPVOID*)&pDPA_InsertPtr,hComctl32, (LPCSTR)334L);
|
---|
1035 | Shell32ProcLoadHelper((LPVOID*)&pDPA_DeletePtr,hComctl32, (LPCSTR)336L);
|
---|
1036 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Sort,hComctl32, (LPCSTR)338L);
|
---|
1037 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Search,hComctl32, (LPCSTR)339L);
|
---|
1038 | /* user32 */
|
---|
1039 | Shell32ProcLoadHelper((LPVOID*)&pLookupIconIdFromDirectoryEx,hUser32,"LookupIconIdFromDirectoryEx");
|
---|
1040 | Shell32ProcLoadHelper((LPVOID*)&pCreateIconFromResourceEx,hUser32,"CreateIconFromResourceEx");
|
---|
1041 | /* ole2 */
|
---|
1042 | Shell32ProcLoadHelper((LPVOID*)&pOleInitialize,hOle32,"OleInitialize");
|
---|
1043 | Shell32ProcLoadHelper((LPVOID*)&pOleUninitialize,hOle32,"OleUninitialize");
|
---|
1044 | Shell32ProcLoadHelper((LPVOID*)&pDoDragDrop,hOle32,"DoDragDrop");
|
---|
1045 | Shell32ProcLoadHelper((LPVOID*)&pRegisterDragDrop,hOle32,"RegisterDragDrop");
|
---|
1046 | Shell32ProcLoadHelper((LPVOID*)&pRevokeDragDrop,hOle32,"RevokeDragDrop");
|
---|
1047 |
|
---|
1048 | /* initialize the common controls */
|
---|
1049 | if (pDLLInitComctl)
|
---|
1050 | {
|
---|
1051 | pDLLInitComctl(NULL);
|
---|
1052 | }
|
---|
1053 |
|
---|
1054 | SIC_Initialize();
|
---|
1055 | SYSTRAY_Init();
|
---|
1056 |
|
---|
1057 | break;
|
---|
1058 |
|
---|
1059 | case DLL_THREAD_ATTACH:
|
---|
1060 | shell32_RefCount++;
|
---|
1061 | break;
|
---|
1062 |
|
---|
1063 | case DLL_THREAD_DETACH:
|
---|
1064 | shell32_RefCount--;
|
---|
1065 | break;
|
---|
1066 |
|
---|
1067 | case DLL_PROCESS_DETACH:
|
---|
1068 | shell32_RefCount--;
|
---|
1069 |
|
---|
1070 | if ( !shell32_RefCount )
|
---|
1071 | {
|
---|
1072 | shell32_hInstance = 0;
|
---|
1073 |
|
---|
1074 | if (pdesktopfolder)
|
---|
1075 | {
|
---|
1076 | IShellFolder_Release(pdesktopfolder);
|
---|
1077 | pdesktopfolder = NULL;
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | SIC_Destroy();
|
---|
1081 |
|
---|
1082 | /* this one is here to check if AddRef/Release is balanced */
|
---|
1083 | if (shell32_ObjCount)
|
---|
1084 | {
|
---|
1085 | dprintf(("leaving with %u objects left (memory leak)\n", shell32_ObjCount));
|
---|
1086 | }
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 | FreeLibrary(hOle32);
|
---|
1090 | FreeLibrary(hComctl32);
|
---|
1091 |
|
---|
1092 | dprintf(("refcount=%u objcount=%u \n", shell32_RefCount, shell32_ObjCount));
|
---|
1093 | break;
|
---|
1094 | }
|
---|
1095 | return TRUE;
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | /*************************************************************************
|
---|
1099 | * DllInstall [SHELL32.202]
|
---|
1100 | *
|
---|
1101 | * PARAMETERS
|
---|
1102 | *
|
---|
1103 | * BOOL bInstall - TRUE for install, FALSE for uninstall
|
---|
1104 | * LPCWSTR pszCmdLine - command line (unused by shell32?)
|
---|
1105 | */
|
---|
1106 |
|
---|
1107 | HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
|
---|
1108 | {
|
---|
1109 | FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
|
---|
1110 |
|
---|
1111 | return S_OK; /* indicate success */
|
---|
1112 | }
|
---|
1113 |
|
---|