[DllImport("netapi32.dll", SetLastError=true)]
static extern TODO NetFileEnum(TODO);
Declare Function NetFileEnum Lib "netapi32.dll" ( _
ByVal servername As String, _
ByVal basepath As String, _
ByVal username As String, _
ByVal level As Integer, _
ByRef bufptr As IntPtr, _
ByVal prefmaxlen As Integer, _
ByRef entriesread As Integer, _
ByRef totalentries As Integer, _
ByVal resume_handle As IntPtr) As Integer
(one of 3 valid types)
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=4)> _
Structure FILE_INFO_3
Dim fi3_id As Integer
Dim fi3_permission As Integer
Dim fi3_num_locks As Integer
Dim fi3_pathname As String
Dim fi3_username As String
End Structure
Definition from the API
'NET_API_STATUS NetFileEnum(
' LPWSTR servername,
' LPWSTR basepath,
' LPWSTR username,
' DWORD level,
' LPBYTE* bufptr,
' DWORD prefmaxlen,
' LPDWORD entriesread,
' LPDWORD totalentries,
' PDWORD_PTR resume_handle
');
Please add some!
Const MAX_PREFERRED_LENGTH As Integer = -1
Dim dwIndex, dwStatus, dwReadEntries, dwTotalEntries As Integer
Dim pCurrent As FILE_INFO_3
Dim iPtr, pBuffer As IntPtr
dwStatus = NetFileEnum(TextBox1.Text, Nothing, Nothing, 3, pBuffer, MAX_PREFERRED_LENGTH, dwReadEntries, dwTotalEntries, Nothing)
if dwStatus = 0 then
For dwIndex = 0 To dwReadEntries - 1
iPtr = New IntPtr(pBuffer.ToInt32 + (dwIndex * Len(pCurrent)))
pCurrent = CType(Marshal.PtrToStructure(iPtr, GetType(FILE_INFO_3)), FILE_INFO_3)
'Debug.WriteLine("dwIndex=" & dwIndex)
'Debug.WriteLine(" id: " & pCurrent.fi3_id)
'Debug.WriteLine(" num_locks: " & pCurrent.fi3_num_locks)
'Debug.WriteLine(" pathname: " & pCurrent.fi3_pathname)
'Debug.WriteLine(" permission: " & pCurrent.fi3_permission)
'Debug.WriteLine(" username: " & pCurrent.fi3_username)
Next
end if
Do you know one? Please contribute it!