PxPlus User Forum

Twitter Twitter Twitter

Author Topic: How to find the "Location" property of a Windows printer  (Read 1383 times)

PxPlus

  • Administrator
  • Diamond Member
  • *****
  • Posts: 1091
    • View Profile
How to find the "Location" property of a Windows printer
« on: May 31, 2018, 09:41:14 AM »
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