4 * Copyright 1993 Robert J. Amstadt
20 WORD USER_HeapSel = 0;
23 extern HTASK TASK_GetNextTask(HTASK);
25 /***********************************************************************
26 * GetFreeSystemResources (USER.284)
28 WORD GetFreeSystemResources( WORD resType )
30 int userPercent, gdiPercent;
34 case GFSR_USERRESOURCES:
35 userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
36 LOCAL_HeapSize( USER_HeapSel );
40 case GFSR_GDIRESOURCES:
41 gdiPercent = (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
42 LOCAL_HeapSize( GDI_HeapSel );
46 case GFSR_SYSTEMRESOURCES:
47 userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
48 LOCAL_HeapSize( USER_HeapSel );
49 gdiPercent = (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
50 LOCAL_HeapSize( GDI_HeapSel );
56 return (WORD)MIN( userPercent, gdiPercent );
60 /***********************************************************************
61 * SystemHeapInfo (TOOLHELP.71)
63 BOOL16 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;
73 /***********************************************************************
74 * TimerCount (TOOLHELP.80)
76 BOOL16 TimerCount( TIMERINFO *pTimerInfo )
79 * In standard mode, dwmsSinceStart = dwmsThisVM
81 * I tested this, under Windows in enhanced mode, and
82 * if you never switch VM (ie start/stop DOS) these
83 * values should be the same as well.
85 * Also, Wine should adjust for the hardware timer
86 * to reduce the amount of error to ~1ms.
87 * I can't be bothered, can you?
89 pTimerInfo->dwmsSinceStart = pTimerInfo->dwmsThisVM = GetTickCount();
94 /**********************************************************************
97 int USER_InitApp(HINSTANCE hInstance)
101 /* Create task message queue */
102 queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
103 if (!SetMessageQueue( queueSize )) return 0;
108 /**********************************************************************
111 void USER_AppExit( HTASK16 hTask, HINSTANCE16 hInstance, HQUEUE16 hQueue )
113 /* FIXME: flush send messages (which are not implemented yet),
114 * empty clipboard if needed, maybe destroy menus (Windows
115 * only complains about them but does nothing);
118 WND* desktop = WIN_GetDesktop();
120 /* Patch desktop window queue */
121 if( desktop->hmemTaskQ == hQueue )
122 desktop->hmemTaskQ = GetTaskQueue(TASK_GetNextTask(hTask));
126 TIMER_RemoveQueueTimers( hQueue );
128 HOOK_FreeQueueHooks( hQueue );
130 QUEUE_SetDoomedQueue( hQueue );
132 /* Nuke orphaned windows */
134 WIN_DestroyQueueWindows( desktop->child, hQueue );
136 QUEUE_SetDoomedQueue( 0 );
138 /* Free the message queue */
140 QUEUE_DeleteMsgQueue( hQueue );