Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VC++ configuration for Building DLLs?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00068689
Message ID:
00068810
Vues:
29
>
> if (!_SetHandSize(parm->p[0].val.ev_handle,parm->p[0].val.ev_length+1)) {
> _Error(182); // "Insufficient memory"
> }
> _HLock(parm->p[0].val.ev_handle);
> string = (char FAR *) _HandToPtr(parm->p[0].val.ev_handle);
> string[parm->p[0].val.ev_length] = '\0';
> memcpy(destination,string,parm->p[0].val.ev_length+1);
> _HUnLock(parm->p[0].val.ev_handle);
>

Oops! I figured it out by looking at your code! I set the length of the string to the length + 1 and then I set the value of the character after the end of the string to '\0' instead of setting the last character to null. This WAS my code; I'm amazed that it worked at all:

if ((mh_out = _AllocHand(parm->p[1].val.ev_length+1)) == 0)
_Error(182); /* "Insufficient memory." */

_HLock(mh_out);
in_string = (char FAR *) _HandToPtr(parm->p[1].val.ev_handle);
out_string = (char FAR *) _HandToPtr(mh_out);

*(out_string + parm->p[1].val.ev_length+1) = '\0'; /* _RetChar() needs null terminated string */

Which is wrong, since C and C++ arrays start with 0 not 1! Thank you very much.

-Lou.
"All my life I said I wanted to be someone ...
I can see now that I should have been more specific." -Jane Wagner
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform