|
-
Aug 3rd, 2000, 08:04 AM
#4
New Member
Remote MAC Address for Windows NT
Create a new project. Put one command button and one listbox and one text box into the form. Don't change the names of the controls. If you have a remote machine with Windows NT on it and your machine is also NT you will need only the hostname from the remote machine. Put that into the text box and run the program.
Hope it helps!
Option Explicit
Private Declare Function NetWkstaTransportEnum Lib "netapi32" ( _
Servername As Any, _
ByVal Level As Long, _
Bufptr As Long, _
ByVal Prefmaxlen As Long, _
Entriesread As Long, _
Totalentries As Long, _
Resumehandle As Long) As Long
Private Declare Function lstrlenW Lib "kernel32" ( _
ByVal lpString As Long) As Long
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long)
Private Declare Function NetApiBufferFree Lib "Netapi32.dll" ( _
ByVal lpBuffer As Long) As Long
Private Type WKSTA_TRANSPORT_INFO_0
wkti0_quality_of_service As Long
wkti0_number_of_vcs As Long
wkti0_transport_name As Long
wkti0_transport_address As Long
wkti0_wan_ish As Long
End Type
Private Sub Command1_Click()
Dim Servername() As Byte
Dim Level As Long
Dim Prefmaxlen As Long
Dim Result As Variant
Dim sResult As Variant
Dim sBufptr As WKSTA_TRANSPORT_INFO_0
Dim Bufptr As Long
Dim Entriesread As Long
Dim Totalentries As Long
Dim Resumehandle As Long
Dim Buffer() As Byte
Dim nLen As Long
Dim A As Long
Dim L As Long
List1.Clear
Prefmaxlen = -1
Level = 0
Servername = "\\" & Text1.Text & vbNullChar
Result = NetWkstaTransportEnum(Servername(0), Level, Bufptr, Prefmaxlen, Entriesread, Totalentries, Resumehandle)
If L = 0 Or L = 234& Then
For A = 0 To Entriesread - 1
CopyMem sBufptr, ByVal Bufptr, Len(sBufptr)
Debug.Print PtrToString(sBufptr.wkti0_transport_address)
Bufptr = Bufptr + Len(sBufptr)
Next A
End If
NetApiBufferFree Bufptr
End Sub
Private Function PtrToString(lpwString As Long) As String
Dim Buffer() As Byte
Dim nLen As Long
If lpwString Then
nLen = lstrlenW(lpwString) * 2
If nLen Then
ReDim Buffer(0 To (nLen - 1)) As Byte
CopyMem Buffer(0), ByVal lpwString, nLen
PtrToString = Buffer
List1.AddItem (Buffer)
End If
End If
End Function
May the force be with you!
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
|