473,472 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to move a intptr in vb.net 2003

As a simple example starting with a memory pointer location I need to do 10
operations, (like copying 10 values to an array for instance), then when
that's done, move the pointer to the eleventh location so that I can then
use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

How can you do this in vb.net 2003

Thanks for any help
Bob

Mar 16 '07 #1
11 2294
Robert Dufour wrote:
As a simple example starting with a memory pointer location I need to do 10
operations, (like copying 10 values to an array for instance), then when
that's done, move the pointer to the eleventh location so that I can then
use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x
I'm not aware of support for pointer arithmetic with IntPtr's. Maybe
you can get by with manual incrementing of the pointer, but this needs
to be well thought out. Do you need to point to a position ten *bytes*
away or one ten *elements* away? If the former, you'll need to
consider the element's size. A call to
System.Runtime.InteropServices.Marshal would help in this case.

<aircode>
'ten *bytes* away
Ptr = New IntPtr(Ptr.ToInt64 + 10)

'ten *elements* away
Ptr = New IntPtr(Ptr.ToInt64 + 10 * _
System.Runtime.InteropServices.Marshal.SizeOf(Elem entType))
</aircode>
HTH.

Regards,

Branco.

Mar 16 '07 #2
Hi Robert,

"ptr1 = Ptr1 + 10 'Does not work"

I don't have a whole bunch of experience with pointers in vb.net (only been
programming vb.net a few months now)
In C++ (bare with me here) Incrementing a pointer is going to move it along
as many bytes as the sizeof the datatype it is pointing / refering to, this
I do not think is the case with vb.net

I think that incrementing an IntPtr in .net is only going to make it walk
one byte forward in memory, so unless your array is of type "byte" or "char"
it is not going to be moving with the correct offset.

so lets say you are pointing to an array of integers (on 32 bit computer)
then

ptr1 = Ptr1 + 40

Or in other words:
ptr1 = ptr1 + 10 * dataTypeSize

Regards,

Mike
"Robert Dufour" <bd*****@sgiims.comwrote in message
news:eb**************@TK2MSFTNGP02.phx.gbl...
As a simple example starting with a memory pointer location I need to do
10 operations, (like copying 10 values to an array for instance), then
when that's done, move the pointer to the eleventh location so that I can
then use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

How can you do this in vb.net 2003

Thanks for any help
Bob

Mar 16 '07 #3
Sorry I have kind of repeated what you answered, your post was not visible
when I hit the reply group button.

"Branco Medeiros" <br*************@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
Robert Dufour wrote:
>As a simple example starting with a memory pointer location I need to do
10
operations, (like copying 10 values to an array for instance), then when
that's done, move the pointer to the eleventh location so that I can then
use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can
pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

I'm not aware of support for pointer arithmetic with IntPtr's. Maybe
you can get by with manual incrementing of the pointer, but this needs
to be well thought out. Do you need to point to a position ten *bytes*
away or one ten *elements* away? If the former, you'll need to
consider the element's size. A call to
System.Runtime.InteropServices.Marshal would help in this case.

<aircode>
'ten *bytes* away
Ptr = New IntPtr(Ptr.ToInt64 + 10)

'ten *elements* away
Ptr = New IntPtr(Ptr.ToInt64 + 10 * _
System.Runtime.InteropServices.Marshal.SizeOf(Elem entType))
</aircode>
HTH.

Regards,

Branco.

Mar 16 '07 #4
"Robert Dufour" <bd*****@sgiims.comschrieb:
As a simple example starting with a memory pointer location I need to do
10 operations, (like copying 10 values to an array for instance), then
when that's done, move the pointer to the eleventh location so that I can
then use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

How can you do this in vb.net 2003
In addition to the other replies, you can use the 'Marshal' class to
populate the array using data read from the memory location too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 17 '07 #5
Thanks to all, actually I'm trying to get my head around manipulating bytes
in bitmaps and copying from an old bitmap in rgb24 to a monochrome bitmap,
the samples of code I saw had things like intptr and I never used them
before. Never had to do any graphics before so I'm learning
Thanks
Bob
"Robert Dufour" <bd*****@sgiims.comwrote in message
news:eb**************@TK2MSFTNGP02.phx.gbl...
As a simple example starting with a memory pointer location I need to do
10 operations, (like copying 10 values to an array for instance), then
when that's done, move the pointer to the eleventh location so that I can
then use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

How can you do this in vb.net 2003

Thanks for any help
Bob

Mar 17 '07 #6
Robert Dufour wrote:
Thanks to all, actually I'm trying to get my head around manipulating bytes
in bitmaps and copying from an old bitmap in rgb24 to a monochrome bitmap,
<snip>

Maybe the GDI+ library can be used instead of trying to deal directly
with the bits... I remember once using BitBlt (from the Win32 gdi
library) to copy whatever bits I needed between bitmats of different
formats. I suppose GDI+ is capable of that much and more...

Regards,

Branco.

Mar 17 '07 #7
Thanks that's what I'm trying to use.
Bob
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:ud****************@TK2MSFTNGP06.phx.gbl...
"Robert Dufour" <bd*****@sgiims.comschrieb:
>As a simple example starting with a memory pointer location I need to do
10 operations, (like copying 10 values to an array for instance), then
when that's done, move the pointer to the eleventh location so that I can
then use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

How can you do this in vb.net 2003

In addition to the other replies, you can use the 'Marshal' class to
populate the array using data read from the memory location too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 17 '07 #8
I thought so but I can't find a way to do it.
There's a lot of stuff out ther doing this, so it must be possible.
I'm just trying to understand how it can be done.
I only found one thing that worked Ok for what I needed to do and it was the
Universal document converter but that works as a printer driver, so a user
could go in and change settings on his machine and my program would be
screwed up.
Thats why I am trying to roll my own.
Basic problem is I'm too stupid to be able to make sense out of all the docs
out there and put it all together in a simple way thats gonna be easy to
maintain later.
Regards,
Bob


