Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For all of my post concerning SafeArray, File TO Memory, etc

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I've solved those problems or least found an alternative, instead of using a safearray or a linked list to hold in memory, I am using a CByteArray which grows as you add bytes into it, and holding it in there, and as far as getting out to visual basic, I have this exposed method that copies a CByteArray To A Variant and passes back out the Variant, which is seen in VB as a Variant/Bytes (Helpful to all of those that want to export binary data to VB)<br><br><br>VARIANT CWiDataClientCtrl::GetFileMem()







{







VARIANT vaResult;







VariantInit(&vaResult);







CByteArray MyB;







if (m_dclient.GetCByte(MyB) == 0)







{















vaResult.vt = VT_ARRAY ¦ VT_UI1;







SAFEARRAYBOUND rgsabound[1];















rgsabound[0].cElements = MyB.GetSize();







rgsabound[0].lLbound = 0;















vaResult.parray = SafeArrayCreate(VT_UI1, 1, rgsabound);















void * pArrayData = NULL;















SafeArrayAccessData(vaResult.parray, &pArrayData);







memcpy(pArrayData, MyB.GetData(), MyB.GetSize());







SafeArrayUnaccessData(vaResult.parray);















return vaResult;







}







vaResult.vt = VT_EMPTY;







return vaResult;





























}<br><br>Though I would like sugestions on other methods or ideas you may have. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top