Always set the drive type even if nothing else changed.
[wine/multimedia.git] / dlls / user / misc.c
blob277534e665eea3186086d52e7256161bde1d0bf5
1 /*
2 * Misc USER functions
4 * Copyright 1995 Thomas Sandford
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Turchanov Sergey
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "wine/windef16.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "winternl.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(win);
38 /* USER signal proc flags and codes */
39 /* See UserSignalProc for comments */
40 #define USIG_FLAGS_WIN32 0x0001
41 #define USIG_FLAGS_GUI 0x0002
42 #define USIG_FLAGS_FEEDBACK 0x0004
43 #define USIG_FLAGS_FAULT 0x0008
45 #define USIG_DLL_UNLOAD_WIN16 0x0001
46 #define USIG_DLL_UNLOAD_WIN32 0x0002
47 #define USIG_FAULT_DIALOG_PUSH 0x0003
48 #define USIG_FAULT_DIALOG_POP 0x0004
49 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
50 #define USIG_THREAD_INIT 0x0010
51 #define USIG_THREAD_EXIT 0x0020
52 #define USIG_PROCESS_CREATE 0x0100
53 #define USIG_PROCESS_INIT 0x0200
54 #define USIG_PROCESS_EXIT 0x0300
55 #define USIG_PROCESS_DESTROY 0x0400
56 #define USIG_PROCESS_RUNNING 0x0500
57 #define USIG_PROCESS_LOADED 0x0600
59 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
61 /***********************************************************************
62 * SignalProc32 (USER.391)
63 * UserSignalProc (USER32.@)
65 * The exact meaning of the USER signals is undocumented, but this
66 * should cover the basic idea:
68 * USIG_DLL_UNLOAD_WIN16
69 * This is sent when a 16-bit module is unloaded.
71 * USIG_DLL_UNLOAD_WIN32
72 * This is sent when a 32-bit module is unloaded.
74 * USIG_DLL_UNLOAD_ORPHANS
75 * This is sent after the last Win3.1 module is unloaded,
76 * to allow removal of orphaned menus.
78 * USIG_FAULT_DIALOG_PUSH
79 * USIG_FAULT_DIALOG_POP
80 * These are called to allow USER to prepare for displaying a
81 * fault dialog, even though the fault might have happened while
82 * inside a USER critical section.
84 * USIG_THREAD_INIT
85 * This is called from the context of a new thread, as soon as it
86 * has started to run.
88 * USIG_THREAD_EXIT
89 * This is called, still in its context, just before a thread is
90 * about to terminate.
92 * USIG_PROCESS_CREATE
93 * This is called, in the parent process context, after a new process
94 * has been created.
96 * USIG_PROCESS_INIT
97 * This is called in the new process context, just after the main thread
98 * has started execution (after the main thread's USIG_THREAD_INIT has
99 * been sent).
101 * USIG_PROCESS_LOADED
102 * This is called after the executable file has been loaded into the
103 * new process context.
105 * USIG_PROCESS_RUNNING
106 * This is called immediately before the main entry point is called.
108 * USIG_PROCESS_EXIT
109 * This is called in the context of a process that is about to
110 * terminate (but before the last thread's USIG_THREAD_EXIT has
111 * been sent).
113 * USIG_PROCESS_DESTROY
114 * This is called after a process has terminated.
117 * The meaning of the dwFlags bits is as follows:
119 * USIG_FLAGS_WIN32
120 * Current process is 32-bit.
122 * USIG_FLAGS_GUI
123 * Current process is a (Win32) GUI process.
125 * USIG_FLAGS_FEEDBACK
126 * Current process needs 'feedback' (determined from the STARTUPINFO
127 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
129 * USIG_FLAGS_FAULT
130 * The signal is being sent due to a fault.
132 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
133 DWORD dwFlags, HMODULE16 hModule )
135 FIXME("(%04x, %08lx, %04lx, %04x)\n",
136 uCode, dwThreadOrProcessID, dwFlags, hModule );
137 /* FIXME: Should chain to GdiSignalProc now. */
138 return 0;
142 /**********************************************************************
143 * SetLastErrorEx [USER32.@]
145 * Sets the last-error code.
147 * RETURNS
148 * None.
150 void WINAPI SetLastErrorEx(
151 DWORD error, /* [in] Per-thread error code */
152 DWORD type) /* [in] Error type */
154 TRACE("(0x%08lx, 0x%08lx)\n", error,type);
155 switch(type) {
156 case 0:
157 break;
158 case SLE_ERROR:
159 case SLE_MINORERROR:
160 case SLE_WARNING:
161 /* Fall through for now */
162 default:
163 FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error,type);
164 break;
166 SetLastError( error );
169 /******************************************************************************
170 * GetAltTabInfoA [USER32.@]
172 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
174 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
175 return FALSE;
178 /******************************************************************************
179 * GetAltTabInfoW [USER32.@]
181 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
183 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
184 return FALSE;
187 /******************************************************************************
188 * SetDebugErrorLevel [USER32.@]
189 * Sets the minimum error level for generating debugging events
191 * PARAMS
192 * dwLevel [I] Debugging error level
194 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
196 FIXME("(%ld): stub\n", dwLevel);
200 /******************************************************************************
201 * GetProcessDefaultLayout [USER32.@]
203 * Gets the default layout for parentless windows.
204 * Right now, just returns 0 (left-to-right).
206 * RETURNS
207 * Success: Nonzero
208 * Failure: Zero
210 * BUGS
211 * No RTL
213 BOOL WINAPI GetProcessDefaultLayout( DWORD *pdwDefaultLayout )
215 if ( !pdwDefaultLayout ) {
216 SetLastError( ERROR_INVALID_PARAMETER );
217 return FALSE;
219 FIXME( "( %p ): No BiDi\n", pdwDefaultLayout );
220 *pdwDefaultLayout = 0;
221 return TRUE;
225 /******************************************************************************
226 * SetProcessDefaultLayout [USER32.@]
228 * Sets the default layout for parentless windows.
229 * Right now, only accepts 0 (left-to-right).
231 * RETURNS
232 * Success: Nonzero
233 * Failure: Zero
235 * BUGS
236 * No RTL
238 BOOL WINAPI SetProcessDefaultLayout( DWORD dwDefaultLayout )
240 if ( dwDefaultLayout == 0 )
241 return TRUE;
242 FIXME( "( %08lx ): No BiDi\n", dwDefaultLayout );
243 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
244 return FALSE;
248 /***********************************************************************
249 * SetWindowStationUser (USER32.@)
251 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
253 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
254 return 1;
257 /***********************************************************************
258 * RegisterLogonProcess (USER32.@)
260 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
262 FIXME("(%p,%d),stub!\n",hprocess,x);
263 return 1;
266 /***********************************************************************
267 * SetLogonNotifyWindow (USER32.@)
269 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
271 FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
272 return 1;
275 static const WCHAR primary_device_name[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
276 static const WCHAR primary_device_string[] = {'X','1','1',' ','W','i','n','d','o','w','i','n','g',' ',
277 'S','y','s','t','e','m',0};
279 /***********************************************************************
280 * EnumDisplayDevicesA (USER32.@)
282 BOOL WINAPI EnumDisplayDevicesA( LPCSTR lpDevice, DWORD i, LPDISPLAY_DEVICEA lpDispDev,
283 DWORD dwFlags )
285 UNICODE_STRING deviceW;
286 DISPLAY_DEVICEW ddW;
287 BOOL ret;
289 if(lpDevice)
290 RtlCreateUnicodeStringFromAsciiz(&deviceW, lpDevice);
291 else
292 deviceW.Buffer = NULL;
294 ddW.cb = sizeof(ddW);
295 ret = EnumDisplayDevicesW(deviceW.Buffer, i, &ddW, dwFlags);
296 RtlFreeUnicodeString(&deviceW);
298 if(!ret) return ret;
300 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceName, -1, lpDispDev->DeviceName, sizeof(lpDispDev->DeviceName), NULL, NULL);
301 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceString, -1, lpDispDev->DeviceString, sizeof(lpDispDev->DeviceString), NULL, NULL);
302 lpDispDev->StateFlags = ddW.StateFlags;
304 if(lpDispDev->cb >= offsetof(DISPLAY_DEVICEA, DeviceID) + sizeof(lpDispDev->DeviceID))
305 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceID, -1, lpDispDev->DeviceID, sizeof(lpDispDev->DeviceID), NULL, NULL);
306 if(lpDispDev->cb >= offsetof(DISPLAY_DEVICEA, DeviceKey) + sizeof(lpDispDev->DeviceKey))
307 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceKey, -1, lpDispDev->DeviceKey, sizeof(lpDispDev->DeviceKey), NULL, NULL);
309 return TRUE;
312 /***********************************************************************
313 * EnumDisplayDevicesW (USER32.@)
315 BOOL WINAPI EnumDisplayDevicesW( LPCWSTR lpDevice, DWORD i, LPDISPLAY_DEVICEW lpDisplayDevice,
316 DWORD dwFlags )
318 FIXME("(%s,%ld,%p,0x%08lx), stub!\n",debugstr_w(lpDevice),i,lpDisplayDevice,dwFlags);
320 if (i)
321 return FALSE;
323 memcpy(lpDisplayDevice->DeviceName, primary_device_name, sizeof(primary_device_name));
324 memcpy(lpDisplayDevice->DeviceString, primary_device_string, sizeof(primary_device_string));
326 lpDisplayDevice->StateFlags =
327 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
328 DISPLAY_DEVICE_PRIMARY_DEVICE |
329 DISPLAY_DEVICE_VGA_COMPATIBLE;
331 if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID))
332 lpDisplayDevice->DeviceID[0] = 0;
333 if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(lpDisplayDevice->DeviceKey))
334 lpDisplayDevice->DeviceKey[0] = 0;
336 return TRUE;
339 /***********************************************************************
340 * MonitorFromPoint (USER32.@)
342 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
344 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
345 ((ptScreenCoords.x >= 0) &&
346 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
347 (ptScreenCoords.y >= 0) &&
348 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
350 return xPRIMARY_MONITOR;
352 return NULL;
355 /***********************************************************************
356 * MonitorFromRect (USER32.@)
358 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
360 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
361 ((lprcScreenCoords->right > 0) &&
362 (lprcScreenCoords->bottom > 0) &&
363 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
364 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
366 return xPRIMARY_MONITOR;
368 return NULL;
371 /***********************************************************************
372 * MonitorFromWindow (USER32.@)
374 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
376 WINDOWPLACEMENT wp;
378 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
379 return xPRIMARY_MONITOR;
381 if (IsIconic(hWnd) ?
382 GetWindowPlacement(hWnd, &wp) :
383 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
385 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
388 return NULL;
391 /***********************************************************************
392 * GetMonitorInfoA (USER32.@)
394 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
396 MONITORINFOEXW miW;
397 MONITORINFOEXA *miA = (MONITORINFOEXA*)lpMonitorInfo;
398 BOOL ret;
400 miW.cbSize = sizeof(miW);
402 ret = GetMonitorInfoW(hMonitor, (MONITORINFO*)&miW);
403 if(!ret) return ret;
405 miA->rcMonitor = miW.rcMonitor;
406 miA->rcWork = miW.rcWork;
407 miA->dwFlags = miW.dwFlags;
408 if(miA->cbSize >= offsetof(MONITORINFOEXA, szDevice) + sizeof(miA->szDevice))
409 WideCharToMultiByte(CP_ACP, 0, miW.szDevice, -1, miA->szDevice, sizeof(miA->szDevice), NULL, NULL);
410 return ret;
413 /***********************************************************************
414 * GetMonitorInfoW (USER32.@)
416 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
418 RECT rcWork;
420 if ((hMonitor == xPRIMARY_MONITOR) &&
421 lpMonitorInfo &&
422 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
423 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
425 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
426 GetSystemMetrics(SM_CXSCREEN),
427 GetSystemMetrics(SM_CYSCREEN) );
428 lpMonitorInfo->rcWork = rcWork;
429 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
431 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
432 strcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, primary_device_name);
434 return TRUE;
437 return FALSE;
440 /***********************************************************************
441 * EnumDisplayMonitors (USER32.@)
443 BOOL WINAPI EnumDisplayMonitors(
444 HDC hdcOptionalForPainting,
445 LPRECT lprcEnumMonitorsThatIntersect,
446 MONITORENUMPROC lpfnEnumProc,
447 LPARAM dwData)
449 RECT rcLimit;
450 SetRect( &rcLimit, 0, 0, GetSystemMetrics(SM_CXSCREEN),
451 GetSystemMetrics(SM_CYSCREEN) );
453 if (!lpfnEnumProc)
454 return FALSE;
456 if (hdcOptionalForPainting)
458 RECT rcClip;
459 POINT ptOrg;
461 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
463 default:
464 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
465 return FALSE;
467 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
468 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
469 (!lprcEnumMonitorsThatIntersect ||
470 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
472 break;
474 /* fall through */
475 case NULLREGION:
476 return TRUE;
477 case ERROR:
478 return FALSE;
480 } else {
481 if ( lprcEnumMonitorsThatIntersect &&
482 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
484 return TRUE;
488 return lpfnEnumProc(
489 xPRIMARY_MONITOR,
490 hdcOptionalForPainting,
491 &rcLimit,
492 dwData);
495 /***********************************************************************
496 * RegisterSystemThread (USER32.@)
498 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
500 FIXME("(%08lx, %08lx)\n", flags, reserved);
503 /***********************************************************************
504 * RegisterShellHookWindow [USER32.@]
506 BOOL WINAPI RegisterShellHookWindow ( HWND hWnd )
508 FIXME("(%p): stub\n", hWnd);
509 return 0;
513 /***********************************************************************
514 * DeregisterShellHookWindow [USER32.@]
516 HRESULT WINAPI DeregisterShellHookWindow ( DWORD u )
518 FIXME("0x%08lx stub\n",u);
519 return 0;
524 /***********************************************************************
525 * RegisterTasklist [USER32.@]
527 DWORD WINAPI RegisterTasklist (DWORD x)
529 FIXME("0x%08lx\n",x);
530 return TRUE;
534 /***********************************************************************
535 * RegisterDeviceNotificationA (USER32.@)
537 * See RegisterDeviceNotificationW.
539 HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
541 FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hnd,notifyfilter,flags );
542 return 0;
545 /***********************************************************************
546 * RegisterDeviceNotificationW (USER32.@)
548 * Registers a window with the system so that it will receive
549 * notifications about a device.
551 * PARAMS
552 * hRecepient [I] Window or service status handle that
553 * will receive notifications.
554 * pNotificationFilter [I] DEV_BROADCAST_HDR followed by some
555 * type-specific data.
556 * dwFlags [I] See notes
558 * RETURNS
560 * A handle to the device notification.
562 * NOTES
564 * The dwFlags parameter can be one of two values:
565 *| DEVICE_NOTIFY_WINDOW_HANDLE - hRecepient is a window handle
566 *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecepient is a service status handle
568 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecepient, LPVOID pNotificationFilter, DWORD dwFlags)
570 FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hRecepient,pNotificationFilter,dwFlags );
571 return 0;
574 /***********************************************************************
575 * UnregisterDeviceNotification (USER32.@)
578 BOOL WINAPI UnregisterDeviceNotification(HDEVNOTIFY hnd)
580 FIXME("(handle=%p), STUB!\n", hnd);
581 return TRUE;
584 /***********************************************************************
585 * GetAppCompatFlags (USER32.@)
587 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
589 FIXME("stub\n");
590 return 0;
594 /***********************************************************************
595 * AlignRects (USER32.@)
597 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
599 FIXME("(%p, %ld, %ld, %ld): stub\n", rect, b, c, d);
600 if (rect)
601 FIXME("rect: [[%ld, %ld], [%ld, %ld]]\n", rect->left, rect->top, rect->right, rect->bottom);
602 /* Calls OffsetRect */
603 return FALSE;
607 /***********************************************************************
608 * LoadLocalFonts (USER32.@)
610 VOID WINAPI LoadLocalFonts(VOID)
612 /* are loaded. */
613 return;
617 /***********************************************************************
618 * USER_489 (USER.489)
620 LONG WINAPI stub_USER_489(void) { FIXME("stub\n"); return 0; }
622 /***********************************************************************
623 * USER_490 (USER.490)
625 LONG WINAPI stub_USER_490(void) { FIXME("stub\n"); return 0; }
627 /***********************************************************************
628 * USER_492 (USER.492)
630 LONG WINAPI stub_USER_492(void) { FIXME("stub\n"); return 0; }
632 /***********************************************************************
633 * USER_496 (USER.496)
635 LONG WINAPI stub_USER_496(void) { FIXME("stub\n"); return 0; }
637 /***********************************************************************
638 * User32InitializeImmEntryTable
640 BOOL WINAPI User32InitializeImmEntryTable(LPVOID ptr)
642 FIXME("(%p): stub\n", ptr);
643 return TRUE;
646 /**********************************************************************
647 * WINNLSGetIMEHotkey [USER32.@]
650 UINT WINAPI WINNLSGetIMEHotkey(HWND hUnknown1)
652 FIXME("hUnknown1 %p: stub!\n", hUnknown1);
653 return 0; /* unknown */
656 /**********************************************************************
657 * WINNLSEnableIME [USER32.@]
660 BOOL WINAPI WINNLSEnableIME(HWND hUnknown1, BOOL bUnknown2)
662 FIXME("hUnknown1 %p bUnknown2 %d: stub!\n", hUnknown1, bUnknown2);
663 return TRUE; /* success (?) */
666 /**********************************************************************
667 * WINNLSGetEnableStatus [USER32.@]
670 BOOL WINAPI WINNLSGetEnableStatus(HWND hUnknown1)
672 FIXME("hUnknown1 %p: stub!\n", hUnknown1);
673 return TRUE; /* success (?) */
676 /**********************************************************************
677 * SendIMEMessageExA [USER32.@]
680 LRESULT WINAPI SendIMEMessageExA(HWND p1, LPARAM p2)
682 FIXME("(%p,%lx): stub\n", p1, p2);
683 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
684 return 0;
687 /**********************************************************************
688 * SendIMEMessageExW [USER32.@]
691 LRESULT WINAPI SendIMEMessageExW(HWND p1, LPARAM p2)
693 FIXME("(%p,%lx): stub\n", p1, p2);
694 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
695 return 0;