Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb_dotnet thread: VB6 to VB.Net API Calls


Message #1 by "kevin labranche" <klabranche@c...> on Fri, 24 May 2002 21:39:29
I am trying to convert my VB6 class to a VB.Net Class.  I have several 
API's 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 doesn't 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...

  Return to Index