Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DECLARE DLL problem
Message
De
14/11/2001 04:22:09
 
 
À
13/11/2001 16:34:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00580332
Message ID:
00581358
Vues:
29
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform