Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to put and retreive byte array through SAFEARRAY

Posted on 2003-12-02
7
Medium Priority
?
1,312 Views
Last Modified: 2010-05-18
Hi,

I m relatively new to C++. Can any of them tell me how to put byte array into a safe array and retreive them. I m forced to use this Safe array and i m new to C++. so can anyone post a piece of code for this. Any sample code is appreciated.

Thanks
Ram
0
Comment
Question by:rampriya_sb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9863005
@rampriya_sb:

> I m relatively new to C++. Can any of them tell me how to put byte array into
> a safe array and retreive them. I m forced to use this Safe array and i m new
> to C++. so can anyone post a piece of code for this. Any sample code is appreciated.

Whenever I need to use a SAFEARRAY, I use this class:
     http://www.sellsbrothers.com/tools/comvector.h

Then you can write code like this:
     CComVector<BYTE>   vec;

     vec.Create( 100 );  // Create a safe array with 100 bytes
     {
          CComVectorData<BYTE> data( vec );
         
          data[0] = 0x01;
          data[1] = 0x02;
     }

If you need help using those classes let me know.  They include pretty good examples.

Hope That Helps,
Dex*
0
 

Author Comment

by:rampriya_sb
ID: 9863059
Dex,

Thanks for the help, Yaa, this class seems to be useful and reduces my job i guess... so can u include some more examples on this. you can mail me at rampriya_sb@yahoo.com

Thanks in advance
Ram
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9863073
Ram,

I'd be happy to provide you with another example, but if I e-mail it to you, then it doesn't help anyone else who reads this question.  What do you need to do with the SAFEARRAY?  I'll try to give you an exact example.

Dex*
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:rampriya_sb
ID: 9863131
Dex,

ok, thats fine, I need to pass a byte array in the safe array. I'll be passing the reference of this safe array to another code, where i need to retreive the byte array. So please let me know how to go about using this class...

Thanks
Ram
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9863728
Ram,

Okay, this example will create a SAFEARRAY, copy in a byte array (lpData) that has a size of dwSize:
     CComVector<BYTE>   vec;
     vec.Create( dwSize );
     {
          CComVectorData<BYTE> data( vec );
         
          ::CopyMemory( &(data[0]), lpData, dwSize );
     }
     // Now, you can use "vec" for anything that calls for a SAFEARRAY
     SomeFunc( vec );

What else would you like to see?

Dex*
0
 

Author Comment

by:rampriya_sb
ID: 9870419
Dex*

Thanks a lot for your help, I need another help. I have stored a bmp file in the database. I need to display that on the screen, how do i display that on the screen? can you help me out..

thanks
ram
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 2000 total points
ID: 9870437
Sure, I can help you, but you should open a new question, so that other people can help you too.

If you're done with this question, you should accept an answer.  If you aren't finished, then you should explain what else you need.

Dex*
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

721 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