;================================================
;Define udf function here
;================================================
;FUNCTION PriMapState
;AUTHOR Lonkero (Jooel.Nieminen@gwspikval.com)
;ACTION Checks for existent networkprinter connection
;VERSION 1.1.1
;SYNTAX PriMapState(PRINTER)
;PARAMETERS PRINTER
; to be checked Printer's name
;
;RETURNS 1 if printer connected
; 2 if printer is default
; nothing if not connected
;EXAMPLE
; if not PriMapState('\\server\printer1')
; "printer1 not connected!"
; endif
;
;CODE
function PriMapState($_Pri)
if @inwin=1
if len(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices",$_Pri))
if split(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]=$_Pri
$PriMapState=2
else
$PriMapState=1
endif
endif
else
dim $_Root,$_C,$_C2 $_Root="HKLM\System\CurrentControlSet\control\Print\Printers"
for $_C=0 to 259
$_C2=enumkey($_Root,$_C)
If instr(READVALUE($_Root+"\"+$_C2,"Port"),$_Pri)
If instr(READPROFILESTRING("%windir%\win.ini","windows","device"),$_Pri)
$PriMapState = 2
Else
$PriMapState = 1
Endif
Endif
if $_C2=259 $_C=$_C2 endif
next
endif
endfunction