|
-
May 3rd, 2001, 09:55 PM
#1
Thread Starter
Member
pinging a list of addresses...
i have a treeview which will contain names of sites pinged. When the form loads, i want to ping this list of sites to see which ones replies and which ones don't.
the treeview looks like this...
username
Online
....yahoo
....hotmail
Offline
....google
....lycos
the node that says "Online" is called n1
this is what i do to add one online site...
call this sub
Dim hFile As Long, lpWSAdata As WSAdata
Dim hHostent As Hostent, AddrList As Long
Dim Address As Long, rIP As String
Dim OptInfo As IP_OPTION_INFORMATION
Dim EchoReply As IP_ECHO_REPLY
Call WSAStartup(&H101, lpWSAdata)
If GetHostByName(hostname + String(64 - Len(hostname), 0)) <> SOCKET_ERROR Then
CopyMemory hHostent.h_name, ByVal GetHostByName(hostname + String(64 - Len(hostname), 0)), Len(hHostent)
CopyMemory AddrList, ByVal hHostent.h_addr_list, 4
CopyMemory Address, ByVal AddrList, 4
End If
hFile = IcmpCreateFile()
If hFile = 0 Then
strreply = "Unable to Create File Handle"
Exit Sub
End If
OptInfo.TTL = 255
If IcmpSendEcho(hFile, Address, String(32, "A"), 32, OptInfo, EchoReply, Len(EchoReply) + 8, 2000) Then
rIP = CStr(EchoReply.Address(0)) + "." + CStr(EchoReply.Address(1)) + "." + CStr(EchoReply.Address(2)) + "." + CStr(EchoReply.Address(3))
Else
strreply = "Timeout"
End If
If EchoReply.Status = 0 Then
strreply = "yes"
Else
strreply = "Failure ..."
End If
Call IcmpCloseHandle(hFile)
Call WSACleanup
then, i add them based on what "strreply" is
so i have
Private Sub Form_Load()
Set n1 = TreeView1.Nodes.Add(, 1, "new", "new", 2, 2)
n1.Bold = True
n1.Text = "Online"
const hostname = "www.yahoo.com"
call ping
if strreply = "yes" then
treeview1.nodes.add(n1, 4, [key], [text])="Yahoo.com"
end if
Now finally the question....
when i use a loop or a for statement to run the ping sub over again, i need to change const hostname to the name of the different sites (of course) but, when i do that vb tells me:
compile error duplicate declaration in current scope
how can i get rid of this?
-emptywords
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|