General information
Category:
Windows API functions
Title:
Christof Lange's Struct Library
I am trying to lookup data from our accounting program, Rubicon, which runs as a client/server application. The accompanying rubapi.dll is a 32-bit windows dll-file with functions for both reading and writing to the application. Typically a function like "RubLesKunde" given a customer number, will lookup customer information. The function expects a structure as parameter. Since VFP do not support structures, I was recommended Christof Lange's Struct Library in order to be able to convert a data object into a structure-like string to feed the function. However, I must be doing something wrong, since I am not getting the expected results. This is the declaration of the function in VB-code:
Declare Function RubLesKunde Lib "rubapi" (ByRef M As ReskInfo) As Long
...and this is my translation to VFP-code:
DECLARE LONG RubLesKunde IN "rubapi" STRING @ pReskinfo
...this is part of the definition of the structure in C
typedef struct _reskontro_data {
PSLONG lSize; /* Size of the entire structure */
PSSHORT sKey;
PSSHORT sFiller1; /* for Future use */
PSLONG lKundeNummer; /* KU_KNR */
PSCHAR achKundeNavn[30+1]; /* KU_KNAVN */
* more values
PSDOUBLE dSaldo; /* KU_SALDO */
} RESKINFO, *PRESKINFO;
... in VFP I try this:
DEFINE CLASS ReskInfo AS STRUCT
lSize = 0
sKey = 0
sFiller1 = 0
lKundenummer = 0
szKundenavn = SPACE(30+1)
* more values
dSaldo = 0
cMembers = "l:lSize, w:sKey, w:sFiller1, l:lKundenummer, " + ;
"c:szKundenavn, d:dSaldo"
ENDDEFINE
... and finally try to execute like this:
oReskinfo = createobject("Reskinfo")
oReskinfo.lSize = oReskinfo.SizeOf()
oReskinfo.lKundenummer = 12345 && A valid customer number
cReskinfo = oReskinfo.Getstring()
RetVal = RubLesKunde(@cReskinfo)
... which returns a value of 2 which indicates an error.
Any information will be appreciated :)
Next
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