LoadArray2 example for C++ 5.0 and later
long lCount;
COleVariant MyVar;
HFILE hFile;
HGLOBAL hData=NULL;
void FAR* pData=NULL;
SAFEARRAY FAR *psa;
SAFEARRAYBOUND rgsabound[1];
ILEADRasterIO *pRasterIO=NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
IID_ILEADRasterIO, (void**)&pRasterIO);
MyVar.Clear();
hFile = _lopen("v:\\images\\babe.cmp", OF_READ);
lCount = _llseek(hFile, 0, SEEK_END);
_llseek(hFile, 0, SEEK_SET);
hData = GlobalAlloc(GMEM_MOVEABLE, lCount);
pData = GlobalLock(hData);
_lread(hFile, pData, lCount);
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = lCount;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
SafeArrayLock(psa);
memcpy(psa->pvData, pData, lCount);
SafeArrayUnlock(psa);
V_VT(&MyVar) = (VT_ARRAY | VT_UI1);
V_ARRAY(&MyVar) = psa;
GlobalUnlock(hData);
GlobalFree(hData);
pRasterIO->LoadArray2(m_LEADRasterView1.GetRaster(),
MyVar, 0, 0, -1, lCount);
pRasterIO->Release();
_lclose(hFile);