VB icon

Using real pointers in VB!

Email
Submitted on: 1/8/2015 4:30:00 PM
By: Stephan Kirchmaier (from psc cd)  
Level: Advanced
User Rating: By 5 Users
Compatibility: VB 5.0, VB 6.0
Views: 450
 
     This code uses undocumented functions of VB that gives you a pointer to a string or a number!
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Using real pointers in VB!
'**************************************
Private Declare Sub CopyMemByPtr Lib "kernel32" Alias _
"RtlMoveMemory" (ByVal lpTo As Long, ByVal lpFrom As Long, _
ByVal lLen As Long)
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Using real pointers in VB!
' Description:This code uses undocumented functions of VB that gives you a pointer to a string or a number!
' By: Stephan Kirchmaier (from psc cd)
'**************************************

Private Declare Sub CopyMemByPtr Lib "kernel32" Alias _
"RtlMoveMemory" (ByVal lpTo As Long, ByVal lpFrom As Long, _
ByVal lLen As Long)
Private Sub Form_Click()
Dim a As Long, b As String, c As Long, d As String
Dim i As Integer, j As Long, k As Integer, l As Long
Dim u(2) As Byte, o As Long
b = "HELLO!"
d = Space(Len(b))
i = 20
u(0) = 23
u(1) = 243
u(2) = 124
o = VarPtr(u(0))
j = VarPtr(i)
l = VarPtr(k)
a = StrPtr(b)
c = StrPtr(d)
CopyMemByPtr o + 1, j, Len(u(0)) * 2
CopyMemByPtr l, j, Len(i) * 2
CopyMemByPtr c, a, Len(b) * 2
MsgBox d & vbCr & k & vbCr & u(1)
End Sub


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.