Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to pass a date to a DLL?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00065737
Message ID:
00065822
Vues:
46
>>>>Peter,
>>>>
>>>>Thanks a lot. Here is what I found in the header file.
>>>>
>>>>typedef struct tagDPIDate
>>>>{
>>>> short jour;
>>>> short mois;
>>>> short annee;
>>>>} DPIDate, FAR * LPDPIDate;
>>>>
>>>>I removed the text of your message in this answer because I'm using the offline reader and it's plain memo...
>>>>
>>>>José
>>>
>>>The length of the string should be 6.
>>>
>>>After the dll procedure returns you can unpack it by:
>>>lnJour = UnpackShort(substr(m.lcStr, 1, 2))
>>>lnMois = UnpackShort(substr(m.lcStr, 3, 2))
>>>lnAnnee = UnpackShort(substr(m.lcStr, 5, 2))
>>>
>>>** Here is a VFP procedure that will unpack the datatype short:
>>>function UnpackShort
>>> lparameters lcStr
>>> assert len(m.lcStr) = 2
>>> local lnLeft, lnRight
>>> lnLeft = asc(left(m.lcStr, 1))
>>> lnRight = asc(right(m.lcStr, 1))
>>> return iif(bitand(lnRight, 0x80) = 0x80), -1, 1) * bitor(lnLeft, bitand(lnRight, 0x7f))
>>
>>I understand why you use the BITAND in the IIF. But I really don't get the part after the "*" sign. IMHO, you can't obtain the correct value using this formula.
>>
>>I would go for the simple one:
>>return lnRight * 256 + lnLeft
>>
>>Of course, you can add the part for the sign, but I don't see how you can have negative values for day, month or year.
>>
>>Vlad
>
>Paul and Vlad,
>
>Thanks a lot for your insight. I really have no C experience, so your help is very welcome. I'll try all your good suggestions and will come back to tell you something about my progresses...
>
>José

If you download my Pointers Class, you will find in the VCX file a VFP class for numerical conversions. This class can be used completly independent from the Pointers class. Obviously, you can use it for all-kind-of numerical conversions like the ones you need now.

Vlad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform