1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| EXPORT_DLL int __stdcall test(SAFEARRAY **sfa) {
std::ofstream ff("c:\\toto");
int colonnes, m_lignes;
// nombre de lignes
long ubound, lbound, nbElt;
SafeArrayGetUBound(*sfa,1,&ubound);
SafeArrayGetLBound(*sfa,1,&lbound);
m_lignes=ubound-lbound+1;
// nombres de colonnes
if ((*sfa)->cDims>1) {
SafeArrayGetUBound(*sfa,2,&ubound);
SafeArrayGetLBound(*sfa,2,&lbound);
m_colonnes=ubound-lbound+1;
} else m_colonnes=1;
// allocation
nbElt=colonnes*lignes;
ff << "dim=" << (*sfa)->cDims << std::endl;
ff << "colonne=" << m_colonnes << std::endl;
ff << "ligne=" << lignes << std::endl;
ff << "nbElt=" << colonnes*m_lignes << std::endl;
ff << "EltSize=" << SafeArrayGetElemsize(*sfa) << std::endl;
VARTYPE typ;
SafeArrayGetVartype(*sfa,&typ);
ff << "type=" << ((typ==2)?"int":"pas int") << std::endl;
// copie
double *tab=NULL;
if (SafeArrayAccessData(*sfa, (void **)&tab)!=S_OK || !tab) return -29;
for(unsigned i=0;i<nbElt;i++){
ff << tab[i] << "\t";
}
ff.close();
return 0;
} |
Partager