A veces podemos necesitar construir una pequeña aplicación en Windows usando el lenguaje C para solucionar un tema específico. Aquí teneis como hacerlo
Simply do go.bat changeres (don't specify the .c extension)
Simplemente haz go.bat changeres (no especifiques la extensión .c)
go.bat
- Code: Select all Expand view
- @ECHO OFF
set bcdir=c:\bcc7
%bcdir%\bin\bcc32 -c -I%bcdir%\include %1.c
IF EXIST %1.rc %bcdir%\bin\brc32 -r %1
echo %bcdir%\lib\c0w32.obj + > b32.bc
echo %1.obj, + >> b32.bc
echo %1.exe, + >> b32.bc
echo %1.map, + >> b32.bc
echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib, >> b32.bc
IF EXIST %1.res echo %1.res >> b32.bc
%bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v -L%bcdir%\lib @b32.bc
%1.exe
changeres.c
- Code: Select all Expand view
- #include <windows.h>
#include <stdio.h>
#pragma argsused
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow )
{
DEVMODE dm;
FILE * pFile = fopen( "resolution.txt", "w" );
dm.dmSize = sizeof( DEVMODE );
EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &dm );
fwprintf( pFile, L"%d x %d\n", dm.dmPelsWidth, dm.dmPelsHeight );
fclose( pFile );
dm.dmPelsWidth = 800;
dm.dmPelsHeight = 600;
ChangeDisplaySettings( &dm, DM_PELSWIDTH || DM_PELSHEIGHT );
return 0;
}