CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Copy Memory

  1. #1
    Join Date
    Jan 2000
    Posts
    46

    Copy Memory

    Hi,
    I am using VB 6.0. I am calling the Copymemory function twice in one sub.
    When the execution goes to the second Copymemory function, I get a memory exception and the program exits out and closes also the vb windows.
    Is there a problem with calling copymemory twice in one sub? If not, is there something I can do to fix the problem?
    Thank you for your help...

    Avni


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Copy Memory

    There's nothing wrong with calling CopyMemory multiple times, provided you are passing the parameters as expected, post a sample of the code that's crashing and we may be able to pin point the problem.

    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  3. #3
    Join Date
    Jan 2000
    Posts
    46

    Re: Copy Memory

    Hi, Here is the code that uses the copymemory twice. It's kind of long, but i didn't know which part to skip. Thank you for your help.

    rc = PLC_GetSessionData(SessionID, pSessionData)

    ' Get SessionData from the pointer pSessionData
    Call CopyMemory(SessionData, ByVal pSessionData, LenB(SessionData))

    ' Display Data retreived for session
    Dim LicenseID As Long
    Dim ServerID As Long
    Dim LicenseData As tLicenseData
    Dim pLicenseData As Long

    LicenseID = SessionData.CurrentLicenseId
    ServerID = SessionData.CurrentServerId

    rc = PLC_GetLicenseData(APIHandle, ServerID, LicenseID, pLicenseData)

    Call CopyMemory(LicenseData, ByVal pLicenseData, LenB(LicenseData))
    'Here is where I get the memory error.

    'Then using LicenseData to get the Developer Data
    'Result = Result + "Pointer is: " + Hex(pLicenseData)
    Result = Result + vbNewLine + " LicenseID = " + Hex(LicenseID)


  4. #4
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Copy Memory

    If the License Data Structure contains Strings, it could be you are doubling up on the Memory you're trying to copy by using LenB, try using Len instead, other than that nothing stands out.

    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  5. #5
    Join Date
    Jan 2000
    Posts
    46

    Re: Copy Memory

    Hi Aaron,
    What you suggested did not work, but I changed the length in the second copymemory call to len(sessiondata) and that seems to work fine...
    I don't know if this is the best way to do this, but it works...
    Thanks for your help.
    Avni


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

Featured