473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Convert array<Byte>^ data to const byte* data

Hello

I am trying to call a function in C from C# though c ++

so basically C# -> C++ - >C

In C#, I have byte[] bytes - which reads the information from the file. I am passing the byte array and the size to C++ .

In C++ I get the byte array and the size but I am not able to convert to the specific data types.

Expand|Select|Wrap|Line Numbers
  1. void Image::OpenMemFile(array<Byte>^ data, unsigned int size)
  2. {
  3.  
  4.     Free();
  5.     m_dataStream = data;
  6.     Byte const* streamData = &data[0];   // this is where it throws error 
  7.          // Should I use marshaling here ? What call should that be ?
  8.          hImage = ::OpenMemImage(streamData , size);
  9.     modified = false;
  10. }
  11.  
  12. // this is the function I need to call 
  13. EXIVSIMPLE_API HIMAGE OpenMemImage(const BYTE *data, unsigned int size)
  14. {
  15.    // code
  16.         imgWrap->image = Exiv2::ImageFactory::open(data, size);
  17.  
  18. }
the C function it needs to call is
Expand|Select|Wrap|Line Numbers
  1. Image::AutoPtr ImageFactory::open(const byte* data, long size)
  2.     {
  3.       /// code
  4.     }
  5.  
I need to help in converting the byte array to const byte* . I realize I need to use Marshaling. Is there a specific function to marshal arrays in C++ ?

Any help is appreciated.

Thanks
Feb 3 '10 #1
1 2637
Banfa
9,065 Expert Mod 8TB
Moved to .NET because this is not C++ but C++/CLR, marshalling is part of the .NET framework
Feb 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Hal Vaughan | last post by:
If I have a byte and I convert it to string (String sData = new String(byte bData), then convert it back (byte bData = sData.getBytes()), will all data be intact, or do Strings have problems with...
16
by: Vince | last post by:
Hi, I have replaced my BYTE* by a vector<BYTE> and before I used to do : void CCardRecord::GetRecData(int nOffset, int nDataSize, CString& csValue) { BYTE *pTmp = NULL; pTmp = new BYTE;...
4
by: zon7mail | last post by:
I've two functions. One is managed and receives an array, and the other is unmanaged and receives a pointer, just like this class A { int Foo(unsigned char* m){}; ... } ref class B {
6
by: msdnuniv | last post by:
Hello everybody, since days i try to convert Unicode-Strings in VB.NET to ANSI which should be processable in VB6 and converted to unicode again. It should be possible with any codepage, e.g....
1
by: Hyun-jik Bae | last post by:
Hi, I heard roughly that List<bytekeep data in one block like byte. Is that really true? Please reply. Thanks in advance. Hyun-jik Bae
43
by: john | last post by:
Hi, in TC++PL 3 on pages 674-675 it is mentioned: "Maybe your first idea for a two-dimensional vector was something like this: class Matrix { valarray< valarray<doublev; public: // ... };
2
by: blueflyy | last post by:
Hello, I wish to initialize a vector<BYTE> from an existing BYTE array. Simple example: BYTE buf = {0,1,2,3,4,5}; std::vector<BYTE> vec(buf, buf + sizeof(buf)/sizeof(buf));
6
by: Bob Altman | last post by:
Hi all, I'm looking for the fastest way to convert an array of bytes to String. I also need to convert a String back to its original Byte() representation. Convert.ToBase64String and...
2
by: Nag76 | last post by:
I have a requirement in the C# app to find if a byte exists as part of byte array and take decision based on that. I came across few of two ways to do that. Use the basic byte Array and use...
9
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I've an optimization question for you all really quick. I have a stream that I am reading some bytes. At times, the stream can contain a small amount of bytes such as 50...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.