Passing/receiving byte-arrays ?
-
Can someone please help me out!!! I just don't know how to pass/receive binary data between a VB6 client application and an ATL COM Server (EXE). How can I transform this into COM? HRESULT MyFunc( unsigned short* pbIn, long cbIn, unsigned short** ppbOut ); Where pbIn is of cbIn-size. The output shall be a size-dynamic buffer holding the result. Can I use VB6 to call this method using Byte arrays? Need help
-
Can someone please help me out!!! I just don't know how to pass/receive binary data between a VB6 client application and an ATL COM Server (EXE). How can I transform this into COM? HRESULT MyFunc( unsigned short* pbIn, long cbIn, unsigned short** ppbOut ); Where pbIn is of cbIn-size. The output shall be a size-dynamic buffer holding the result. Can I use VB6 to call this method using Byte arrays? Need help
COM must know at runtime the size of the buffer you want to marshall. So in your case you should declare the method in your IDL file like this : interface XXX { HRESULT MyFunc( [in]long cbIn,[in,size_is(cbIn)] unsigned short *pbIn,[out]long* pbOut,[out,size_is( ,*pbOut)]unsigned short** ppbOut); }; Or if you want to use the automation marshaller you can pass the array as SAFEARRAY, which is a VARIANT compatible type.
-
Can someone please help me out!!! I just don't know how to pass/receive binary data between a VB6 client application and an ATL COM Server (EXE). How can I transform this into COM? HRESULT MyFunc( unsigned short* pbIn, long cbIn, unsigned short** ppbOut ); Where pbIn is of cbIn-size. The output shall be a size-dynamic buffer holding the result. Can I use VB6 to call this method using Byte arrays? Need help
Hi Stefan, one way that to pass binary data is to use BSTRs, using the api SysAllocStringByteLen , this creates a string with binary data . I actually used that doing a atl com object that passed binary data to vb6. I don't remember well, but since VB6 work with unicode internally , i think that you must allocate 2*nBytes that you want to pass to VB, but I'm not sure if you really need to double the nª of bytes, so you should try the first one. It's not necessary with BSTR to pass the size, since their size is prefixed at the head of the data, and vb makes use of this. Hope this helps, Joao Vaz
-
Can someone please help me out!!! I just don't know how to pass/receive binary data between a VB6 client application and an ATL COM Server (EXE). How can I transform this into COM? HRESULT MyFunc( unsigned short* pbIn, long cbIn, unsigned short** ppbOut ); Where pbIn is of cbIn-size. The output shall be a size-dynamic buffer holding the result. Can I use VB6 to call this method using Byte arrays? Need help
See sample app of COM Variant and Safearrays at http://www.sellsbrothers.com/tools/CComSafeArray.zip It also uses VB Clients and C++ COM Object Best SafeArray Sample that I have seen (from chris sells site) :cool: