I copied the example straight off VB-Square to add users to NT via the NetUserAdd API....

It successfully adds a user but when the function completes it ALWAYS gives me a Memory Violation error and crashes not only the application but VB as well.

I stepped through the code and it happily executed the NetUserAdd command, returned a good value, cleared the buffers with good return values but in exiting the function it crashed.

I have a sneaking suspicion it has something to do with the "NetApiBufferFree" functions in stuffing up the return code and thus its problem.

Anyone had this before????