Csdn Q & A: Installing a printer in VB6

Source: Internet
Author: User

Install a new printer on the system:

Http://www.devx.com/vb2themax/Tip/19284

Private type printer_info_2 pservername as string pprintername as string psharename as string pportname as string pdrivername as string pcomment as string plocation as string pdevmode as long enough pfile as string pprintprocessor as string pdatatype as string pparameters as bytes as long attributes as long priority as long defaultpriority as long starttime as long untiltime as long status as long cjobs as long averageppm as longend typeprivate declare function addprinter lib "winspool. DRV "alias" addprintera "_ (byval pname as string, byval level as long, pprinter as any) as longprivate declare function closeprinter lib" winspool. DRV "(byval hprinter AS _ long) as long 'Install a new printer on the system' sprintername is the name to assign to identify the printer 'sdriver is a string identifying the driver for the printer 'sport is the printer's com port 'scomment is a comment to associate to the printer item' 'example: 'dim Bok as Boolean 'Bok = installprinter ("Epson", "Epson stylus color 440", "LPT1:",' "my favorite printer") 'msgbox "Printer added: "& bokfunction installprinter (byval sprintername as string, byval sdriver as string, _ optional byval sport as string =" LPT1: ", optional sserver as string, _ optional scomment as string) as Boolean dim hprinter as long dim PI as printer_info_2 'fill the printer_info_2 struct with pi. pprintername = sprintername. pdrivername = sdriver. pportname = sport. pservername = sserver. pcomment = scomment. pprintprocessor = "winprint ". priority = 1. defaultpriority = 1. pdatatype = "Raw" end with 'add the printer hprinter = addprinter (sserver, 2, Pi) 'If successful close the printer and return true if hprinter <> 0 then closeprinter hprinter installprinter = true end ifend Function

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.