Building a standalone Windows C app

Building a standalone Windows C app

Postby Antonio Linares » Sat Mar 17, 2018 8:19 am

Sometimes we may need to build a small Windows app using C language to solve a specific issue. Here you have how to do it :-)

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  RUN
@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  RUN
#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;
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 3 guests