"Branco Medeiros" <br*************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
Robert Dufour wrote:
>Thanks to all, actually I'm trying to get my head around manipulating
bytes
in bitmaps and copying from an old bitmap in rgb24 to a monochrome
bitmap,
<snip>

Maybe the GDI+ library can be used instead of trying to deal directly
with the bits... I remember once using BitBlt (from the Win32 gdi
library) to copy whatever bits I needed between bitmats of different
formats. I suppose GDI+ is capable of that much and more...

Regards,

Branco.

Mar 17 '07 #9
Thanks Michael
In been doing a LOT of reading up on all this and I WILL get it.
Gonna keep plugging at it,

Regards,
Bob
"Michael M." <no****@mike.comwrote in message
news:eO*************@TK2MSFTNGP06.phx.gbl...
Hi Robert,

"ptr1 = Ptr1 + 10 'Does not work"

I don't have a whole bunch of experience with pointers in vb.net (only
been programming vb.net a few months now)
In C++ (bare with me here) Incrementing a pointer is going to move it
along as many bytes as the sizeof the datatype it is pointing / refering
to, this I do not think is the case with vb.net

I think that incrementing an IntPtr in .net is only going to make it walk
one byte forward in memory, so unless your array is of type "byte" or
"char" it is not going to be moving with the correct offset.

so lets say you are pointing to an array of integers (on 32 bit computer)
then

ptr1 = Ptr1 + 40

Or in other words:
ptr1 = ptr1 + 10 * dataTypeSize

Regards,

Mike
"Robert Dufour" <bd*****@sgiims.comwrote in message
news:eb**************@TK2MSFTNGP02.phx.gbl...
>As a simple example starting with a memory pointer location I need to do
10 operations, (like copying 10 values to an array for instance), then
when that's done, move the pointer to the eleventh location so that I can
then use the next ten values, etc
Dim Ptr1 as IntPtr
For x = 0 to 100
'Do something like getting 10 values from memory from this block,
initailly at ptr1
'next move the pointer to a new position 10 units so that I can pickup
the next 10 values
ptr1 = Ptr1 + 10 'Does not work
next x

How can you do this in vb.net 2003

Thanks for any help
Bob


Mar 17 '07 #10
On Mar 17, 12:43 pm, "Robert Dufour" <bduf...@sgiims.comwrote:
Thanks to all, actually I'm trying to get my head around manipulating bytes
in bitmaps and copying from an old bitmap in rgb24 to a monochrome bitmap,
Try this site: www.bobpowell.net
And more specifically this link: http://www.bobpowell.net/onebit.htm

Chris

Mar 19 '07 #11
Robert Dufour wrote:
<backposted/>

What exactly are you trying to do?

Branco.
I thought so but I can't find a way to do it.
There's a lot of stuff out ther doing this, so it must be possible.
I'm just trying to understand how it can be done.
I only found one thing that worked Ok for what I needed to do and it was the
Universal document converter but that works as a printer driver, so a user
could go in and change settings on his machine and my program would be
screwed up.
Thats why I am trying to roll my own.
Basic problem is I'm too stupid to be able to make sense out of all the docs
out there and put it all together in a simple way thats gonna be easy to
maintain later.
Regards,
Bob

"Branco Medeiros" <branco.medei...@gmail.comwrote in message

news:11**********************@n76g2000hsh.googlegr oups.com...
Robert Dufour wrote:
Thanks to all, actually I'm trying to get my head around manipulating
bytes
in bitmaps and copying from an old bitmap in rgb24 to a monochrome
bitmap,
<snip>
Maybe the GDI+ library can be used instead of trying to deal directly
with the bits... I remember once using BitBlt (from the Win32 gdi
library) to copy whatever bits I needed between bitmats of different
formats. I suppose GDI+ is capable of that much and more...
Regards,
Branco.

Mar 19 '07 #12

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

Similar topics

1
by: Bob | last post by:
This is a VB.net 2003 question I have a function called HandleES that expects a "ByVal lpES As IntPtr" paramter in My1.DLL I would like to call the function from My2.DLL. In My2.DLL I've...
2
by: Nuno Esculcas | last post by:
Hello, I come from C++ and i now have to work with C#, and someone tell me that bye bye pointers but i think this is not true, i must convert a DIB image in something that i can use in C# (like...
2
by: Jurate | last post by:
I want my window not to have title bar, but then the problem arises, how to move such a window. Is it possible to make window move by moving mouse anywhere on that window? -- Jurate
6
by: Nikki | last post by:
Hi, Can anybody help me in solving this problem. I m developing an application in which the main application form is borderless. now i m not able to move the application form with the help of...
5
by: Andrey Simanovsky | last post by:
Consider the following code snippet: using System; enum E { A, } struct T { public static explicit operator T(int i) { return new T(); } public static void Foo() { E e = 0;
3
by: Ken Varn | last post by:
I have a managed C++ function that accepts an IntPtr argument. I am passing in a variable of type HANDLE for the IntPtr argument. The compiler does not issue any warnings for this, so I am...
4
by: Pieter | last post by:
Hi, On the pc of one of my clients (W2000, Office 2003) I'm getting sometimes an exception when moving (Move) a MailItem to an Outlook-Folder: The RPC server is not available. (Exception from...
29
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. How do I...
0
by: Paul | last post by:
Hi, I am looking to create an eLearning resource using VB2008. I have a form with a background picture of a cross section of a strand of hair magnified x1000. The around the edge of the hair...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
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...
0
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...

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.