Visual C + + PRINT programming technology-programming basics-Getting a printer

Source: Internet
Author: User
Tags print object

The standard method is to use the: EnumPrinters () function to obtain

#define Printer_enum_default     0x00000001#define printer_enum_local       0x00000002#define printer_enum_ CONNECTIONS 0x00000004#define printer_enum_favorite    0x00000004#define printer_enum_name        0x00000008#define Printer_enum_remote      0x00000010#define printer_enum_shared      0x00000020#define printer_enum_network     0x00000040

  

BOOL enumprinters (  _in_   DWORD Flags,//Printer get method, see above table   _in_   LPTSTR Name,  _in_   DWORD level,// printer_info_1, printer_info_2 , printer_info_4, and printer_info_5 respectively correspond to 1,2,4,5< C10/>_out_  lpbyte pprinterenum,//a Pointer to A buffer this receives an array of printer_info_1, prin Ter_info_2, printer_info_4, orprinter_info_5 structures.                             Each structure contains data, describes an available print object.  _in_   DWORD cbbuf,//the size, in bytes, of the buffer pointed to by Pprinterenum.  _out_  Lpdword pcbneeded,  _out_  lpdword pcreturned);

  

DWORD dwsize,dwprinters;::enumprinters (printer_enum_local,null,5,null,0,&dwsize,&dwprinters); byte* pbuffer=new byte[dwsize];::enumprinters (printer_enum_local,null,5,pbuffer,dwsize,&dwsize,& Dwprinters), if (dwprinters!=0) {printer_info_5* pprninfo= (printer_info_5*) pbuffer;for (UINT i=0;i<dwprinters;i++ ) {M_listbox. AddString (Pprninfo->pprintername); M_listbox:listbox control variable                        pprninfo++;}}    Delete[] pbuffer;

  

Visual C + + PRINT programming technology-programming basics-Getting a printer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.