;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; for CoCreate SolidDesigner ;; Description: ;; inquire GDI printer names from Windows Operating System ;; GDI Drucker von Windows abfragen ;; ;; Reference : https://ww3.cad.de/foren/ubb/Forum92/HTML/001041.shtml ;; Docu : https://support.ptc.com/help/creo_elements_direct/r20.7.0.0/advanced_documentation/integration_kit/reference/filing_and_os.html ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Filename : cadde-92-001041.lsp ;; Version : 1.0 initial-version by Seele ;; : 1.1 unified version by der_Wolfgang ;; Created : Tue Mar 25 10:24:38 CET 2025 ;; Modified : Tue Mar 25 16:07:02 CET 2025 ;; Author : der_Wolfgang@forum@cad.de ;; Download : cad.de ? ;; SD-Version : developed with PE80 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :oli) (export 'sd-inq-gdi-printer-names) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; get printer names from the OS via system command ;; parameter: none ;; return: printer names as list of strings (not mandatory sorted) ;; ;; using a system command is always a little slow. Don't call it too often ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun sd-inq-gdi-printer-names () "returns printer names from the OS via system command: list of (unsorted) strings" (let ((printer-names-tmp-file (format nil "~Asd-gdi-printer-names.txt" (sd-inq-temp-dir))) (clear-chars (format nil " ~A~A" (code-char 10) #| MAC OS line end |# (code-char 13) #| windows line end |#)) printer-names ) (sd-sys-exec (format nil "wmic printer get Name > \"~A\"" (sd-convert-filename-to-platform printer-names-tmp-file))) (when (> (sd-inq-file-size printer-names-tmp-file) 0) ;; something useful was written to file? (with-open-file (instream printer-names-tmp-file :direction :input) (loop for input-line = (read-line instream nil) while input-line do (push (string-trim clear-chars input-line) printer-names) ;; remove any mad characters );endloop ); with-open-file (when printer-names ;(setq printer-names (rest (nreverse printer-names))) ;; skip the header line in file (setq printer-names (nbutlast printer-names)) ;; skip the header line in file ) ) ;; end when file was written (when (sd-inq-file-status printer-names-tmp-file :existence) (delete-file printer-names-tmp-file)) ;; cleanup printer-names ;; return value der funktion )) ;; end let+defun ;;; test: ;(setq my-printers (oli:sd-inq-gdi-printer-names)) (pprint my-printers)