Sign in to follow this  
Followers 0
iceberg

Detect Printer Port

6 posts in this topic

Hi,

Is there any way to check in the registry if a PC has a USB001 Printer Port?

Thanks.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites



Is there any way to check in the registry if a PC has a USB001 Printer Port?

Step over the subkeys of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers in the registry and check the Port value under each:

Dim $subKeys, $subKeyName, $portName
While 1
    $subKeys = $subKeys + 1
    $subKeyName = RegEnumKey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers", $subKeys)
    If @error = -1 Then ExitLoop
    $portName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\" & $subKeyName, "Port")
    MsgBox(0, "Debug", $portName)
WEnd

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thanks DaveF. is there any way to do something like this:

if PC has USB001 port then

do something

else

endif

thanks.

Edited by iceberg

mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

Dim $subKeys, $subKeyName, $portName
While 1
    $subKeys = $subKeys + 1
    $subKeyName = RegEnumKey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers", $subKeys)
    If @error = -1 Then ExitLoop
    $portName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\" & $subKeyName, "Port")
    If StringInStr($portName, "USB001") Then
        SmiteAll()
    Else
        Whimper()
    EndIf
WEnd


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Hi,

Is there any way to check in the registry if a PC has a USB001 Printer Port?

Thanks.

<{POST_SNAPBACK}>

if FileExists("USB001:") then
    Msgbox(0,"Found!","USB port found.")
else
    Msgbox(0,"Not Found","USB port NOT found.")
endif

At least this code works with LPT/COM-ports, you could try if it would also works for USB-ports.

Regards,

-Sven

Share this post


Link to post
Share on other sites

DaveF your codes work fine.

SvenP the codes do not recognise USB printer ports.

thanks alot guys!


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0