I found this code on the internet today, and it's just what I need to
be able to enumerate the open files on our network servers. However,
I keep getting error messages (specifically 123 and 1113) returned in
the dwStatus variable. Can anyone tell me what these numeric messages
mean, or point me in the direction of some documentation on the
NetFileEnum call?
I think 123 means the network resource cannot be found..I feel this is
the case because if I try to contact "FOO", I get the 123 error. I
thought 1113 might be a permissions error, but I logged into my PC
with a domain admin account and still received the error.
Any help would be appreciated. Please? :)
Dan
================================
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(TextBox2.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)
TextBox1.Text += "dwIndex=" & dwIndex & vbNewLine
TextBox1.Text += " id: " & pCurrent.fi3_id &
vbNewLine
TextBox1.Text += " num_locks: " &
pCurrent.fi3_num_locks & vbNewLine
TextBox1.Text += " pathname: " &
pCurrent.fi3_pathname & vbNewLine
TextBox1.Text += " permission: " &
pCurrent.fi3_permission & vbNewLine
TextBox1.Text += " username: " &
pCurrent.fi3_username & vbNewLine & vbNewLine
Next
Else
TextBox1.Text += "dwStatus returned " & dwStatus &
vbNewLine & vbNewLine
End If
NetApiBufferFree(pBuffer)
expvb - 12 Apr 2008 05:32 GMT
From the "+=" in your code, this appears to be a VB.Net code. This newsgroup
is for VB6 and lower. For VB.Net, please look in newsgroups with "dotnet" or
"vsnet" in the name.
Windows error codes can be looked up using a utility that comes with Visual
Studio in the Tools sub section in the Start menu. Look for "Error Lookup",
or "Visual C++ Error Lookup".