Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DECLARE DLL problem
Message
From
14/11/2001 04:22:09
 
 
To
13/11/2001 16:34:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00580332
Message ID:
00581358
Views:
28
>Well, as I understand funtion DoubleToNum it converts data to valid double one before calling DLL. The following is the code I use:
>
>set proce to clsheap addi && Ed clsheap class
>
>ascmx = replicate(chr(0),8*10)
>xdata =DoubleToNum(ascmx) && Is this OK ?
>
>retval=MyDll(,,@xdata)
>
>The C0000005 error appear after that.

No, what you want to do is initialize a buffer to the length of the array (10 Doubles at 8 bytes/double is 80 bytes, and then parse the results after the return:
cBuffer = REPL(CHR(0), 80)
*
*  blah, blah woof, woof
*
retval =MyDLL(,,@cBuffer)
LOCAL i, ArrayOfDoubles[10], nPosn
FOR i = 0 TO 9
   nPosn = i*8 + 1
   ArrayOfDoubles[i+1] = DoubleToNum(SUBST(cBuffer,nPosn,8))
ENDFOR
That should populate the memvar array ArrayOfDoubles with the 10 values returned.


>
>Must I convert LONG data type too?
>

If the Long is embedded in a structumemllocation, you need to convert from the string to the numeric value using DWORDToNum():
nLongInteger = DWORDToNum(SUBST(cStructureHoldingLong,nPositionofLong,4))
If the Long is passed as a parameter rather than being embedded in a structure, then it will be handled as a 32 bit integer value without the need to convert. If you need to convert an integer to the string representing the Integer to concatenate into a structure, you'd use NumToDWORD():
cDWORDString = NumToDWORD(nMyIntegerValue)
See my postings on the Wiki (htp://fox.wikis.com) entitled "Pointers on Pointers" for more details.
>
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform