Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending VFP arrays to/from C++?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00258437
Message ID:
00261398
Vues:
13
>Has anyone done any work with sending VFP arrays to a dll or returning C++ arrays from a dll to VFP? Ideally what I would like to do is pass a VFP array to my dll and have it populate the array for me. Almost as good would be to have the dll pass back a C array and allow VFP to manipulate it instead. Has anyone done something similar?

Dear Michael,

here is a short code snippet from my GetProfiles fll, which gives back available MAPI profiles into a VFP array. (See File Section if want it to use)
Calling syntax: GetProfiles("aArrayName"). This function will create a local array with the specified name and stores info into it.

I hope this helps.
Value val;
Locator loc;
// Making the array
// Null terminate character string
if (!_SetHandSize(parm->p[0].val.ev_handle,parm->p[0].val.ev_length+1))
goto ERROR; // "Insufficient memory"
_HLock(parm->p[0].val.ev_handle);
varName = (char FAR *) _HandToPtr(parm->p[0].val.ev_handle);
varName[parm->p[0].val.ev_length] = '\0';
if (_FindVar(_NameTableIndex(varName),-1,&loc)) { // if array exist
_Release(_NameTableIndex(varName));
}
loc.l_subs = 1;// 1 dimension array
loc.l_sub1 =(short) nRows; // 1st dimension
loc.l_sub2 = 0; // 2nd dimension
flag = 1; // private 0: public
if ((retValue = _NewVar(varName, &loc, flag)) < 0) {// retValue : NTI
_HUnLock(parm->p[0].val.ev_handle);
goto ERROR;
}
_HUnLock(parm->p[0].val.ev_handle);
// now wee have a refrence for the array in loc

// populating the array
for (i=0; i loc.l_subs = 1;// 1 dimension array
loc.l_sub1 =i+1; // 1st dimension
loc.l_sub2 = 0; // 2nd dimension
val.ev_type="C"

pszString="any text or char array"; // pointer to actual data

//making handle for array element
if (!_SetHandSize(val.ev_handle,strlen(pszString)))
goto ERROR; // "Insufficient memory"

_HLock(parm->val.ev_handle); // allocing pointer
pszItemText = (char FAR *) _HandToPtr(val.ev_handle);
strcpy(pszItemText,pszString);
ev_length=strlen(pszString);
if ((retValue = _Store(&loc,&val)) < 0) {
_HUnLock(val.ev_handle);
goto ERROR;
};
_HUnLock(val.ev_handle);
};

ERROR: // do anything you want

I hope this helps.

BB
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform