Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I pass a byte parameter to a dll?
Message
De
27/02/2001 21:36:07
 
 
À
27/02/2001 12:27:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00480142
Message ID:
00480360
Vues:
8
>I need to pass a parameter to a dll function using an unsigned byte and am having some problems.
>
>DECLARE INTEGER LoadToRam IN Hc11DownLoaderDll INTEGER,STRING,STRING
>
>retval = LoadToRam(portnum,CHR(255),NULL)
>
>I need to pass the CHR(255) and the portnum as unsigned char but Foxpro sends it as a signed char.
>

Try:
DECLARE INTEGER LoadToRam IN Hc11DownLoaderDll INTEGER, INTEGER, INTEGER
portnum = 1
commandcode = 255
Ptr = 0
RetCode = LoadToRam(portnum, commandcode, ptr)
This takes advantage of the fact that integer values are passed LSB first, so a byte uses only the first byte of the 4 byte integer.



>A VB implementation uses the following.
>
>Private Declare Function LoadToRam Lib "Hc11DownLoaderDll.dll" _
> (ByVal comPort_ As Byte, ByVal commandCode_ As Byte, _
> ByRef progressBarPtr_ As Any) As Integer
>
>command = CByte(&HFF)
>
>comport = CByte(cboComPort.Text)
>
>result = LoadToRam(comport, command, vbNullString)
>
>A C++ implementation of course just does a cast to unsigned char for the character byte 0xFF.
>
>I need a way to do it in VFP 6.0 if it is possible.
>Any help is appreciated
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform