4 * Copyright 1993 Robert J. Amstadt
21 WORD USER_HeapSel
= 0;
24 extern HTASK
TASK_GetNextTask(HTASK
);
25 extern BOOL32
MENU_SwitchTPWndTo(HTASK
);
27 /***********************************************************************
28 * GetFreeSystemResources (USER.284)
30 WORD
GetFreeSystemResources( WORD resType
)
32 int userPercent
, gdiPercent
;
36 case GFSR_USERRESOURCES
:
37 userPercent
= (int)LOCAL_CountFree( USER_HeapSel
) * 100 /
38 LOCAL_HeapSize( USER_HeapSel
);
42 case GFSR_GDIRESOURCES
:
43 gdiPercent
= (int)LOCAL_CountFree( GDI_HeapSel
) * 100 /
44 LOCAL_HeapSize( GDI_HeapSel
);
48 case GFSR_SYSTEMRESOURCES
:
49 userPercent
= (int)LOCAL_CountFree( USER_HeapSel
) * 100 /
50 LOCAL_HeapSize( USER_HeapSel
);
51 gdiPercent
= (int)LOCAL_CountFree( GDI_HeapSel
) * 100 /
52 LOCAL_HeapSize( GDI_HeapSel
);
58 return (WORD
)MIN( userPercent
, gdiPercent
);
62 /***********************************************************************
63 * SystemHeapInfo (TOOLHELP.71)
65 BOOL16
SystemHeapInfo( SYSHEAPINFO
*pHeapInfo
)
67 pHeapInfo
->wUserFreePercent
= GetFreeSystemResources( GFSR_USERRESOURCES
);
68 pHeapInfo
->wGDIFreePercent
= GetFreeSystemResources( GFSR_GDIRESOURCES
);
69 pHeapInfo
->hUserSegment
= USER_HeapSel
;
70 pHeapInfo
->hGDISegment
= GDI_HeapSel
;
75 /***********************************************************************
76 * TimerCount (TOOLHELP.80)
78 BOOL16
TimerCount( TIMERINFO
*pTimerInfo
)
81 * In standard mode, dwmsSinceStart = dwmsThisVM
83 * I tested this, under Windows in enhanced mode, and
84 * if you never switch VM (ie start/stop DOS) these
85 * values should be the same as well.
87 * Also, Wine should adjust for the hardware timer
88 * to reduce the amount of error to ~1ms.
89 * I can't be bothered, can you?
91 pTimerInfo
->dwmsSinceStart
= pTimerInfo
->dwmsThisVM
= GetTickCount();
96 /**********************************************************************
99 int USER_InitApp(HINSTANCE hInstance
)
103 /* Create task message queue */
104 queueSize
= GetProfileInt( "windows", "DefaultQueueSize", 8 );
105 if (!SetMessageQueue( queueSize
)) return 0;
110 /**********************************************************************
113 void USER_AppExit( HTASK16 hTask
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
115 /* FIXME: flush send messages (which are not implemented yet),
116 * empty clipboard if needed, maybe destroy menus (Windows
117 * only complains about them but does nothing);
120 WND
* desktop
= WIN_GetDesktop();
122 /* Patch desktop window */
123 if( desktop
->hmemTaskQ
== hQueue
)
124 desktop
->hmemTaskQ
= GetTaskQueue(TASK_GetNextTask(hTask
));
126 /* Patch resident popup menu window */
127 MENU_SwitchTPWndTo(0);
131 TIMER_RemoveQueueTimers( hQueue
);
133 HOOK_FreeQueueHooks( hQueue
);
135 QUEUE_SetDoomedQueue( hQueue
);
137 /* Nuke orphaned windows */
139 WIN_DestroyQueueWindows( desktop
->child
, hQueue
);
141 QUEUE_SetDoomedQueue( 0 );
143 /* Free the message queue */
145 QUEUE_DeleteMsgQueue( hQueue
);