CRT Documentation: Reference

SaveCrtState

[This function does not have a corresponding DOS function.]

Saves the current state of the console so it may be restored later.

function SaveCrtState(
  StatesToSave: TCrtSaveStates
): pointer;

Parameters

StatesToSave
[in] States to save. See the documentation for TCrtSaveStates for details.

Return Values

A non-nil pointer on success, nil on failure.

Remarks

This function returns a pointer that can be used with RestoreCrtState to restore the console state to the same state that it was in when this function was called.

By specifying multiple values for the StatesToSave parameter you can selectively save those console states that you wish. For example, specifying [csScreen, csCursorPos] saves only the screen contents and cursor location. Specifying [csCursorPos, csTextAttr] saves only the cursor position and current color value used for writing text to the screen.

If successful, memory is allocated and a pointer is returned, otherwise nil is returned. The memory structure allocated contains a pointer as well, so simply freeing this pointer will not dispose of all the memory used. If you want to dispose of all the memory allocated rather than restore the state later, you can use FreeCrtState.

See Also

Crt Overview, TCrtSaveStates, RestoreCrtState, FreeCrtState