#include <windows.h>#include <windowsx.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <time.h>#include <process.h>Include dependency graph for gvwin.h:

Go to the source code of this file.
Defines | |
| #define | MAXSTR 256 |
Functions | |
| int | gp_printfile (HINSTANCE hInstance, HWND hwnd, char *filename, char *port) |
| int gp_printfile | ( | HINSTANCE | hInstance, | |
| HWND | hwnd, | |||
| char * | filename, | |||
| char * | port | |||
| ) |
Definition at line 54 of file gvwprn.c.
Referenced by main(), and PrintPs().
00055 { 00056 DWORD count; 00057 char *buffer; 00058 char portname[MAXSTR]; 00059 FILE *f; 00060 HANDLE printer; 00061 DOC_INFO_1 di; 00062 DWORD written; 00063 00064 if (!get_queuename (hInstance, hwnd, portname, port)) return FALSE; 00065 port = portname + 8; /* skip over \\spool\ */ 00066 00067 if ((buffer = MALLOC (PRINT_BUF_SIZE)) == (char *) NULL) return FALSE; 00068 if (filename != (char *) 0) 00069 { 00070 if ((f = fopen (filename, "rb")) == (FILE *) NULL) 00071 { 00072 FREE (buffer); 00073 return FALSE; 00074 } 00075 } 00076 else 00077 f = stdin; 00078 00079 /* open a printer */ 00080 if (!OpenPrinter (port, &printer, NULL)) 00081 { 00082 sciprint (MSG_ERROR71, port, GetLastError ()); 00083 FREE (buffer); 00084 return FALSE; 00085 } 00086 /* from here until ClosePrinter, should AbortPrinter on error */ 00087 00088 di.pDocName = filename; 00089 di.pOutputFile = NULL; 00090 di.pDatatype = "RAW"; /* for available types see EnumPrintProcessorDatatypes */ 00091 if (!StartDocPrinter (printer, 1, (LPBYTE) & di)) 00092 { 00093 sciprint (MSG_ERROR72, GetLastError ()); 00094 AbortPrinter (printer); 00095 FREE (buffer); 00096 return FALSE; 00097 } 00098 00099 while ((count = fread (buffer, 1, PRINT_BUF_SIZE, f)) != 0) 00100 { 00101 if (!WritePrinter (printer, (LPVOID) buffer, count, &written)) 00102 { 00103 FREE (buffer); 00104 fclose (f); 00105 AbortPrinter (printer); 00106 return FALSE; 00107 } 00108 } 00109 fclose (f); 00110 FREE (buffer); 00111 00112 if (!EndDocPrinter (printer)) 00113 { 00114 sciprint (MSG_ERROR73, GetLastError ()); 00115 AbortPrinter (printer); 00116 return FALSE; 00117 } 00118 00119 if (!ClosePrinter (printer)) 00120 { 00121 sciprint (MSG_ERROR74, GetLastError ()); 00122 return FALSE; 00123 } 00124 return TRUE; 00125 }
Here is the caller graph for this function:

1.5.1