Solved

How to put and retreive byte array through SAFEARRAY

Posted on 2003-12-02
7
1,278 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

757 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

20 Experts available now in Live!

Get 1:1 Help Now