Release 960314
[wine.git] / misc / user.c
blob0a3cd4fad7a2e516e07a886bc686439169faaca2
1 /*
2 * Misc. USER functions
4 * Copyright 1993 Robert J. Amstadt
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "windows.h"
10 #include "gdi.h"
11 #include "user.h"
12 #include "win.h"
13 #include "toolhelp.h"
15 #define USER_HEAP_SIZE 0x10000
17 #ifndef WINELIB
18 LPSTR USER_Heap = NULL;
19 WORD USER_HeapSel = 0;
22 /***********************************************************************
23 * GetFreeSystemResources (USER.284)
25 WORD GetFreeSystemResources( WORD resType )
27 DWORD user, gdi;
29 switch(resType)
31 case GFSR_USERRESOURCES:
32 user = GetHeapSpaces( USER_HeapSel );
33 gdi = 0xffffffff;
34 break;
36 case GFSR_GDIRESOURCES:
37 gdi = GetHeapSpaces( GDI_HeapSel );
38 user = 0xffffffff;
39 break;
41 case GFSR_SYSTEMRESOURCES:
42 user = GetHeapSpaces( USER_HeapSel );
43 gdi = GetHeapSpaces( GDI_HeapSel );
44 break;
46 default:
47 return 0;
49 if (user > gdi) return LOWORD(gdi) * 100 / HIWORD(gdi);
50 else return LOWORD(user) * 100 / HIWORD(user);
54 /***********************************************************************
55 * SystemHeapInfo (TOOLHELP.71)
57 BOOL SystemHeapInfo( SYSHEAPINFO *pHeapInfo )
59 pHeapInfo->wUserFreePercent = GetFreeSystemResources( GFSR_USERRESOURCES );
60 pHeapInfo->wGDIFreePercent = GetFreeSystemResources( GFSR_GDIRESOURCES );
61 pHeapInfo->hUserSegment = USER_HeapSel;
62 pHeapInfo->hGDISegment = GDI_HeapSel;
63 return TRUE;
67 /***********************************************************************
68 * USER_HeapInit
70 BOOL USER_HeapInit(void)
72 if (!(USER_HeapSel = GlobalAlloc(GMEM_FIXED,USER_HEAP_SIZE))) return FALSE;
73 USER_Heap = GlobalLock( USER_HeapSel );
74 LocalInit( USER_HeapSel, 0, USER_HEAP_SIZE-1 );
75 return TRUE;
77 #endif
80 /***********************************************************************
81 * TimerCount (TOOLHELP.80)
83 BOOL TimerCount( TIMERINFO *pTimerInfo )
85 /* FIXME
86 * In standard mode, dwmsSinceStart = dwmsThisVM
88 * I tested this, under Windows in enhanced mode, and
89 * if you never switch VM (ie start/stop DOS) these
90 * values should be the same as well.
92 * Also, Wine should adjust for the hardware timer
93 * to reduce the amount of error to ~1ms.
94 * I can't be bothered, can you?
96 pTimerInfo->dwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount();
97 return TRUE;
101 /**********************************************************************
102 * USER_InitApp
104 int USER_InitApp(HINSTANCE hInstance)
106 int queueSize;
108 /* Create task message queue */
109 queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
110 if (!SetMessageQueue( queueSize )) return 0;
112 return 1;