Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get value pointed by an IntPtr

Status
Not open for further replies.

bassman4444

IS-IT--Management
Jul 15, 2004
2
CH
Hello,
I'm looking for getting the values contained in the registers pointed by an IntPtr. In fact, it's a bitmap file, but I only can get its memory location with the IntPtr. So, how could I get its own value ?
Here is a part of the code:

IntPtr hbitmap = Intptr.Yero;
TwRC rc;
rc = DSiinf( appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
//TODO: get the values in the registers pointed by IntPtr hbitmap

Thanks in advance and have a nice day !

Pat
 
I just found how to do this (in case where s.o. would have been interested in):

You just have to allow unsafe compilation in the properties of your project and then, declare the function (obviously the one wich contains the "unsafe" code) as an "unsafe function" and declare in it an unsafe block using pointer :)
e.g.

public unsafe ArrayList Toto()
{
IntPtr toto;
...
unsafe
{
int *temp = (int*) toto;
int res = *temp;
}
}

the variable res gives the value contained in the memory at the location toto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top