Click here to Skip to main content
16,008,075 members
Home / Discussions / COM
   

COM

 
GeneralUrgent!! Creating own stream in a Word Document Pin
26-Mar-02 23:02
suss26-Mar-02 23:02 
GeneralPointer to an ActiveX in VB Pin
Jerome Conus26-Mar-02 19:46
Jerome Conus26-Mar-02 19:46 
GeneralCOM Object Pin
Nick Parker26-Mar-02 18:16
protectorNick Parker26-Mar-02 18:16 
GeneralRe: COM Object Pin
Paul M Watt26-Mar-02 18:53
mentorPaul M Watt26-Mar-02 18:53 
GeneralRe: COM Object Pin
Michael Dunn26-Mar-02 19:31
sitebuilderMichael Dunn26-Mar-02 19:31 
GeneralReturning Safearray from remote DCOM Pin
David Spain25-Mar-02 12:34
David Spain25-Mar-02 12:34 
GeneralRe: Returning Safearray from remote DCOM Pin
Sayan Mukherjee26-Mar-02 2:36
Sayan Mukherjee26-Mar-02 2:36 
GeneralRe: Returning Safearray from remote DCOM Pin
David Spain26-Mar-02 3:56
David Spain26-Mar-02 3:56 
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; q<count; q++)
="" {
="" sldk="" +="1.0f;" test="" values
="" pfloattemp[q]="sldk;
" }
="" safearrayunaccessdata(*psafloatreturn);
="" safearraylock(*psafloatreturn);="" ???

="" *errcode="S_OK;
" return="" s_ok;
}

---------------
client="" code:

passed="" in:="" cstring="" sname,="" int="" cnt,="" float*="" pfloatarray1,="" bool*="" pboolarray,="" pfloatarray2,="" float="" float1,="" float2,="" long*="" errcode

{

="" safearraybound="" sab;
="" sab.llbound="0;
" sab.celements="cnt;
" safearray*="" psafloatreturn="SafeArrayCreateVector(VT_R4," 0,="" cnt);

="" initialize="" other="" parameters="" here

="" **="" safearray="" **
="" safearraylock(psafloatreturn);
="" tempfloat="new" float[cnt];
="" psafloatreturn-="">pvData = 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 returning, I know that the count on both ends is the same and matches the cnt variable given here, so is not an issue of writing past array boundaries.

Thanks in advance for any help.



David Spain, C++ Applications Programmer
GeneralRe: Returning Safearray from remote DCOM Pin
David Spain27-Mar-02 2:55
David Spain27-Mar-02 2:55 
GeneralBuilding interface to IActiveScriptSite and IActiveScriptSiteWindow with MFC and ATL 7.0 Pin
25-Mar-02 7:50
suss25-Mar-02 7:50 
GeneralProblems with suspend/resume comm thread. Pin
dejan.n25-Mar-02 4:05
dejan.n25-Mar-02 4:05 
GeneralATL CLSCTX_LOCAL_SERVER get E_NOINTERFACE error... Pin
johnstapleton25-Mar-02 2:46
johnstapleton25-Mar-02 2:46 
GeneralRe: ATL CLSCTX_LOCAL_SERVER get E_NOINTERFACE error... Pin
jfugate18-Jul-02 5:03
jfugate18-Jul-02 5:03 
QuestionHow do I retrieve the container window Ptr(HWND) in the COM? (eg.IE client area) Pin
xelin25-Mar-02 1:28
xelin25-Mar-02 1:28 
AnswerRe: How do I retrieve the container window Ptr(HWND) in the COM? (eg.IE client area) Pin
Amit Dey30-Mar-02 0:33
Amit Dey30-Mar-02 0:33 
GeneralRe: How do I retrieve the container window Ptr(HWND) in the COM? (eg.IE client area) Pin
xelin3-Apr-02 0:21
xelin3-Apr-02 0:21 
QuestionHow to specify an ATL server location at runtime Pin
HawkSoftware22-Mar-02 19:52
HawkSoftware22-Mar-02 19:52 
AnswerRe: How to specify an ATL server location at runtime Pin
Not Active26-Mar-02 15:04
mentorNot Active26-Mar-02 15:04 
GeneralRe: How to specify an ATL server location at runtime Pin
HawkSoftware26-Mar-02 18:28
HawkSoftware26-Mar-02 18:28 
Generalefficiency question with in proc COM methods Pin
moredip22-Mar-02 12:16
moredip22-Mar-02 12:16 
GeneralRe: efficiency question with in proc COM methods Pin
Tim Smith22-Mar-02 13:18
Tim Smith22-Mar-02 13:18 
GeneralRe: efficiency question with in proc COM methods Pin
22-Mar-02 13:52
suss22-Mar-02 13:52 
Generaldialog boxes Pin
shingai22-Mar-02 9:41
shingai22-Mar-02 9:41 
GeneralRe: dialog boxes Pin
Mazdak22-Mar-02 9:50
Mazdak22-Mar-02 9:50 
GeneralRe: dialog boxes Pin
Mazdak22-Mar-02 18:34
Mazdak22-Mar-02 18:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.