473,383 Members | 1,859 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,383 software developers and data experts.

Converting IntPtr to byte[]

Can anyone help in converting an IntPtr to a byte[]?
It's not obvious to me how to do that. It seems maybe
that the Marshal.PtrToStructure() method is the way to
go, but I've been having trouble getting that to do what
I want. Any help is appreciated
Jul 19 '05 #1
1 1792
Brian,
Can anyone help in converting an IntPtr to a byte[]?
It's not obvious to me how to do that. It seems maybe
that the Marshal.PtrToStructure() method is the way to
go, but I've been having trouble getting that to do what
I want.


Try Marshal.Copy instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 19 '05 #2

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

Similar topics

2
by: Brian Harleton | last post by:
Having trouble figuring out the best way to convert an IntPtr to a byte without losing any data. Looks like I need to use Marshal.PtrToStructure(), but I'm not having any luck with that. Any...
1
by: Gaz | last post by:
Hi all, I'm using a 3rd party Assembly that contains a method which returns bitmap data, however the Return value type is IntPtr and I need to convert it so I can access the Bitmap data: I'm...
8
by: iyuen | last post by:
I'm having problems with converting a byte array to an image object~ My byte array is an picture in VB6 StdPicture format. I've used propertybag to convert the picture into base64Array format in...
5
by: _BNC | last post by:
I've converted " byte" to "byte *" at times, using 'unsafe' and fixed { .... }, but the reverse does not seem to work. In this case, a C++ DLL returns a byte * and a length. What is the best...
1
by: Jan Nielsen | last post by:
In a C# application I'm using the NetShareGetInfo API function to get some information about a share. This is working all right. Now I want my application to be able to display the contents of...
5
by: Robin Tucker | last post by:
I need to marshal an IntPtr (which I've got from GlobalLock of an HGLOBAL) into a byte array. I know the size of the array required and I've got a pointer to the blob, but I can't see how to copy...
5
by: David | last post by:
I note that you can null teminate a string by adding controlchar.null. Is there a way of adding a null to a Buffer of Bytes and converting it to a string. I have packets coming in from a...
6
by: DaTurk | last post by:
Hi, I have several interfaces in CLI that I access via c#. My problem is, is that down in the unmanaged c++, which the CLI lies on top of, I have a lot of c_str() happening. But all of my...
1
by: Beorne | last post by:
I have imported a corporate image handling COM object in my C# project. To access in a fast way the memory of the image there is a method that returns a pointer to the memory (in byte) of the...
5
by: Bob Altman | last post by:
Hi all, I'm writing C++/CLI code (compiled with /clr) that accepts a native char array (and its length) and calls a managed routine that expects an array of System::Byte. I was just wondering...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.