Technical Document #24

Technical Document #24
If a variable requires a pointer to be assigned to it, as in pBuffer = &dwVal, how do I do it in Visual basic (which does not support pointers)?

NOTE: This document refers to development in Visual Basic 6.0, as opposed to Visual Basic .NET which includes direct support for pointers.
For information regarding WinDriver's support for Visual Basic .NET, refer to Technical Document #128.

WinDriver provides you with the function WD_VB_GetAddress() for getting a pointer to a variable — i.e., its address. To obtain the pointer to a variable the function must be called as

     pBuffer = WD_VB_GetAddress (test, 1, 1)
  ' where "test" is the variable whose pointer is required.
  ' The other two parameters must always be one.

You can also use VisualBasic's VarPtr() function to get the pointer to a variable (i.e., it's address).

You can refer to the WinDriver VisualBasic samples and generated DriverWizard code for examples of using both WD_VB_GetAddress() and VarPtr() to acquire a pointer to a variable in Visual Basic.