19-01-2005, 09:27
|
|
|
חבר מתאריך: 29.09.02
הודעות: 208
|
|
אולי..
הנה חתיכת קוד שאולי תעזור לך. אני אישית לא יודע.
קוד:
// Include files
#include <iostream.h>
#include <fstream.h>
#include <string.h>
// Constants (may vary from system to system)
const char PRINTER_PREFIX[] = "\\\\WNT2\\";
const int MAX_PRINTER_NAME = 20;
const int MAX_FILE_NAME = 256;
// Function prototypes
void Open_Files( ifstream &, ofstream & );
void main()
{
ofstream Printer;
ifstream PrintFile;
char Ch;
Open_Files( PrintFile, Printer );
if ( Printer && PrintFile )
{
while ( PrintFile.get( Ch ) )
Printer << Ch;
Printer << "\f"; // eject last page
}
else
if ( ! Printer )
cout << "Unable to open printer.\n";
else
cout << "Unable to open file.\n";
}
void Open_Files( ifstream & FileOnDisk, ofstream & Printer )
{
char PrinterName[MAX_PRINTER_NAME + sizeof(PRINTER_PREFIX)];
char FileName[MAX_FILE_NAME];
char Ch;
int Pos;
// Get printer name and open output stream to printer.
strcpy( PrinterName, PRINTER_PREFIX );
do {
cout << "Printer name (or *CANCEL*): ";
// Place rest of printer name after prefix.
for ( Pos = sizeof(PRINTER_PREFIX)-1;
Pos < sizeof(PrinterName);
++Pos )
{
cin.get( Ch );
if ( Ch == '\n' || Ch == '*' )
break;
PrinterName[Pos] = Ch;
}
PrinterName[Pos] = '\0';
if ( Ch == '*' )
{
cin.ignore( 100, '\n' );
return;
}
Printer.open( PrinterName );
} while ( ! Printer );
do {
cout << "Enter filename: ";
cin.getline( FileName, MAX_FILE_NAME );
if ( strcmp( FileName, "*CANCEL*" ) == 0 )
return;
FileOnDisk.open( FileName );
} while ( ! FileOnDisk );
}
נערך לאחרונה ע"י יהונתן בתאריך 19-01-2005 בשעה 09:29.
|