Results 1 to 2 of 2

Thread: NetUserAdd

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461

    Angry

    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????

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461

    PROBLEM SOLVED

    Well the example given on VB Square doesn't work in all cases

    It appears that using the code as is doesn't work on the system I am using but I cannot confirm if it actually works on any system.

    For those who are interested there were 2 problems :

    1. Use of the VarPtr was changed to the API Call StrToPtr
    2. Definition of the byte arrays was set to UBound(var) + 1 instead of just UBound(var)


    In doing both of these the code ran perfectly... which would suggest to me that leaving the last byte off the end and not using the correct conversion method into a pointer, the system lost its SP when leaving the function and thus tried to access memory it wasn't allowed to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width