|
-
Feb 6th, 2006, 07:31 AM
#1
Thread Starter
Junior Member
Memory Access in VB.Net
Hi Folks,
Quick question - is it possible to access a memory address using vb.net?
For example, if i want to access the memory address 0x00000002 I can type this in C#:
private const int th32CS_SNAPPROCESS = 0x00000002;
But when I try what I think the vb.net version should be:
Private Const th32cs_SnapProcess As Int32 = 0x00000002
However, VS doesnt seem to like this code.
Any ideas why? Is it possible to access memory in vb.net?
All suggestions gratefully recieved!
Thanks
-
Feb 6th, 2006, 07:47 AM
#2
Re: Memory Access in VB.Net
The hexadecimal prefix in VB is "&H", not "0x". VB.NET doesn't support pointers though, so a memoery address won't do you much good.
-
Feb 7th, 2006, 09:24 AM
#3
Thread Starter
Junior Member
Re: Memory Access in VB.Net
-
Feb 7th, 2006, 09:37 AM
#4
Re: Memory Access in VB.Net
I believe you can use the Marshal class to go in and out of managed memory if that helps any
-
Feb 7th, 2006, 09:54 AM
#5
Re: Memory Access in VB.Net
Note that the memory model in the CLR does not guarantee that a variable will stay at the same address - the GC can move things around to make a bit of space. If you have to reference a variable by address (and I suggest that you don't really) then you have to "pin" it to prevent it being moved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|