在PB程序中如何设置打印机?

在PB程序中如何设置打印机?//先定义局部函数如下:FUNCTIONulongGetWindowsDirectoryA(refstringwdir,ulongbuf)LIBRARY”kernel32.dll”//内部变量stringis_winpathfile//编写读取已经安装的打印机清单:stringls_WindowsDirctoryulonglu_Bufboo

//先定义局部函数如下:


FUNCTION ulong GetWindowsDirectoryA(ref string wdir, ulong buf) LIBRARY “kernel32.dll”

//内部变量

string is_winpathfile

//编写读取已经安装的打印机清单:

string ls_WindowsDirctory

ulong lu_Buf

boolean lb_PrinterExists

string ls_printer,ls_tmp,ls_printers[]

int li_point

integer li_rtn,li_ArrayUp,li_step
lu_Buf = 144


ls_WindowsDirctory = Space(144)

//得到系统目录

GetWindowsDirectoryA(ls_WindowsDirctory,lu_Buf)

is_winpathfile = ls_WindowsDirctory + “/win.ini”

//判断系统是否安装打印机

li_rtn = RegistryKeys(“HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/Print/Printers”, ls_printers)

IF li_rtn = 1 THEN

li_ArrayUp = UpperBound(ls_printer)

IF li_ArrayUp >= 1 THEN

FOR li_step = 1 TO li_ArrayUp

ddlb_printers.additem ( ls_Printer[li_step] )

lb_PrinterExists = true

NEXT

else

lb_PrinterExists = false

end if

else

lb_PrinterExists = false

end if

IF NOT lb_PrinterExists THEN

messagebox (“提示!”,”尚未安装打印机!”)

ELSE

ls_tmp = profilestring (is_winpathfile,”windows”,”device”,””)

ls_tmp = trim (ls_tmp)

li_point = pos (ls_tmp,”,”,1)

ls_printer = left (ls_tmp,li_point – 1)

IF trim (ls_printer) <> “” AND NOT IsNull (ls_printer) THEN

ddlb_printers.text = trim (ls_printer)

ELSE

ddlb_printers.selectitem (1)

END IF

END IF

//在selectchanged事件中编程:

string ls_printer

ls_printer = profilestring(is_winpathfile,”Devices”,trim(this.text (index)),””)

//修改win.ini文件

setprofilestring(is_winpathfile,”windows”,”device”,trim(this.text (index)) + “,” +ls_printer)

//修改注册表文件

RegistrySet(“HKEY_CURRENT_CONFIG/System/CurrentControlSet/Control/Print/Printers”,”Default”, trim(this.text))
 
 
 
BY  tisnly
 

  

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/35933.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注