Solved

How to put and retreive byte array through SAFEARRAY

Posted on 2003-12-02
7
1,292 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find Visual Studio Tools 2 126
Create a path if not exists 7 109
gdb doesn't stop on breakpoint 2 114
Android development question 2 82
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

697 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