Break on
If primapstate("\\MyServer\Konica Bizhub C554E")
? "Printer Exists"
Else
? "Printer does not exist"
EndIf
Sleep 5
;FUNCTION PriMapState
;
;AUTHOR Lonkero (Jooel.Nieminen@gwspikval.com)
;
;ACTION Checks for existent networkprinter connection
;
;VERSION 1.1.1
;
;CHANGES 1.1.1 - 01. november 2003
; Fixed buggie descriped in:
; http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=008079
; 1.1 - 02. July 2002
; added support for win9x
; 1.0 - 01. July 2002
; initial release
;
;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
;
;REMARKS code for w9x adapted from BrianTX
;
;DEPENDENCIES none
;
;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