Click to See Complete Forum and Search --> : Copy Memory


avni
January 13th, 2000, 12:53 PM
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

Aaron Young
January 13th, 2000, 01:32 PM
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
ajyoung@pressenter.com
aarony@redwingsoftware.com

avni
January 13th, 2000, 01:43 PM
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)

Aaron Young
January 13th, 2000, 01:53 PM
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
ajyoung@pressenter.com
aarony@redwingsoftware.com

avni
January 14th, 2000, 11:44 AM
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