Dit is de code waar (een) foutje(s) is ingeslopen.
-----------------------------------------------------------------
#define PRINTDRIVER
#include <windows.h>
#include <string.h>
#include <print.h>
#include <stdio.h>
int PrintHPFile(char *filename);
int main(void)
{
FILE *bestand;
bestand = fopen ("bes5.txt","w+");
PrintHPFile(bestand);
return 0;
}
int PrintHPFile(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;
}
Dit zijn mijn problemen:
1) print.cpp 13 : cannot convert 'FILE *' to 'char *' in function main
2) print.cpp 13 : type mismatch in parameter 'filename' in call to 'PrintHPFile(char *)' in function main()
Thx op voorhand
waxxie
-----------------------------------------------------------------
#define PRINTDRIVER
#include <windows.h>
#include <string.h>
#include <print.h>
#include <stdio.h>
int PrintHPFile(char *filename);
int main(void)
{
FILE *bestand;
bestand = fopen ("bes5.txt","w+");
PrintHPFile(bestand);
return 0;
}
int PrintHPFile(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;
}
Dit zijn mijn problemen:
1) print.cpp 13 : cannot convert 'FILE *' to 'char *' in function main
2) print.cpp 13 : type mismatch in parameter 'filename' in call to 'PrintHPFile(char *)' in function main()
Thx op voorhand
waxxie