4 * Copyright 1993 Robert J. Amstadt
20 WORD USER_HeapSel = 0;
24 extern void TIMER_NukeTimers(HWND, HQUEUE);
25 extern HTASK TASK_GetNextTask(HTASK);
26 extern void QUEUE_SetDoomedQueue(HQUEUE);
28 /***********************************************************************
29 * GetFreeSystemResources (USER.284)
31 WORD GetFreeSystemResources( WORD resType )
33 int userPercent, gdiPercent;
37 case GFSR_USERRESOURCES:
38 userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
39 LOCAL_HeapSize( USER_HeapSel );
43 case GFSR_GDIRESOURCES:
44 gdiPercent = (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
45 LOCAL_HeapSize( GDI_HeapSel );
49 case GFSR_SYSTEMRESOURCES:
50 userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
51 LOCAL_HeapSize( USER_HeapSel );
52 gdiPercent = (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
53 LOCAL_HeapSize( GDI_HeapSel );
59 return (WORD)MIN( userPercent, gdiPercent );
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;
77 /***********************************************************************
78 * TimerCount (TOOLHELP.80)
80 BOOL TimerCount( TIMERINFO *pTimerInfo )
83 * In standard mode, dwmsSinceStart = dwmsThisVM
85 * I tested this, under Windows in enhanced mode, and
86 * if you never switch VM (ie start/stop DOS) these
87 * values should be the same as well.
89 * Also, Wine should adjust for the hardware timer
90 * to reduce the amount of error to ~1ms.
91 * I can't be bothered, can you?
93 pTimerInfo->dwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount();
98 /**********************************************************************
101 int USER_InitApp(HINSTANCE hInstance)
105 /* Create task message queue */
106 queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
107 if (!SetMessageQueue( queueSize )) return 0;
112 /**********************************************************************
115 void USER_AppExit(HTASK hTask, HINSTANCE hInstance, HQUEUE hQueue)
117 /* FIXME: flush send messages (which are not implemented yet),
118 * empty clipboard if needed, maybe destroy menus (Windows
119 * only complains about them but does nothing);
122 WND* desktop = WIN_GetDesktop();
124 /* Patch desktop window queue */
125 if( desktop->hmemTaskQ == hQueue )
126 desktop->hmemTaskQ = GetTaskQueue(TASK_GetNextTask(hTask));
130 TIMER_NukeTimers( 0, hQueue );
132 HOOK_FreeQueueHooks( hQueue );
134 QUEUE_SetDoomedQueue( hQueue );
136 /* Nuke orphaned windows */
138 WIN_DestroyQueueWindows( desktop->child, hQueue );
140 QUEUE_SetDoomedQueue( 0 );
142 /* Free the message queue */
144 QUEUE_DeleteMsgQueue( hQueue );