Release 960114
[wine/gsoc-2012-control.git] / misc / user.c
blob27bd40c544fb44c7535166beadeddc4dc1bdce1d
1 /*
2 static char RCSId[] = "$Id: user.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
3 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include "atom.h"
8 #include "comm.h"
9 #include "gdi.h"
10 #include "desktop.h"
11 #include "dlls.h"
12 #include "dos_fs.h"
13 #include "sysmetrics.h"
14 #include "menu.h"
15 #include "dce.h"
16 #include "dialog.h"
17 #include "syscolor.h"
18 #include "win.h"
19 #include "windows.h"
20 #include "user.h"
21 #include "message.h"
22 #include "toolhelp.h"
24 #define USER_HEAP_SIZE 0x10000
26 #ifndef WINELIB
27 LPSTR USER_Heap = NULL;
28 WORD USER_HeapSel = 0;
31 /***********************************************************************
32 * GetFreeSystemResources (USER.284)
34 WORD GetFreeSystemResources( WORD resType )
36 DWORD user, gdi;
38 switch(resType)
40 case GFSR_USERRESOURCES:
41 user = GetHeapSpaces( USER_HeapSel );
42 gdi = 0xffffffff;
43 break;
45 case GFSR_GDIRESOURCES:
46 gdi = GetHeapSpaces( GDI_HeapSel );
47 user = 0xffffffff;
48 break;
50 case GFSR_SYSTEMRESOURCES:
51 user = GetHeapSpaces( USER_HeapSel );
52 gdi = GetHeapSpaces( GDI_HeapSel );
53 break;
55 default:
56 return 0;
58 if (user > gdi) return LOWORD(gdi) * 100 / HIWORD(gdi);
59 else return LOWORD(user) * 100 / HIWORD(user);
63 /***********************************************************************
64 * SystemHeapInfo (TOOLHELP.71)
66 BOOL SystemHeapInfo( SYSHEAPINFO *pHeapInfo )
68 pHeapInfo->wUserFreePercent = GetFreeSystemResources( GFSR_USERRESOURCES );
69 pHeapInfo->wGDIFreePercent = GetFreeSystemResources( GFSR_GDIRESOURCES );
70 pHeapInfo->hUserSegment = USER_HeapSel;
71 pHeapInfo->hGDISegment = GDI_HeapSel;
72 return TRUE;
76 /***********************************************************************
77 * TimerCount (TOOLHELP.80)
79 BOOL TimerCount( TIMERINFO *pTimerInfo )
81 /* FIXME
82 * In standard mode, dwmsSinceStart = dwmsThisVM
84 * I tested this, under Windows in enhanced mode, and
85 * if you never switch VM (ie start/stop DOS) these
86 * values should be the same as well.
88 * Also, Wine should adjust for the hardware timer
89 * to reduce the amount of error to ~1ms.
90 * I can't be bothered, can you?
92 pTimerInfo->dwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount();
93 return TRUE;
96 /***********************************************************************
97 * USER_HeapInit
99 BOOL USER_HeapInit(void)
101 if (!(USER_HeapSel = GlobalAlloc(GMEM_FIXED,USER_HEAP_SIZE))) return FALSE;
102 USER_Heap = GlobalLock( USER_HeapSel );
103 LocalInit( USER_HeapSel, 0, USER_HEAP_SIZE-1 );
104 return TRUE;
106 #endif
109 /**********************************************************************
110 * USER_InitApp
112 int USER_InitApp(HINSTANCE hInstance)
114 int queueSize;
116 /* Create task message queue */
117 queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
118 if (!SetMessageQueue( queueSize )) return 0;
120 return 1;