1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <windows.h>
#include <wincon.h>
#include <winspool.h>
#include <stdio.h>
#include <stdlib.h>
DOC_INFO_1 docinfo1;
char docname[] = "Crap face";
char outputfile[] = "testingout";
char datatype[] = "RAW";
int print_handle = 0;
int bytes_written;
char string[] = "This is a test...\n1... 2... 3...\n\f";
int temp;
char portname[] = "HP Deskjet 3900 Series";
HANDLE conhandle;
COORD consize = {80, 50};
SMALL_RECT conwinsize = {0, 0, 80-1, 50-1};
int main(){
conhandle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTitle("Printer test!");
SetConsoleScreenBufferSize(conhandle, consize);
SetConsoleWindowInfo(conhandle, TRUE, &conwinsize);
WriteConsole(conhandle, "Test!\n", 12, &temp, NULL);
printf("1...\n");
printf("2...\n");
printf("3...\n");
printf("4...\n");
system("PAUSE");
OpenPrinter(portname, &print_handle, NULL);
printf("Handle: 0x%08X\n", print_handle);
if(print_handle == 0){
printf("Crap!\n");
system("PAUSE");
return 0;
}
docinfo1.pDocName = docname;
docinfo1.pOutputFile = outputfile;
docinfo1.pDatatype = datatype;
temp = StartDocPrinter(print_handle, 1, &docinfo1);
printf("%i ");
temp = StartPagePrinter(print_handle);
printf("%i");
temp = WritePrinter(print_handle, string, strlen(string), &bytes_written);
printf("%i\n");
printf("Bytes written: %i\n", bytes_written);
system("PAUSE");
printf("EndPagePrinter()\n");
EndPagePrinter(print_handle);
system("PAUSE");
printf("EndDocPrinter()\n");
EndDocPrinter(print_handle);
system("PAUSE");
printf("ClosePrinter()\n");
ClosePrinter(print_handle);
system("PAUSE");
return 0;
}
|