[DllImport("Netapi32.dll", SetLastError=true)]
static extern int NetApiBufferFree(IntPtr Buffer);
VB .NET Signature:
Declare Unicode Function NetApiBufferFree Lib "netapi32.dll" _
(ByVal buffer As IntPtr) As Long
Notes:
Changed VB.NET Signature from "ByRef buffer" to "ByVal buffer". With ByRef you get a significant memory leak, with ByVal everything is fine.
Notes:
Added VB definition & sample.
Sample Code:
VB.NET:
' Edited down code to only show usage of NetApiBufferFree()
Dim BufPtr As IntPtr 'in
retval = NetShareEnum(SvrNameBldr, 2, BufPtr, MAX_PREFERRED_LENGTH, dwEntriesread, dwTotalentries, dwResumehandle)
Call NetApiBufferFree(BufPtr)