kepler
Mar 16th, 2006, 11:22 AM
Hi,
Can someone tell me how can I detect in VB if one ( or at least one ) computer is connected to my computer? I have a host computer and a small one connected to the first; I want to know if the connection is active or not, if the cable is disabled or not.
Kind regards,
Kepler
t_mann
Mar 16th, 2006, 12:38 PM
This might help: start>run>cmd and type netstat -a. This will dysplay all active connections, listening ports, and so on. For more information about netstat just type netstat -? . OK, now how to get this in visual basic:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute Me.hwnd, "Open", "CMD.exe", " /K netstat -a > C:\ip.txt", "C:\", 0
This will put the results from your command promp in a file so u can use the data.
Of course there might be an easier way, but I recently used this method in a program and it worked fine.
the182guy
Mar 16th, 2006, 05:02 PM
there is a lot of examples of how to do this on pscode.com/vb where it does it via API and not saving to a file first