以原始VL库函数来读取打印设备名称:
- (defun c:printer (/ index l lst k)
- ;lisperado
-
- (defun index (l n / x)
- (if (> n 0)
- (cons (cons (itoa (- (length l) (setq x (1- n)))) (nth x l)) (index l x))
- )
- )
-
- (textscr)
- (if (and (setq l (vl-registry-descendents
- "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"
- )
- )
- (setq lst (index l (length l)))
- )
- (progn (initget (apply 'strcat (mapcar '(lambda (x) (strcat (car x) " ")) lst)))
- (setq k (getkword
- (apply 'strcat
- (cons "\n可用打印设备,Select printer \n" (mapcar '(lambda (x) (strcat "[" (car x) "]=" (cdr x) " \n")) lst))
- )
- )
- )
- (princ (cdr (assoc k lst)))
- )
- (princ "\n抱歉!执行失败!")
- )
- (terpri)
- (princ)
- )
输入索引 1,2,3 等等。。比输入名称更快捷吧?
|