Click here to Skip to main content
15,903,854 members
Home / Discussions / COM
   

COM

 
GeneralRe: COM object pooling Pin
Dudi Avramov30-Nov-02 20:47
Dudi Avramov30-Nov-02 20:47 
GeneralNeed help in accessing ATL COM property of type coclass. Pin
bahruddina15-Nov-02 5:38
bahruddina15-Nov-02 5:38 
GeneralRe: Need help in accessing ATL COM property of type coclass. Pin
Hans Ruck17-Nov-02 4:44
Hans Ruck17-Nov-02 4:44 
Generalpass an array from C# to a COM object Pin
gharrison14-Nov-02 21:09
gharrison14-Nov-02 21:09 
GeneralRe: pass an array from C# to a COM object Pin
Christian Graus17-Nov-02 8:24
protectorChristian Graus17-Nov-02 8:24 
QuestionCComPtr or CComQIPtr??? Pin
LukeV14-Nov-02 4:08
LukeV14-Nov-02 4:08 
AnswerRe: CComPtr or CComQIPtr??? Pin
ian mariano14-Nov-02 6:56
ian mariano14-Nov-02 6:56 
GeneralSAFEARRAY - Multidimensions Pin
Dave Loeser13-Nov-02 6:16
Dave Loeser13-Nov-02 6:16 
Hey all,
I'm working on a component that returns a SAFEARRAY. Here's the IDL for the method as well as the C++ declaration:

[id(2), helpstring("List of Report Type (Names) available to a user on a specific date")] HRESULT GetReportTypes([in] BSTR UserID, [in] INT CloseDate, [out, retval] VARIANT* pReportTypes);

STDMETHODIMP CReports::GetReportTypes(BSTR UserID, INT CloseDate, VARIANT *pReportTypes)

Now without loading this up with a ton of code I'll explain what I am doing and then show the important parts of the code.

Basically, I want to return a SAFEARRAY that is mulitdimensionl, in this case the array is [x][1] in size and x is determined by the number of records retrieved. So here's how I'm creating the SAFEARRAY:

<br />
    // Setup/Create our SAFEARRAY<br />
    SAFEARRAYBOUND SABounds[2];<br />
    SABounds[0].cElements = (DWORD)pRsHPASReports->RecordCount + 1; // Why do I need to add 1 to this???<br />
    SABounds[1].cElements = SABounds[0].cElements;<br />
    SABounds[0].lLbound = 0;<br />
    SABounds[1].lLbound = 0;		<br />
		<br />
    // Initialize the variant and set it up as an array of variants<br />
    VariantInit(pReportTypes);<br />
    pReportTypes->vt = VT_VARIANT | VT_ARRAY;<br />
    pReportTypes->parray = SafeArrayCreate(VT_VARIANT, 2, SABounds);<br />


and then after opening the recordset I loop through the records filling in the SAFEARRAY with my data, like so:

<br />
while(! pRsHPASReports->IsEOF)<br />
{<br />
    ldimension[0] = lLoop++;<br />
    ldimension[1] = 0;<br />
<br />
    CComVariant bstrTmp( pRsHPASReports->Fields->Item["RptType"]->Value );<br />
    TESTHR(SafeArrayPutElement( pReportTypes->parray, ldimension, &bstrTmp ));<br />
<br />
    ldimension[1] = 1;<br />
    CComVariant bstrTmp2( pRsHPASReports->Fields->Item["Title"]->Value );<br />
    TESTHR(SafeArrayPutElement( pReportTypes->parray, ldimension, &bstrTmp2 ));<br />
			<br />
    pRsHPASReports->MoveNext();<br />
}<br />

pretty standard stuff, right? Well, as you can see from the comment above, If I have a record count of 1 then the SAFEARRAY does not appear to be initialized properly... I'm forced to add 1 to the count so that I can build the array. My question is why can't I create a SAFEARRAY with a size [1][1]?

On the client side, when checking the bounds on the SAFEARRAY I see 0 to 1 ... yet the element at postion 1 is empty. I've looked high and low on the web for a soloution and have not been successful...
So, anyone know how I can create a SAFEARRAY with just one element?

Thanks,


Dave "Dak Lozar" Loeser
When access is allowed to a member, it said to be accessible. Otherwise, it is inaccessible.
GeneralRe: SAFEARRAY - Multidimensions Pin
Vi217-Nov-02 20:45
Vi217-Nov-02 20:45 
GeneralDealing with CWnd* as parents Pin
Dave_12-Nov-02 3:41
Dave_12-Nov-02 3:41 
GeneralMFC ActiveX and Admin rights Pin
Paul Selormey11-Nov-02 20:15
Paul Selormey11-Nov-02 20:15 
GeneralRe: MFC ActiveX and Admin rights Pin
Renjith Ramachandran22-Nov-02 2:24
Renjith Ramachandran22-Nov-02 2:24 
GeneralPassing files Pin
Scracha11-Nov-02 4:48
Scracha11-Nov-02 4:48 
GeneralRe: Passing files Pin
Steve S11-Nov-02 6:58
Steve S11-Nov-02 6:58 
GeneralRe: Passing files Pin
Scracha13-Nov-02 3:42
Scracha13-Nov-02 3:42 
GeneralExcel Component holds up memory Pin
yslim10-Nov-02 21:37
yslim10-Nov-02 21:37 
GeneralPractical question regarding largish com (ATL) based application Pin
Member 969-Nov-02 19:45
Member 969-Nov-02 19:45 
GeneralRe: Practical question regarding largish com (ATL) based application Pin
Anonymous10-Nov-02 5:02
Anonymous10-Nov-02 5:02 
GeneralSerializing COM Components Pin
Tometa Software8-Nov-02 21:25
Tometa Software8-Nov-02 21:25 
GeneralRe: Serializing COM Components Pin
Stephane Rodriguez.8-Nov-02 21:37
Stephane Rodriguez.8-Nov-02 21:37 
GeneralDCOM, domains, and the guest account Pin
Anonymous8-Nov-02 10:03
Anonymous8-Nov-02 10:03 
GeneralActiveX Control signature Pin
Haabit8-Nov-02 3:38
Haabit8-Nov-02 3:38 
GeneralProgrammer's Reference Pin
Haakon S.8-Nov-02 0:35
Haakon S.8-Nov-02 0:35 
GeneralCommunication between 2 ActiveX Ctrls in a browser( HTML page) Pin
sanskypotov7-Nov-02 19:53
sanskypotov7-Nov-02 19:53 
GeneralIDL syntax for SAFEARRAY parameters Pin
nebbish6-Nov-02 10:14
nebbish6-Nov-02 10:14 

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.