visual c++ - Understanding a C++ sample - printers, handles, strings -



visual c++ - Understanding a C++ sample - printers, handles, strings -

there few question next code came across here:

// rawdatatoprinter - sends binary info straight printer // // szprintername: null-terminated string specifying printer name // lpdata: pointer raw info bytes // dwcount length of lpdata in bytes // // returns: true success, false failure. // bool rawdatatoprinter(lptstr szprintername, lpbyte lpdata, dword dwcount) { bool bstatus = false; handle hprinter = null; doc_info_1 docinfo; dword dwjob = 0l; dword dwbyteswritten = 0l; // open handle printer. bstatus = openprinter( szprintername, &hprinter, null ); // question 1 if (bstatus) { // fill in construction info "document." docinfo.pdocname = (lptstr)_t("my document"); // question 2 docinfo.poutputfile = null; // question 3 docinfo.pdatatype = (lptstr)_t("raw"); // question 4 // inform spooler document beginning. dwjob = startdocprinter( hprinter, 1, (lpbyte)&docinfo ); // question 5 if (dwjob > 0) { // start page. bstatus = startpageprinter( hprinter ); if (bstatus) { // send info printer. bstatus = writeprinter( hprinter, lpdata, dwcount, &dwbyteswritten); endpageprinter (hprinter); } // inform spooler document ending. enddocprinter( hprinter ); } // close printer handle. closeprinter( hprinter ); } // check see if right number of bytes written. if (!bstatus || (dwbyteswritten != dwcount)) { bstatus = false; } else { bstatus = true; } homecoming bstatus; }

please question number in comments

question 1

when have set hprinter = null meant &hprinter ?

question 2

what (lptstr)_t denote ? (see t )

question 3

what null here denote ?

question 4

what raw mean ( type of info ? ) ?

question 5

what 1 denote here ?

&hprinter address of hprinter variable. need pass openprinter function can write in actual handle printer.

_t takes character string , converts proper ansi (8bits/character) or unicode (16bits/character) representation based on compilation settings. it's macro either expands nil (ansi) or l (unicode) plus actual string.

here where, in code? null macro expands (basically) 0. it's used provide decent default value.

raw info sounds, raw data. it's not structured in way, it's soup of bytes pass (usually) device.

from http://msdn.microsoft.com/en-us/library/dd145115(v=vs.85).aspx:

the version of construction pdocinfo points. value must 1.

c++ visual-c++ printing

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -