I'd like to get array of bytes from active-x component, store that in html-form input hidden field and then pass it to server via form-submit. How can I do that?
HRESULT Data([out, retval] SAFEARRAY(VARIANT) *pArray);
STDMETHODIMP MyActiveX::get_Data(SAFEARRAY **pArray)
for (int i = 0; i < 10; i++)
a = (BYTE)i;
Browser tells me: type mismatch
Although I am not familiar with your exact situation, I have seen some similar situations before.
You are correct to put your data in a field using
$('#hiddenField'). If you've put a
name attribute on that field so that it becomes part of the HTTP submit, that part is good.
What I would do is put a breakpoint before
. Use the
debugger keyword if you're not familiar with it. Run the code in your debugger and look at the structure of the value of
myActiveX.Data. It probably has some sort of wrapper field.
for(x in myActiveX.Data) alert(x + ": " + myActiveX.Data[x]);
I'm assuming the C++ code is the server side code.
The best way to handle this is to serialise the SAFEARRAY. From there you can handle it in two ways.
Firstly, the serialisation. I've looked at MSDN and I think using LPSAFEARRAY_Marshal and LPSAFEARRAY_Unmarshal (with an optional
IUnknown IID to specify the type, but the documentation doesn't say how it's used) or LPSAFEARRAY_UserMarshal and LPSAFEARRAY_UserUnmarshal to convert the SAFEARRAY to/from a serialised format.
Secondly, handling the data transfer.
Either way, when you need to get the data back, just de-serialise it with the matching function.