Home > Back-end >  C connect printer to print pictures
C connect printer to print pictures

Time:09-17

HDC hdcPrint;//printer dc controller
TCHAR szDevString [120].//array for the WIN. INI data
SzPrinter TCHAR * and * szDriver;//printer and driver name
TCHAR * szPort;//port name
TCHAR * nextChar;

//retrieve printer, printer drivers and
//from WIN. INI output port name,

GetProfileString (_T (" Windows "), _T (" device "), _T (,,, ""),
SzDevString, 120);

//parse the name list, according to the need to set up PTRS
//if the string contains the name of the required, please use them
//create a device context,

If ((szPrinter=_tcstok_s (szDevString,
_T (", "), & nextChar))
& & (szDriver=_tcstok_s (NULL,
_T (", "), & nextChar))
& & (szPort=_tcstok_s (NULL,
_T (", "), & nextChar)))
{
HdcPrint=CreateDC (szDriver szPrinter,
SzPort, NULL);
}

//print contains the string test page
//"printer test" in the upper left corner,

The Escape (hdcPrint, STARTDOC, 8, "Test - Doc", NULL);
TextOut (hdcPrint, 50, 50, _T (" PRINTER TEST "), 12);
The Escape (hdcPrint NEWFRAME, 0, NULL, NULL);
The Escape (hdcPrint ENDDOC, 0, NULL, NULL);

//remove printers DC,
DeleteDC (hdcPrint);

The above code I have test to use, but according to the result is printed out a line of text, what I need now is to print out a picture, I hope god can help me with,

CodePudding user response:

If it's convenient for you can add my QQ 568997743 set the problem solved with ChongXie
  • Related