• 0

VBA Port Scanning?


Question

Hey guys. I have a port scanning script that should work:

Private Function IsOutsidePortinUse(ByVal PortNumber As Integer) As Boolean
Dim oSocket As Object
Dim bAns As Boolean
On Error Resume Next
Set oSocket = CreateObject("MSWinsock.Winsock.1")
    If Err.Number > 0 Then
        Err.Raise 30000, , "Could not create winsock object"
        Exit Function
    End If
Err.Clear
oSocket.RemoteHost = "74.125.237.80"
oSocket.RemotePort = PortNumber
oSocket.Connect
bAns = Err.Number = 10048 'port is busy
oSocket.Close
Set oSocket = Nothing
IsPortinUse = bAns
End Function

but it always returns false? Does anyone know why?

Link to comment
https://www.neowin.net/forum/topic/1006758-vba-port-scanning/
Share on other sites

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.