Address of a var
Address of a var
Address of a var
Address of a var
Address of a var
Address of a var Address of a var Address of a var Address of a var Address of a var Address of a var Address of a var Address of a var
Address of a var Address of a var
Address of a var
Go Back  Xtreme Visual Basic Talk > > > Address of a var


Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2003, 09:06 PM
ReadError's Avatar
ReadError ReadError is offline
Junior Contributor
 
Join Date: Nov 2003
Location: Québec city, Canada
Posts: 310
Question Address of a var


Maybe it's simple but, since we don't have VarPtr anymore, how do we get the address of a variable?
Reply With Quote
  #2  
Old 12-19-2003, 09:42 PM
reboot's Avatar
rebootAddress of a var reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

Why would you need to?
Reply With Quote
  #3  
Old 12-20-2003, 02:38 AM
OnErr0r's Avatar
OnErr0rAddress of a var OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

reboot is right, it's not something you normally do in .net. You can using the following snippet from my Direct Bitmap Memory Manipulation sample (See the Code Library):

GCHandle = Runtime.InteropServices.GCHandle.Alloc(bmpData, Runtime.InteropServices.GCHandleType.Pinned)
bmpAddress = GCHandle.AddrOfPinnedObject()


bmpData is an array, which you want "pinned", in my limited .net understanding means, it's not going to be deallocated/moved elsewhere by GC (Garbage Collection)

And bmpAddress is an IntPtr (can accomodate 64bit pointers, which will be important on 64bit OSes) that points to the array.
Reply With Quote
  #4  
Old 12-21-2003, 12:43 AM
ReadError's Avatar
ReadError ReadError is offline
Junior Contributor
 
Join Date: Nov 2003
Location: Québec city, Canada
Posts: 310
Default

Thanks, I was just looking around, trying to "convert" the GetHiWord and GetLoWord functions we often use with subclassing. Is there something already in vb.net to do that?
Reply With Quote
  #5  
Old 12-21-2003, 06:14 PM
OnErr0r's Avatar
OnErr0rAddress of a var OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

HiWord and LoWord don't really require the address of a variable. That was the slow way to do it in VB5/6 too.

Here's the .net way:

Code:
Private Function HiWord(ByVal iDword As Integer) As Short Return CType(iDword >> 16, Short) End FunctionEnd Function ' Use with Integer Overflows disabled ' Project - Properties - Configuration Properties - Optimizations ' Remove Integer Overflow checks Private Function LoWord(ByVal iDword As Integer) As Short Return CType((iDword And &HFFFF), Short) End Function ' Or this one with checks enabled Public Function LoWord2(ByVal iDWord As Integer) As Short If (iDWord And &H8000) <> 0 Then Return CType(iDWord Or &HFFFF0000, Short) Else Return CType(iDWord And &HFFFF, Short) End If End Function
Reply With Quote
  #6  
Old 12-21-2003, 07:35 PM
ReadError's Avatar
ReadError ReadError is offline
Junior Contributor
 
Join Date: Nov 2003
Location: Québec city, Canada
Posts: 310
Default

Thanks a lot
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use an IP Address to get a MAC Address remotely. Meiiko General 3 05-21-2003 05:51 AM
EMAIL ADDRESS FORMAT for Exchange Global Address Book Adresses ohmyigod Communications 5 05-02-2003 10:34 AM
Global Address List florida Web Programming 2 01-21-2003 05:16 AM
Using IP Address Control !! Sabby API 2 07-09-2002 04:47 PM
C/C++ Collection Classes Visual Developer Miscellaneous Languages 3 06-09-2002 02:05 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Address of a var
Address of a var
Address of a var Address of a var
Address of a var
Address of a var
Address of a var Address of a var Address of a var Address of a var Address of a var Address of a var Address of a var
Address of a var
Address of a var
 
Address of a var
Address of a var
 
-->