473,799 Members | 3,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Byte __gc* instead of Byte __gc[]

TGF
Hello,

I am calling a Filestream::Rea d() (i.e. fs->Read(arg1, arg2, arg3)).
The problem is I have a pointer to an unsigned char block of memory and
would like to fill it with the call to 'Read'. However the FileStream::Rea d
function only takes a Byte __gc[] argument. I tried the following
Byte __gc *bytePtr = bufferPtr;

fs->Read(bytePtr , 0, 100);

....It does not allow casting from Byte __gc* to Byte __gc[]. Aren't these
them same thing? That is, aren't both memory objects on the runtime heap
as well as both being pointers (under the hood) to the base address of the
array? Any help on a solution to this would be appreciated.

-TGF


Nov 16 '05 #1
1 1492
> I am calling a Filestream::Rea d() (i.e. fs->Read(arg1, arg2, arg3)).
The problem is I have a pointer to an unsigned char block of memory and
would like to fill it with the call to 'Read'. However the FileStream::Rea d function only takes a Byte __gc[] argument. I tried the following
Byte __gc *bytePtr = bufferPtr;

fs->Read(bytePtr , 0, 100);

...It does not allow casting from Byte __gc* to Byte __gc[]. Aren't these
them same thing?
Nope, not at all.
That is, aren't both memory objects on the runtime heap
as well as both being pointers (under the hood) to the base address of the
array? Any help on a solution to this would be appreciated.


Not exactly. A __gc array has quite a lot of other information available to
the user (such as the length of the array).

In your case, it might depend on where you got bufferPtr from, but it sounds
like you're gonna have to allocate a __gc[] and then copy memory to the
other buffer :(
--
Tomas Restrepo
to****@mvps.org
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3560
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to this method and have it set the instance to hold the right data. >From what I've read it seems I should be able to pass C# objects to managed C++ methods and it should just work; however, when I try it, my C# instance comes out null. If I step...
16
14141
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the byteArray and afterwards see the changes in C#. (if you wanna know more details: the goal is to write the content of an existing char-array in c++ precisely into the passed byteArray, so that after the function has proceded the content of the...
2
3270
by: Josh | last post by:
Hi All, I am trying to write a C# program to call a routine in managed C++. In the routine, the C# program passes a delegate to the managed C++. The delegate looks like this in c++: public __delegate void FoundPidDelegate ( unsigned char *pData, ); The C++ is able to call the C# because my routine in C# is unsafe and
6
1591
by: jlea | last post by:
Does anyone know how to pass a managed array to a method and have that method actually create the array if necessary, ie., if the passed array is null? For example: void AddAttribute(XmlAttribute* attribList, XmlAttribute* anAttrib) { if (attribList == 0L) { attribList = new XmlAttribute * ; attribList = anAttrib; } else {
0
2812
by: Olav Langeland | last post by:
I have a C# Form with a System.Windows.Forms.PropertyGrid(). This uses a Datagram class, implemented in both C# and C++: // C# public class Datagram { public byte _Buffer; // some code...
2
1096
by: Edward Diener | last post by:
I need to pass a pointer to 'int' as a parameter in a managed module to a managed member function. I am assuming I need to box my value. Is this true, or can I just pass the address of my variable ? The variable needs to conform to CLS specifications.
2
4682
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to this method and have it set the instance to hold the right data. >From what I've read it seems I should be able to pass C# objects to managed C++ methods and it should just work; however, when I try it, my C# instance comes out null. If I step...
0
1365
by: volx | last post by:
Hello all: What is the proper way to implement in MC++ a web service which accepts a multi dimensional array as a parameter to one of its methods? This does compile: double pass2DArray(Double array __gc);
3
1904
by: Smugsboy | last post by:
Hello, I would like to know the managed C++ syntax of the following method (defined in C#): void temp(out byte byteArr). I tried something like: void temp( byte byteArr __gc)
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.