K
klabranche
Guest
I am trying to convert my VB6 class to a VB.Net Class. I have several APIs that the class calls. I am running into a problem with VB.Net using the API calls. How should the Below API look in VB.Net
VB6 Declaration
Private Declare Function NetServerEnum Lib "netapi32.dll" (btComputerName As Byte, _
ByVal lgLevel As Long, anBuffer As Any, lgPreferedMaxLen As Long, _
lgEntriesRead As Long, lgTotalEntries As Long, anServerType As Any, _
btDomain As Byte, lgResumeHandle As Long) As Long
So far I have done....
Private Declare Function NetServerEnum Lib "netapi32.dll" (ByRef btComputerName As Byte, ByVal lgLevel As Integer, ByRef anBuffer As Integer, ByRef lgPreferedMaxLen As Integer, ByRef lgEntriesRead As Integer, ByRef lgTotalEntries As Integer, ByRef anServerType As Integer, ByRef btDomain As Byte, ByRef lgResumeHandle As Integer) As Integer
The compiler doesnt like the "As Any" so I changed the declares to integers and now I get an INVALID_PARAMETER (error code 87) from the result of calling the API.
I also tried using the below but this to failed with another error....
Private Declare Function NetServerEnum Lib "netapi32.dll" (ByRef btComputerName As Byte, ByVal lgLevel As Integer, <MarshalAsAttribute(UnmanagedType.AsAny)> ByRef anBuffer As Object, ByRef lgPreferedMaxLen As Integer, ByRef lgEntriesRead As Integer, ByRef lgTotalEntries As Integer, <MarshalAsAttribute(UnmanagedType.AsAny)> ByRef anServerType As Object, ByRef btDomain As Byte, ByRef lgResumeHandle As Integer) As Integer
Any help would be appreciated...
VB6 Declaration
Private Declare Function NetServerEnum Lib "netapi32.dll" (btComputerName As Byte, _
ByVal lgLevel As Long, anBuffer As Any, lgPreferedMaxLen As Long, _
lgEntriesRead As Long, lgTotalEntries As Long, anServerType As Any, _
btDomain As Byte, lgResumeHandle As Long) As Long
So far I have done....
Private Declare Function NetServerEnum Lib "netapi32.dll" (ByRef btComputerName As Byte, ByVal lgLevel As Integer, ByRef anBuffer As Integer, ByRef lgPreferedMaxLen As Integer, ByRef lgEntriesRead As Integer, ByRef lgTotalEntries As Integer, ByRef anServerType As Integer, ByRef btDomain As Byte, ByRef lgResumeHandle As Integer) As Integer
The compiler doesnt like the "As Any" so I changed the declares to integers and now I get an INVALID_PARAMETER (error code 87) from the result of calling the API.
I also tried using the below but this to failed with another error....
Private Declare Function NetServerEnum Lib "netapi32.dll" (ByRef btComputerName As Byte, ByVal lgLevel As Integer, <MarshalAsAttribute(UnmanagedType.AsAny)> ByRef anBuffer As Object, ByRef lgPreferedMaxLen As Integer, ByRef lgEntriesRead As Integer, ByRef lgTotalEntries As Integer, <MarshalAsAttribute(UnmanagedType.AsAny)> ByRef anServerType As Object, ByRef btDomain As Byte, ByRef lgResumeHandle As Integer) As Integer
Any help would be appreciated...