How to find the "Location" property of a Windows printer

Started by PxPlus, May 31, 2018, 09:41:14 AM

Previous topic - Next topic

PxPlus

For the "location" of a Windows printer you need to read the following registry entry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\<printer name>\Location

Where <printer name> is the name of the printer.

You can use the following logic in your programs to get this value:

LET OBJ_WINAPI=NEW("*obj/winapi")
LET REGKEY$="HKEY_LOCAL_MACHINE"
LET REGSUBKEY$="SOFTWARE\Microsoft\Windows NT\" +
      "CurrentVersion\Print\Printers\"
!
! Add the printer name you got from WINPRT_SETUP LIST
!
LET REGSUBKEY$+="hp psc 1200 series"
LET NAME$="Location"
OBJ_WINAPI'GETREGISTRYVALUE(REGKEY$,REGSUBKEY$,NAME$,VALUE$)
!
PRINT "Location is:",VALUE$
!
DROP OBJECT OBJ_WINAPI