Solved

COM Array (CComSafeArray::MultiDimGetAt)

Posted on 2006-06-29
7
707 Views
Last Modified: 2008-01-09
I have a COM array of doubles of type CComSafeArray, say with 10 rows and 30 columns. I simply need to retrieve its elements one by one and print them out on the screen. How do I do this with MultiDimGetAt? I have read the Microsoft documentation available on the MSDN website but it's not very clear to me, and I don't know much about COM.
Thanks.
0
Comment
Question by:Rothbard
  • 5
  • 2
7 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008437

for(int i=0; i < 10; i++)
{
    Array->GetAt(i, &Data);
    cout << Data;
}
0
 

Author Comment

by:Rothbard
ID: 17008472
What is Data in your code? Also, since our Array has two dimensions wouldn't you need MultiDimGetAt rather than GetAt?
0
 
LVL 11

Accepted Solution

by:
Jase-Coder earned 500 total points
ID: 17008479
sorry ignore the above: do

LONG Index[2];

for(int i=0; i< 10; i++)
   for(int j=0; j < 3; j++)
{
      Index[0] = i;
      Index[1] = j;
     
      Array->MultiDimGetAt(Index, Data);
      cout << Data << endl;
}
     

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008485
Data is declared the same as the elements in your array.
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008489
In your case declare Data as double
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008495
change for(int j=0; j < 3; j++) to for(int j=0; j < 30; j++)
0
 

Author Comment

by:Rothbard
ID: 17008514
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now