rocket24
asked on
Using Netbios (nbtstat -A or -a) through Visual Basic
Hello Experts
Is it possible to run the Netbios command thorugh VB instead of using nbtstat in DOS or typing //whatever in explorer
Thanks in advance
rocket24
Is it possible to run the Netbios command thorugh VB instead of using nbtstat in DOS or typing //whatever in explorer
Thanks in advance
rocket24
Here's an API example that gets MAC Address:
http://www.mvps.org/vbnet/index.html?code/network/macaddress.htm
http://www.mvps.org/vbnet/index.html?code/network/macaddress.htm
ASKER
Thanks thats intresting code but what I meant is that my program would have a text box and a command button.
The text box would be where the IP address is entered and the command button would connect to it (if the shares were active) and open it in explorer like on a network when you open explorer and type "\\127.0.0.1" or something in the address bar and then the shares are displayed.
Thanks again
rocket24
The text box would be where the IP address is entered and the command button would connect to it (if the shares were active) and open it in explorer like on a network when you open explorer and type "\\127.0.0.1" or something in the address bar and then the shares are displayed.
Thanks again
rocket24
nbtstat is for checking NetBios session information not for veiwing what shares are present on a computer. Why re-invent the wheel here. If you want to see what shares are available just right click on my computer choose manage and then connect to the other computer and expand the shared folders and look at shares.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks vinnyd79 although your code didn't work until I replaced the API with this one.
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
Thanks everyone
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
Thanks everyone
ASKER
I do realise that that is the same code as vinnyd79 but i kept getting syntax errors before the code was neatly formatted.
here is an example using a command button and a listbox:
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Sub ShellWait(ByVal JobToDo As String)
Dim hProcess As Long, RetVal As Long
hProcess = OpenProcess(&H400, False, Shell(JobToDo, vbHide))
Do
GetExitCodeProcess hProcess, RetVal
DoEvents: Sleep 100
Loop While RetVal = &H103
End Sub
Private Sub Command1_Click()
Dim Ln As String, IpAddress As String
Dim ff As Integer
' change ip address to the ip or machine name to check
IpAddress = "192.168.1.100"
' shell and wait for command to complete.
ShellWait Environ("Comspec") & " /c nbtstat -A " & IpAddress & " > TmpUsr.tmp"
List1.Clear
ff = FreeFile
Open "TmpUsr.tmp" For Input As #ff
Do Until EOF(ff)
Line Input #ff, Ln
If Trim$(Ln) <> "" Then
List1.AddItem Ln
End If
Loop
Close #ff
Kill "TmpUsr.tmp"
End Sub