Release 950319
[wine.git] / misc / user.c
blob91cc3d9523e2e9864dfbd65520a42dd952361f46
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 "gdi.h"
9 #include "dlls.h"
10 #include "sysmetrics.h"
11 #include "menu.h"
12 #include "dce.h"
13 #include "dialog.h"
14 #include "syscolor.h"
15 #include "win.h"
16 #include "windows.h"
17 #include "prototypes.h"
18 #include "user.h"
19 #include "message.h"
20 #include "toolhelp.h"
22 #define USER_HEAP_SIZE 0x10000
24 LPSTR USER_Heap = NULL;
25 WORD USER_HeapSel = 0;
28 /***********************************************************************
29 * GetFreeSystemResources (USER.284)
31 WORD GetFreeSystemResources( WORD resType )
33 DWORD user, gdi;
35 switch(resType)
37 case GFSR_USERRESOURCES:
38 user = GetHeapSpaces( USER_HeapSel );
39 gdi = 0xffffffff;
40 break;
42 case GFSR_GDIRESOURCES:
43 gdi = GetHeapSpaces( GDI_HeapSel );
44 user = 0xffffffff;
45 break;
47 case GFSR_SYSTEMRESOURCES:
48 user = GetHeapSpaces( USER_HeapSel );
49 gdi = GetHeapSpaces( GDI_HeapSel );
50 break;
52 default:
53 return 0;
55 if (user > gdi) return LOWORD(gdi) * 100 / HIWORD(gdi);
56 else return LOWORD(user) * 100 / HIWORD(user);
60 /***********************************************************************
61 * SystemHeapInfo (TOOLHELP.71)
63 BOOL SystemHeapInfo( SYSHEAPINFO *pHeapInfo )
65 pHeapInfo->wUserFreePercent = GetFreeSystemResources( GFSR_USERRESOURCES );
66 pHeapInfo->wGDIFreePercent = GetFreeSystemResources( GFSR_GDIRESOURCES );
67 pHeapInfo->hUserSegment = USER_HeapSel;
68 pHeapInfo->hGDISegment = GDI_HeapSel;
69 return TRUE;
73 #ifndef WINELIB
74 /***********************************************************************
75 * USER_HeapInit
77 static BOOL USER_HeapInit(void)
79 if (!(USER_HeapSel = GlobalAlloc(GMEM_FIXED,USER_HEAP_SIZE))) return FALSE;
80 USER_Heap = GlobalLock( USER_HeapSel );
81 LocalInit( USER_HeapSel, 0, USER_HEAP_SIZE-1 );
82 return TRUE;
84 #endif
86 /**********************************************************************
87 * USER_InitApp
89 * Load necessary resources?
91 int
92 USER_InitApp(int hInstance)
94 int queueSize;
96 SpyInit();
98 #ifndef WINELIB
99 /* Create USER heap */
100 if (!USER_HeapInit()) return 0;
101 #endif
103 /* Global atom table initialisation */
104 if (!ATOM_Init()) return 0;
106 /* GDI initialisation */
107 if (!GDI_Init()) return 0;
109 /* Initialize system colors and metrics*/
110 SYSMETRICS_Init();
111 SYSCOLOR_Init();
113 /* Create the DCEs */
114 DCE_Init();
116 /* Initialize built-in window classes */
117 if (!WIDGETS_Init()) return 0;
119 /* Initialize dialog manager */
120 if (!DIALOG_Init()) return 0;
122 /* Initialize menus */
123 if (!MENU_Init()) return 0;
125 /* Create system message queue */
126 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
127 if (!MSG_CreateSysMsgQueue( queueSize )) return 0;
129 /* Create task message queue */
130 queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
131 if (!SetMessageQueue( queueSize )) return 0;
133 /* Create desktop window */
134 if (!WIN_CreateDesktopWindow()) return 0;
136 #ifndef WINELIB
137 /* Initialize DLLs */
138 InitializeLoadedDLLs(NULL);
139 #endif
141 return 1;