Google found
this for me:
Code:
#define PRINTDRIVER
#include <windows.h>
#include <string.h>
#include <print.h>
#include <stdio.h>
int PrintHPFile( const char *filename )
{
char *pszPrInfo = new char[ 80 ];
// Get the printer setup string from the ini file
GetProfileString( "windows", "device", ",,,", pszPrInfo, 80 );
// Format of ini file line = <Device,Driver,Port>
char *pszDevice = strtok( pszPrInfo, "," );
char *pszDriver = strtok( NULL, "," );
char *pszPort = strtok( NULL, "," );
// create a printer device context
HDC PrintHandle = CreateDC( pszDriver, pszDevice, pszPort,
NULL );
// get a job handle, allocate a buffer
HPJOB PrintJob;
char *buf = new char[ 1024 ];
// open the file for reading
FILE *hp_file = fopen( filename, "rb" );
// Start the print job
PrintJob = OpenJob( pszPort, filename, (HPJOB)PrintHandle );
StartSpoolPage( PrintJob );
// print the file, 1K at a time
for( size_t i(0);; )
{
i = fread( buf, 1, 1023, hp_file );
if( i>0 )
WriteSpool( PrintJob, buf, i );
else
break;
}
// Close up print job
EndSpoolPage( PrintJob );
CloseJob( PrintJob );
// Clean up
DeleteDC( PrintHandle );
fclose( hp_file );
delete[] pszPrInfo;
delete[] buf;
return 1;
}