Returning Safearray from remote DCOM
-
The program, in C++, is sending a call to a DCOM object installed on a remote NT machine, and am trying to return a Safearray of float (as SAFEARRAY **ppfloatarray), have set that parameter as [in,out], (plus other parameters before this as [in]). Client is running Windows 98. On the client end, the data is not being written back to the passed-in safearray, and HRESULT returned is 8002000D, array is locked. How is the client and server to be set up to do this? My solution was to try various combinations for the flags in the fFeatures member of the safearray, also to try setting the array to locked or unlocked before it was sent and before it was returned from server. I have a debug text file written, so I know that the DCOM object is executing, and the correct values are written to the safearray and are there just before it returns. David Spain, C++ Applications Programmer
-
The program, in C++, is sending a call to a DCOM object installed on a remote NT machine, and am trying to return a Safearray of float (as SAFEARRAY **ppfloatarray), have set that parameter as [in,out], (plus other parameters before this as [in]). Client is running Windows 98. On the client end, the data is not being written back to the passed-in safearray, and HRESULT returned is 8002000D, array is locked. How is the client and server to be set up to do this? My solution was to try various combinations for the flags in the fFeatures member of the safearray, also to try setting the array to locked or unlocked before it was sent and before it was returned from server. I have a debug text file written, so I know that the DCOM object is executing, and the correct values are written to the safearray and are there just before it returns. David Spain, C++ Applications Programmer
Hi David, Can you put parts of your code in this forum? Specially those parts where you are accessing and unaccessing the SAFEARRAY. It will be better if you can also give us the portion of the IDL that describes the prototype of the interface method where you are having the problem. With best regards, Sayan (sayanmukherjee@indiatimes.com)
-
The program, in C++, is sending a call to a DCOM object installed on a remote NT machine, and am trying to return a Safearray of float (as SAFEARRAY **ppfloatarray), have set that parameter as [in,out], (plus other parameters before this as [in]). Client is running Windows 98. On the client end, the data is not being written back to the passed-in safearray, and HRESULT returned is 8002000D, array is locked. How is the client and server to be set up to do this? My solution was to try various combinations for the flags in the fFeatures member of the safearray, also to try setting the array to locked or unlocked before it was sent and before it was returned from server. I have a debug text file written, so I know that the DCOM object is executing, and the correct values are written to the safearray and are there just before it returns. David Spain, C++ Applications Programmer
Ok, here is the code in question: I was wanting to return a safearray of BSTR, but was having trouble with that, so thought maybe it had to do with the pointers, so tried float safearray, but is having same problem. This is the code with float safearray: >>> psaFloatReturn is the safearray in question <<< IDL code: [ object, uuid(13AE8E35-3726-11D6-9913-000102476F95), dual, helpstring("IRemoteServerDisp Interface"), pointer_default(unique) ] interface IRemoteServerDisp : IDispatch { [id(2), helpstring("method Method2")] HRESULT Method2([in] BSTR sName, [in] SAFEARRAY(float) *psafloatAr1, [in] SAFEARRAY(VARIANT_BOOL) *psaBoolAr, [in] SAFEARRAY(float) *psafloatAr2, [in] long cnt, [in] float singlefloat1, [in] float singlefloat2, [in,out] SAFEARRAY(float) *psaFloatReturn, [out,retval] long* errcode); }; -------------------- CoClass method: STDMETHODIMP CCoRemoteServer::Method2(BSTR sName, SAFEARRAY **psafloatAr1, SAFEARRAY **psaBoolAr, SAFEARRAY **psafloatAr2, long cnt, float float1, float float2, SAFEARRAY **psaFloatReturn, long* errcode) { . . . float HUGEP *pfloatTemp; long val = SafeArrayAccessData(*psaFloatReturn, (void HUGEP**)&pfloatTemp); float sldk = 3.0f; for(int q=0; qpvData = tempfloat; SafeArrayLock(psaFloatReturn); // call to DCOM object BSTR bstrName = sName.AllocSysString(); HRESULT hResult = m_pRemoteServer->Method2(bstrName, &psafloatar1, &psaBoolAr, &psafloatar2, cnt, float1, float2, &psaFloatReturn, errcode); SysFreeString(bstrName); SafeArrayDestroy(psafloatar1); SafeArrayDestroy(psafloatar2); SafeArrayDestroy(psaBoolAr); bool ret = false; if(SUCCEEDED(hResult)) ret = true; if(psaFloatReturn!=NULL) SafeArrayDestroy(psaFloatReturn); delete []tempfloat; } About the count in initializing and retu
-
The program, in C++, is sending a call to a DCOM object installed on a remote NT machine, and am trying to return a Safearray of float (as SAFEARRAY **ppfloatarray), have set that parameter as [in,out], (plus other parameters before this as [in]). Client is running Windows 98. On the client end, the data is not being written back to the passed-in safearray, and HRESULT returned is 8002000D, array is locked. How is the client and server to be set up to do this? My solution was to try various combinations for the flags in the fFeatures member of the safearray, also to try setting the array to locked or unlocked before it was sent and before it was returned from server. I have a debug text file written, so I know that the DCOM object is executing, and the correct values are written to the safearray and are there just before it returns. David Spain, C++ Applications Programmer
No need for anyone to spend any more time on this -- Sorry if anyone spent time on this, I think there is code on this website in the articles that would help me. In the COM section, "STL Compliant Class for SafeArrays", the code returns safearrays from a COM object, which was my problem. There may be other articles as well. I will look at that to find out what I am doing wrong, so no need for anyone to look at this any further, thanks for the effort. David Spain, C++ Applications Programmer