Hi all,
I need to pass data (byte array, i.e char*) from ActiveX object (using Visual C++ with ATL) to my javascript code (and vice versa). I've digged the Web for such problem and tried lots of solutions but have not succeeded. I've tried the followings:
- Converting char* to BSTR and pass it to javascript (JS), but my result in JS is "", due to the nature of my data is not string.
//in C++:
STDMETHODIMP CActiveXObj::f(BSTR* msg) // msg is the return value in ATL automation function
{
char *buffer; // byte data is stored in buffer
*msg = SysAllocStringByteLen((LPCSTR)buffer, bufferLen+1);
}
//////////////////////////////////////////////////////////////////////////
//in JavaScript:
var myobj= new ActiveXObject("IGCE.ActiveXObj");
var result = myobj.f(); // result = ""
- Pass safe array of byte data from C++
Could anyone please give me the working code in its simplest form?
Thank you very much!
Kristin