Jm,
Lots of little problems. The ones I've noticed include:
***
API
****
Public Const NERR_SUCCESS As Long = 0&
Public Declare Function NetWkstaUserEnum Lib "netapi32" (ByVal servername
As
Long, ByVal level As Long, ByVal bufptr As Long, ByVal prefmaxlen As Long,
ByVal entriesread As Long, ByVal totalentries As Long, ByVal resume_handle
As Long) As Long
Under VB.NET: Short is 16Bit, Integer is 32Bit, and Long is 64Bit. In some
cases where you are using a Long/Integer for a pointer (such as the
servername above) you should define those pointers as System.IntPtr or
better still as String. bufptr I would define as ByRef Byte(), a byte array,
while the last three parameters I would define as ByRef Integer as they are
returning values.
For Example:
Public Structure WKSTA_USER_INFO_0
Public wkui0_username As IntPtr
End Structure
Public Structure WKSTA_USER_INFO_1
Public wkui1_username As IntPtr
Public wkui1_logon_domain As IntPtr
Public wkui1_oth_domains As IntPtr
Public wkui1_logon_server As IntPtr
End Structure
However seeing as they are actualy strings, you might be able to define them
as such. Note, in this instance they may need a
System.Runtime.InteropeServices.MarshalAsAttribute to indicate the type of
String they are
Public Structure WKSTA_USER_INFO_0
Public wkui0_username As String
End Structure
CopyMemory tmp(0), ByVal dwData, tmplen
GetPointerToByteStringW = tmp
CopyMemory is not a "valid" operation under VB.NET! Strings are managed
totally different! Based on a quick look, you should be able to replace
GetPointerToByteStringW with one of the
System.Runtime.InteropServices.Marshal.PtrToString* methods (such as
Marshal.PtrToStringUni)
dwServer = StrPtr(bServer)
Again StrPtr is not a "valid" operation under VB.NET! Strings are managed
totally different! Normally I simply define the API with String as the
parameter type & the marshaller will work it out for itself...
I will try (try) to look at this later, post back here if you get it working
or need more help. The microsoft.public.dotnet.framework.interop newsgroup
has a number of people that do interop a lot, and might provide quicker
help...
Hope this helps
Jay