Título: puertos c++
Publicado por: julyos en 7 Mayo 2005, 18:40 pm
quiero en verdad que me ayuden un poco con el manejo de puertos como aheclr para controlar mi puerto paralelo por un codigo en c++ me gustaria que ma ayudaran con un codigo ejemplo
Título: Re: puertos c++
Publicado por: Griph en 7 Mayo 2005, 19:46 pm
En el sitio http://www.cplusplus.com/src/ hay una aplicación, en código fuente, programada en justamente en C++. Es un programa para controlar la impresora (por consiguiente el puerto paralelo), te decía este sitio porque casualmente ayer en la noche yo estuve vajando algunos códigos. Griph PD: no te pego acá el código fuente porque es muy extenso, mejor bajálo vos (esta un fichero comprimido bajo el algoritmo zip). Edito el post y te pego el código fuente: /********************************************************************* * * hwprint.cpp by Tom Lee * * Example program to demonstrate printing using the Win32 API/GDI. * I'm new to printing with the Win32 GDI myself (although I've * used the GDI heaps before for gfx etc.) - I've been * trying for a long time to find useful info on the Internet * about this very thing, but came across next to nothing. * I thought it'd be a disservice to the Internet not to get * something about printing with Win32/GDI out the door ASAP! * * ------------------------------------------------------------------- * * Libraries to link in: * * kernel32.lib, user32.lib, gdi32.lib, comdlg32.lib * ********************************************************************/
#include <windows.h>
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow ) { PRINTDLG pd;
memset( &pd, 0, sizeof( pd ) );
pd.lStructSize = sizeof( pd );
/* * get rid of PD_RETURNDEFAULT on the line below if you'd like to * see the "Printer Settings" dialog! * */ pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
// try to retrieve the printer DC if( !PrintDlg( &pd ) ) { MessageBox( NULL, "PrintDlg( &pd ) failed!", "Fatal Error", MB_OK | MB_ICONERROR );
return -1; }
DOCINFO di; HDC hPrinter = pd.hDC;
// initialization of the printing! memset( &di, 0, sizeof( di ) ); di.cbSize = sizeof( di ); StartDoc( hPrinter, &di );
// start the first and only page StartPage( hPrinter );
// uncomment the following line to print in colour! :) // SetTextColor( hPrinter, 0x0000FF );
// write "Hello, World!" to the printer's DC TextOut( hPrinter, 100, 100, "Hello, World!", 13 );
// finish the first page EndPage( hPrinter );
// end this document and release the printer's DC EndDoc( hPrinter ); DeleteDC( hPrinter );
return 0; }
Título: Re: puertos c++
Publicado por: oosathiray en 6 Marzo 2015, 08:49 am
código fuente porque es muy extenso, mejor bajálo vos ???
|