General information
Category:
Coding, syntax & commands
>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.
>
>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)
Actually, your VFP code above is sending a 32 bit pointer to your asc(255) value, which is certainly not what you want to do.
VFP's DECLARE-DLL command doesn't support the BYTE or CHAR data types explicitly. But since Windows pushes items onto the stack in 32 bit chunks (anything smaller gets padded), you can use the INTEGER or SHORT declarations, and the function will only pull in the first 8 bits.
So you SHOULD be able to do this:
DECLARE INTEGER LoadToRam IN Hc11DownLoaderDll SHORT,SHORT,STRING
retval = LoadToRam(portnum,255,NULL)
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only