Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Struct Parameters to Dll
Message
De
10/03/2003 11:54:07
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Titre:
Passing Struct Parameters to Dll
Divers
Thread ID:
00763728
Message ID:
00763728
Vues:
66
Here is the situation. I have a c style dll that I need to be able to call through Visual FoxPro 6. It takes as parameters 8 structures. In Fox Pro Help I found the following below the my question:

My Question:
So here is the question. There are 8 WORDS in the structure at 16bits a piece or 2bytes a piece. 8 words * 2 bytes = 16bytes. However, the documentation says to create a 40 byte stringbuffer. Where did the 40 bytes come from? Can anyone point me to a complete documentation on dll access through fox. and I mean "COMPLETE" which would include the source code for the dll and the client for the dll.
Any help is greatly appreciated.

FoxPro Help Exerpt:
Some DLL functions require more complex parameters, such as structures or arrays. If the function requires a pointer to a structure, you must determine the layout of the structure, then emulate it as a string in Visual FoxPro before passing it or receiving it from the DLL function. For example, the Windows system function GetSystemTime( ) expects a pointer to a structure consisting of eight words or unsigned 16-bit integers indicating the year, month, day, and so on. The structure is defined this way:

typedef struct _SYSTEMTIME {
WORD wYear ;
WORD wMonth ;
WORD wDayOfWeek ;
WORD wDay ;
WORD wHour ;
WORD wMinute ;
WORD wSecond ;
WORD wMilliseconds ;
} SYSTEMTIME

To pass data between Visual FoxPro and the GetSystemTime( ) function, you must create a 40-byte string buffer (consisting initially of spaces) and then pass the address of this string to the function for it to fill in. When the string is returned, you must parse it in 2-byte increments to extract the individual fields of the structure. The following fragment illustrates how you could extract three of the fields from the structure:

DECLARE INTEGER GetSystemTime IN win32api STRING @
cBuff=SPACE(40)
=GetSystemTime(@cBuff)

tYear = ALLTRIM(STR(ASC(SUBSTR(cBuff,2)) * ;
256 + ASC(SUBSTR(cBuff,1))))
tMonth = ALLTRIM(STR(ASC(SUBSTR(cBuff,4)) * ;
256 + ASC(SUBSTR(cBuff,3))))
tDOW = ALLTRIM(STR(ASC(SUBSTR(cBuff,6)) * ;
256 + ASC(SUBSTR(cBuff,5))))


So here is the question. There are 8 WORDS in the structure at 16bits a piece or 2bytes a piece. 8 words * 2 bytes = 16bytes. However, the documentation says to create a 40 byte stringbuffer. Where did the 40 bytes come from?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform