4 * Copyright 1993 Robert J. Amstadt
20 WORD USER_HeapSel
= 0;
23 extern HTASK
TASK_GetNextTask(HTASK
);
24 extern void QUEUE_SetDoomedQueue(HQUEUE
);
26 /***********************************************************************
27 * GetFreeSystemResources (USER.284)
29 WORD
GetFreeSystemResources( WORD resType
)
31 int userPercent
, gdiPercent
;
35 case GFSR_USERRESOURCES
:
36 userPercent
= (int)LOCAL_CountFree( USER_HeapSel
) * 100 /
37 LOCAL_HeapSize( USER_HeapSel
);
41 case GFSR_GDIRESOURCES
:
42 gdiPercent
= (int)LOCAL_CountFree( GDI_HeapSel
) * 100 /
43 LOCAL_HeapSize( GDI_HeapSel
);
47 case GFSR_SYSTEMRESOURCES
:
48 userPercent
= (int)LOCAL_CountFree( USER_HeapSel
) * 100 /
49 LOCAL_HeapSize( USER_HeapSel
);
50 gdiPercent
= (int)LOCAL_CountFree( GDI_HeapSel
) * 100 /
51 LOCAL_HeapSize( GDI_HeapSel
);
57 return (WORD
)MIN( userPercent
, gdiPercent
);
61 /***********************************************************************
62 * SystemHeapInfo (TOOLHELP.71)
64 BOOL16
SystemHeapInfo( SYSHEAPINFO
*pHeapInfo
)
66 pHeapInfo
->wUserFreePercent
= GetFreeSystemResources( GFSR_USERRESOURCES
);
67 pHeapInfo
->wGDIFreePercent
= GetFreeSystemResources( GFSR_GDIRESOURCES
);
68 pHeapInfo
->hUserSegment
= USER_HeapSel
;
69 pHeapInfo
->hGDISegment
= GDI_HeapSel
;
74 /***********************************************************************
75 * TimerCount (TOOLHELP.80)
77 BOOL16
TimerCount( TIMERINFO
*pTimerInfo
)
80 * In standard mode, dwmsSinceStart = dwmsThisVM
82 * I tested this, under Windows in enhanced mode, and
83 * if you never switch VM (ie start/stop DOS) these
84 * values should be the same as well.
86 * Also, Wine should adjust for the hardware timer
87 * to reduce the amount of error to ~1ms.
88 * I can't be bothered, can you?
90 pTimerInfo
->dwmsSinceStart
= pTimerInfo
->dwmsThisVM
= GetTickCount();
95 /**********************************************************************
98 int USER_InitApp(HINSTANCE hInstance
)
102 /* Create task message queue */
103 queueSize
= GetProfileInt( "windows", "DefaultQueueSize", 8 );
104 if (!SetMessageQueue( queueSize
)) return 0;
109 /**********************************************************************
112 void USER_AppExit(HTASK hTask
, HINSTANCE hInstance
, HQUEUE hQueue
)
114 /* FIXME: flush send messages (which are not implemented yet),
115 * empty clipboard if needed, maybe destroy menus (Windows
116 * only complains about them but does nothing);
119 WND
* desktop
= WIN_GetDesktop();
121 /* Patch desktop window queue */
122 if( desktop
->hmemTaskQ
== hQueue
)
123 desktop
->hmemTaskQ
= GetTaskQueue(TASK_GetNextTask(hTask
));
127 TIMER_RemoveQueueTimers( hQueue
);
129 HOOK_FreeQueueHooks( hQueue
);
131 QUEUE_SetDoomedQueue( hQueue
);
133 /* Nuke orphaned windows */
135 WIN_DestroyQueueWindows( desktop
->child
, hQueue
);
137 QUEUE_SetDoomedQueue( 0 );
139 /* Free the message queue */
141 QUEUE_DeleteMsgQueue( hQueue
);