Solved

COM Array (CComSafeArray::MultiDimGetAt)

Posted on 2006-06-29
7
699 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

760 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

18 Experts available now in Live!

Get 1:1 Help Now