|
-
March 1st, 2001, 01:15 AM
#1
Get the address of a variable
does anyone know how to get the address of a variable in vb.
like in c, we use the operator &, &variable to get the address of the variable
any advise is appreciated
-
March 1st, 2001, 03:49 AM
#2
Re: Get the address of a variable
There are three undocumented functions in VB5 and 6 that you can use - but bear in mind that they are probably removed by VB.NET:
Dim lAddress as Long
'\\ get address of a variable...
lAddress = VarPtr(variable)
'\\ get address of a string
lAddress = StrPrt(string)
'\\ get address of an object
lAddress = ObjPtr(object)
Bear in mind that these addresses are only valid within your app unless the variables are global.
You should use API functions suct as IsBadStringPointer(), IsBadReadPointer() etc. to validate the address before attemting to pass it to an external DLL or EXE - passing an invalid pointer will cause a GPF.
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
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
|