Use shell icon cache instead of an own IExtractIcon implementation.
[wine] / dlls / user / misc.c
1 /*
2  * Misc USER functions
3  *
4  * Copyright 1995 Thomas Sandford
5  * Copyright 1997 Marcus Meissner
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "wine/windef16.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winnls.h"
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(win);
34
35 /* USER signal proc flags and codes */
36 /* See UserSignalProc for comments */
37 #define USIG_FLAGS_WIN32          0x0001
38 #define USIG_FLAGS_GUI            0x0002
39 #define USIG_FLAGS_FEEDBACK       0x0004
40 #define USIG_FLAGS_FAULT          0x0008
41
42 #define USIG_DLL_UNLOAD_WIN16     0x0001
43 #define USIG_DLL_UNLOAD_WIN32     0x0002
44 #define USIG_FAULT_DIALOG_PUSH    0x0003
45 #define USIG_FAULT_DIALOG_POP     0x0004
46 #define USIG_DLL_UNLOAD_ORPHANS   0x0005
47 #define USIG_THREAD_INIT          0x0010
48 #define USIG_THREAD_EXIT          0x0020
49 #define USIG_PROCESS_CREATE       0x0100
50 #define USIG_PROCESS_INIT         0x0200
51 #define USIG_PROCESS_EXIT         0x0300
52 #define USIG_PROCESS_DESTROY      0x0400
53 #define USIG_PROCESS_RUNNING      0x0500
54 #define USIG_PROCESS_LOADED       0x0600
55
56
57 /***********************************************************************
58  *              SignalProc32 (USER.391)
59  *              UserSignalProc (USER32.@)
60  *
61  * The exact meaning of the USER signals is undocumented, but this
62  * should cover the basic idea:
63  *
64  * USIG_DLL_UNLOAD_WIN16
65  *     This is sent when a 16-bit module is unloaded.
66  *
67  * USIG_DLL_UNLOAD_WIN32
68  *     This is sent when a 32-bit module is unloaded.
69  *
70  * USIG_DLL_UNLOAD_ORPHANS
71  *     This is sent after the last Win3.1 module is unloaded,
72  *     to allow removal of orphaned menus.
73  *
74  * USIG_FAULT_DIALOG_PUSH
75  * USIG_FAULT_DIALOG_POP
76  *     These are called to allow USER to prepare for displaying a
77  *     fault dialog, even though the fault might have happened while
78  *     inside a USER critical section.
79  *
80  * USIG_THREAD_INIT
81  *     This is called from the context of a new thread, as soon as it
82  *     has started to run.
83  *
84  * USIG_THREAD_EXIT
85  *     This is called, still in its context, just before a thread is
86  *     about to terminate.
87  *
88  * USIG_PROCESS_CREATE
89  *     This is called, in the parent process context, after a new process
90  *     has been created.
91  *
92  * USIG_PROCESS_INIT
93  *     This is called in the new process context, just after the main thread
94  *     has started execution (after the main thread's USIG_THREAD_INIT has
95  *     been sent).
96  *
97  * USIG_PROCESS_LOADED
98  *     This is called after the executable file has been loaded into the
99  *     new process context.
100  *
101  * USIG_PROCESS_RUNNING
102  *     This is called immediately before the main entry point is called.
103  *
104  * USIG_PROCESS_EXIT
105  *     This is called in the context of a process that is about to
106  *     terminate (but before the last thread's USIG_THREAD_EXIT has
107  *     been sent).
108  *
109  * USIG_PROCESS_DESTROY
110  *     This is called after a process has terminated.
111  *
112  *
113  * The meaning of the dwFlags bits is as follows:
114  *
115  * USIG_FLAGS_WIN32
116  *     Current process is 32-bit.
117  *
118  * USIG_FLAGS_GUI
119  *     Current process is a (Win32) GUI process.
120  *
121  * USIG_FLAGS_FEEDBACK
122  *     Current process needs 'feedback' (determined from the STARTUPINFO
123  *     flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
124  *
125  * USIG_FLAGS_FAULT
126  *     The signal is being sent due to a fault.
127  */
128 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
129                             DWORD dwFlags, HMODULE16 hModule )
130 {
131     FIXME("(%04x, %08lx, %04lx, %04x)\n",
132           uCode, dwThreadOrProcessID, dwFlags, hModule );
133     /* FIXME: Should chain to GdiSignalProc now. */
134     return 0;
135 }
136
137
138 /**********************************************************************
139  * SetLastErrorEx [USER32.@]
140  *
141  * Sets the last-error code.
142  *
143  * RETURNS
144  *    None.
145  */
146 void WINAPI SetLastErrorEx(
147     DWORD error, /* [in] Per-thread error code */
148     DWORD type)  /* [in] Error type */
149 {
150     TRACE("(0x%08lx, 0x%08lx)\n", error,type);
151     switch(type) {
152         case 0:
153             break;
154         case SLE_ERROR:
155         case SLE_MINORERROR:
156         case SLE_WARNING:
157             /* Fall through for now */
158         default:
159             FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error,type);
160             break;
161     }
162     SetLastError( error );
163 }
164
165 /******************************************************************************
166  * GetAltTabInfoA [USER32.@]
167  */
168 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
169 {
170     FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
171     return FALSE;
172 }
173
174 /******************************************************************************
175  * GetAltTabInfoW [USER32.@]
176  */
177 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
178 {
179     FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
180     return FALSE;
181 }
182
183 /******************************************************************************
184  * SetDebugErrorLevel [USER32.@]
185  * Sets the minimum error level for generating debugging events
186  *
187  * PARAMS
188  *    dwLevel [I] Debugging error level
189  */
190 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
191 {
192     FIXME("(%ld): stub\n", dwLevel);
193 }
194
195
196 /******************************************************************************
197  *                    GetProcessDefaultLayout [USER32.@]
198  *
199  * Gets the default layout for parentless windows.
200  * Right now, just returns 0 (left-to-right).
201  *
202  * RETURNS
203  *    Success: Nonzero
204  *    Failure: Zero
205  *
206  * BUGS
207  *    No RTL
208  */
209 BOOL WINAPI GetProcessDefaultLayout( DWORD *pdwDefaultLayout )
210 {
211     if ( !pdwDefaultLayout ) {
212         SetLastError( ERROR_INVALID_PARAMETER );
213         return FALSE;
214      }
215     FIXME( "( %p ): No BiDi\n", pdwDefaultLayout );
216     *pdwDefaultLayout = 0;
217     return TRUE;
218 }
219
220
221 /******************************************************************************
222  *                    SetProcessDefaultLayout [USER32.@]
223  *
224  * Sets the default layout for parentless windows.
225  * Right now, only accepts 0 (left-to-right).
226  *
227  * RETURNS
228  *    Success: Nonzero
229  *    Failure: Zero
230  *
231  * BUGS
232  *    No RTL
233  */
234 BOOL WINAPI SetProcessDefaultLayout( DWORD dwDefaultLayout )
235 {
236     if ( dwDefaultLayout == 0 )
237         return TRUE;
238     FIXME( "( %08lx ): No BiDi\n", dwDefaultLayout );
239     SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
240     return FALSE;
241 }
242
243
244 /***********************************************************************
245  *              SetWindowStationUser (USER32.@)
246  */
247 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
248 {
249     FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
250     return 1;
251 }
252
253 /***********************************************************************
254  *              RegisterLogonProcess (USER32.@)
255  */
256 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
257 {
258     FIXME("(%p,%d),stub!\n",hprocess,x);
259     return 1;
260 }
261
262 /***********************************************************************
263  *              SetLogonNotifyWindow (USER32.@)
264  */
265 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
266 {
267     FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
268     return 1;
269 }
270
271 /***********************************************************************
272  *              EnumDisplayDevicesA (USER32.@)
273  */
274 BOOL WINAPI EnumDisplayDevicesA( LPVOID unused, DWORD i, LPDISPLAY_DEVICEA lpDisplayDevice,
275                                  DWORD dwFlags )
276 {
277     if (i)
278         return FALSE;
279     FIXME("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags);
280     strcpy(lpDisplayDevice->DeviceName,"X11");
281     strcpy(lpDisplayDevice->DeviceString,"X 11 Windowing System");
282     lpDisplayDevice->StateFlags =
283         DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
284         DISPLAY_DEVICE_PRIMARY_DEVICE |
285         DISPLAY_DEVICE_VGA_COMPATIBLE;
286     return TRUE;
287 }
288
289 /***********************************************************************
290  *              EnumDisplayDevicesW (USER32.@)
291  */
292 BOOL WINAPI EnumDisplayDevicesW( LPVOID unused, DWORD i, LPDISPLAY_DEVICEW lpDisplayDevice,
293                                  DWORD dwFlags )
294 {
295     if (i)
296         return FALSE;
297     FIXME("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags);
298     MultiByteToWideChar( CP_ACP, 0, "X11", -1, lpDisplayDevice->DeviceName,
299                          sizeof(lpDisplayDevice->DeviceName)/sizeof(WCHAR) );
300     MultiByteToWideChar( CP_ACP, 0, "X11 Windowing System", -1, lpDisplayDevice->DeviceString,
301                          sizeof(lpDisplayDevice->DeviceString)/sizeof(WCHAR) );
302     lpDisplayDevice->StateFlags =
303         DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
304         DISPLAY_DEVICE_PRIMARY_DEVICE |
305         DISPLAY_DEVICE_VGA_COMPATIBLE;
306     return TRUE;
307 }
308
309 /***********************************************************************
310  *              RegisterSystemThread (USER32.@)
311  */
312 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
313 {
314     FIXME("(%08lx, %08lx)\n", flags, reserved);
315 }
316
317 /***********************************************************************
318  *           RegisterShellHookWindow                    [USER32.@]
319  */
320 BOOL WINAPI RegisterShellHookWindow ( HWND hWnd )
321 {
322     FIXME("(%p): stub\n", hWnd);
323     return 0;
324 }
325
326
327 /***********************************************************************
328  *           DeregisterShellHookWindow                  [USER32.@]
329  */
330 HRESULT WINAPI DeregisterShellHookWindow ( DWORD u )
331 {
332     FIXME("0x%08lx stub\n",u);
333     return 0;
334
335 }
336
337
338 /***********************************************************************
339  *           RegisterTasklist                           [USER32.@]
340  */
341 DWORD WINAPI RegisterTasklist (DWORD x)
342 {
343     FIXME("0x%08lx\n",x);
344     return TRUE;
345 }
346
347
348 /***********************************************************************
349  *              RegisterDeviceNotificationA (USER32.@)
350  *
351  * See RegisterDeviceNotificationW.
352  */
353 HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
354 {
355     FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hnd,notifyfilter,flags );
356     return 0;
357 }
358
359 /***********************************************************************
360  *              RegisterDeviceNotificationW (USER32.@)
361  *
362  * Registers a window with the system so that it will receive
363  * notifications about a device.
364  *
365  * PARAMS
366  *     hRecepient           [I] Window or service status handle that
367  *                              will receive notifications.
368  *     pNotificationFilter  [I] DEV_BROADCAST_HDR followed by some
369  *                              type-specific data.
370  *     dwFlags              [I] See notes
371  *
372  * RETURNS
373  *
374  * A handle to the device notification.
375  *
376  * NOTES
377  *
378  * The dwFlags parameter can be one of two values:
379  *| DEVICE_NOTIFY_WINDOW_HANDLE  - hRecepient is a window handle
380  *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecepient is a service status handle
381  */
382 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecepient, LPVOID pNotificationFilter, DWORD dwFlags)
383 {
384     FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hRecepient,pNotificationFilter,dwFlags );
385     return 0;
386 }
387
388 /***********************************************************************
389  *           GetAppCompatFlags   (USER32.@)
390  */
391 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
392 {
393     FIXME("stub\n");
394     return 0;
395 }
396
397
398 /***********************************************************************
399  *           AlignRects   (USER32.@)
400  */
401 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
402 {
403     FIXME("(%p, %ld, %ld, %ld): stub\n", rect, b, c, d);
404     if (rect)
405         FIXME("rect: [[%ld, %ld], [%ld, %ld]]\n", rect->left, rect->top, rect->right, rect->bottom);
406     /* Calls OffsetRect */
407     return FALSE;
408 }
409
410
411 /***********************************************************************
412  *              LoadLocalFonts (USER32.@)
413  */
414 VOID WINAPI LoadLocalFonts(VOID)
415 {
416     /* are loaded. */
417     return;
418 }
419
420
421 /***********************************************************************
422  *              USER_489 (USER.489)
423  */
424 LONG WINAPI stub_USER_489(void) { FIXME("stub\n"); return 0; }
425
426 /***********************************************************************
427  *              USER_490 (USER.490)
428  */
429 LONG WINAPI stub_USER_490(void) { FIXME("stub\n"); return 0; }
430
431 /***********************************************************************
432  *              USER_492 (USER.492)
433  */
434 LONG WINAPI stub_USER_492(void) { FIXME("stub\n"); return 0; }
435
436 /***********************************************************************
437  *              USER_496 (USER.496)
438  */
439 LONG WINAPI stub_USER_496(void) { FIXME("stub\n"); return 0; }
440
441 /***********************************************************************
442  *              User32InitializeImmEntryTable
443  */
444 BOOL WINAPI User32InitializeImmEntryTable(LPVOID ptr)
445 {
446   FIXME("(%p): stub\n", ptr);
447   return TRUE;
448 }
449
450 /**********************************************************************
451  * WINNLSGetIMEHotkey [USER32.@]
452  *
453  */
454 UINT WINAPI WINNLSGetIMEHotkey(HWND hUnknown1)
455 {
456     FIXME("hUnknown1 %p: stub!\n", hUnknown1);
457     return 0; /* unknown */
458 }
459
460 /**********************************************************************
461  * WINNLSEnableIME [USER32.@]
462  *
463  */
464 BOOL WINAPI WINNLSEnableIME(HWND hUnknown1, BOOL bUnknown2)
465 {
466     FIXME("hUnknown1 %p bUnknown2 %d: stub!\n", hUnknown1, bUnknown2);
467     return TRUE; /* success (?) */
468 }
469
470 /**********************************************************************
471  * WINNLSGetEnableStatus [USER32.@]
472  *
473  */
474 BOOL WINAPI WINNLSGetEnableStatus(HWND hUnknown1)
475 {
476     FIXME("hUnknown1 %p: stub!\n", hUnknown1);
477     return TRUE; /* success (?) */
478 }
479
480 /**********************************************************************
481  * SendIMEMessageExA [USER32.@]
482  *
483  */
484 LRESULT WINAPI SendIMEMessageExA(HWND p1, LPARAM p2)
485 {
486   FIXME("(%p,%lx): stub\n", p1, p2);
487   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
488   return 0;
489 }
490
491 /**********************************************************************
492  * SendIMEMessageExW [USER32.@]
493  *
494  */
495 LRESULT WINAPI SendIMEMessageExW(HWND p1, LPARAM p2)
496 {
497   FIXME("(%p,%lx): stub\n", p1, p2);
498   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
499   return 0;
500 }