4 * Copyright 1993 Robert J. Amstadt
21 WORD USER_HeapSel
= 0;
23 extern BOOL32
MENU_SwitchTPWndTo(HTASK16
);
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 INT16
InitApp( HINSTANCE16 hInstance
)
101 /* Create task message queue */
102 queueSize
= GetProfileInt32A( "windows", "DefaultQueueSize", 8 );
103 if (!SetMessageQueue32( queueSize
)) return 0;
108 /**********************************************************************
111 void USER_AppExit( HTASK16 hTask
, HINSTANCE16 hInstance
, HQUEUE16 hQueue
)
113 /* FIXME: empty clipboard if needed, maybe destroy menus (Windows
114 * only complains about them but does nothing);
117 WND
* desktop
= WIN_GetDesktop();
119 /* Patch desktop window */
120 if( desktop
->hmemTaskQ
== hQueue
)
121 desktop
->hmemTaskQ
= GetTaskQueue(TASK_GetNextTask(hTask
));
123 /* Patch resident popup menu window */
124 MENU_SwitchTPWndTo(0);
126 TIMER_RemoveQueueTimers( hQueue
);
128 QUEUE_FlushMessages( hQueue
);
129 HOOK_FreeQueueHooks( hQueue
);
131 QUEUE_SetDoomedQueue( hQueue
);
132 WIN_ResetQueueWindows( desktop
->child
, hQueue
, (HQUEUE16
)0);
133 QUEUE_SetDoomedQueue( 0 );
135 /* Free the message queue */
137 QUEUE_DeleteMsgQueue( hQueue
);