program FSConTest;
{$APPTYPE CONSOLE}
uses
Windows;
[color=red]type
TFNGetConsoleDisplayMode = function( // [
msdn]GetConsoleDisplayMode[/
msdn] documented for W2K3
var lpModeFlags: DWORD
): BOOL; stdcall;
TFNSetConsoleDisplayMode = function( // [
msdn]SetConsoleDisplayMode[/
msdn] documented for W2K3
hConsoleOutput: THandle;
dwFlags: DWORD;
var lpNewScreenBufferDimensions: COORD
): BOOL; stdcall;
const
CONSOLE_FULLSCREEN_MODE = 1;
CONSOLE_WINDOWED_MODE = 2;[/color]
var
[color=red] pfnGetConsoleDisplayMode: TFNGetConsoleDisplayMode = nil;
pfnSetConsoleDisplayMode: TFNSetConsoleDisplayMode = nil;[/color]
hKern32:THandle;
newmode: COORD;
hConsole: THandle;
begin
[color=red] hKern32 := GetModuleHandle('kernel32.dll');
if(hKern32 <> 0) then
begin
@pfnGetConsoleDisplayMode := GetProcAddress(hKern32, 'GetConsoleDisplayMode');
@pfnSetConsoleDisplayMode := GetProcAddress(hKern32, 'SetConsoleDisplayMode');[/color]
if(not Assigned(@pfnGetConsoleDisplayMode))then
begin
Writeln('Could not retrieve function pointer for GetConsoleDisplayMode()');
Exit;
end;
if(not Assigned(@pfnSetConsoleDisplayMode))then
begin
Writeln('Could not retrieve function pointer for SetConsoleDisplayMode()');
Exit;
end;
[color=red] end;[/color]
// Retrieve current console
handle
hConsole := GetStdHandle(STD_OUTPUT_HANDLE);
// Wait for input
Write('Press ENTER to switch into fullscreen mode'); Readln;
// Switch mode
if(pfnSetConsoleDisplayMode(hConsole, CONSOLE_FULLSCREEN_MODE, newmode))then
Writeln('Now we should be in fullscreen mode');
// Wait for input
Write('Press ENTER to switch into windowed mode'); Readln;
// Switch mode
if(pfnSetConsoleDisplayMode(hConsole, CONSOLE_WINDOWED_MODE, newmode))then
Writeln('Now we should be in windowed mode');
// Wait for input
Write('Press ENTER to quit'); Readln;
end.