Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C Structures and VFP
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00522430
Message ID:
00522456
Views:
9
Hi!
You are right about 16 byte buffer, but you may reserve more space than needed.
In case of your structure this seems to be correct.
>
>chr(157)+replicate(chr(0), 156)
>
>I'm using a function from a DLL which needs a structure as one of the parameters.
> In VFP's help file I found following under Chapter 27: Extending Visual FoxPro with External Libraries
>
>
>typedef struct _SYSTEMTIME {
>   WORD wYear ;
>   WORD wMonth ;
>   WORD wDayOfWeek ;
>   WORD wDay ;
>   WORD wHour ;
>   WORD wMinute ;
>   WORD wSecond ;
>   WORD wMilliseconds ;
>} SYSTEMTIME
>
>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))))
>
>
>Well. I'm a bit confused here how they got that cBuff has to be of size 40, when each word is only a size 2 and there is only 8 words, which I see as size 8*2 = 16. It says that you must create a 40-byte string buffer. Why?
>
>But back to my function in the DLL and its structure, which looks like this
>
>typedef struct _INITDATA
>{
>  DWORD dwSize;
>  DWORD dwVersionMajor;
>  DWORD dwVersionMinor;
>  DWORD dwVersionBuild;
>  DWORD dwOptions;
>  DWORD dwReserved1;
>  DWORD dwReserved2;
>  char  szDescription[MAXDESCRIPTIONLENGTH+1];
>
>}  INITDATA, FAR* LPINITDATA;
>
>
>All I need is to make sure that dwSize is the value of the size of the structure. Since it is a Double Word I would imagine the have size of 4 so I tried following (MAXDESCRIPTIONLENGTH is 128) strings
>
>chr(157)+chr(0)+chr(0)+chr(0)+replicate(chr(0), 153)
>chr(0)+chr(157)+chr(0)+chr(0)+replicate(chr(0), 153)
>chr(0)+chr(0)+chr(157)+chr(0)+replicate(chr(0), 153)
>chr(0)+chr(0)+chr(0)+chr(157)+replicate(chr(0), 153)
>
>Or chr(156) and 152 replicated chr(0)'s or chr(32)'s.
>
>Any help here would be great. TIA,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform