For the sake of simplicity this call can be wrapped up in two utility functions - one of which returns a Long value from a pointer in another process' memory and another wich returns a string from a pointer in another application's memory thus:-

VB Code:
  1. Private Declare Function ReadProcessMemoryBytes Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, lpBuffer As Byte, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
  2.  
  3. Public Function LongFromOutOfprocessPointer(ByVal hProcess As Long, ByVal lpAddress As Long) As Long
  4.  
  5. Dim lRet As Long
  6. Dim lBytesWritten As Long
  7.  
  8. Call ReadProcessMemory(hProcess, lpAddress, ByVal VarPtr(lRet), Len(lRet), lBytesWritten)
  9. If lBytesWritten > 0 Then
  10.     LongFromOutOfprocessPointer = lRet
  11. End If
  12.  
  13. End Function
  14.  
  15. Public Function StringFromOutOfProcessPointer(ByVal hProcess As Long, ByVal lpString As Long, ByVal Length As Long, ByVal Unicode As Boolean) As String
  16.  
  17. Dim buf() As Byte
  18. Dim lRet As Long
  19. Dim lBytesWritten As Long
  20. Dim sTemp As String
  21.  
  22. ReDim buf(Length) As Byte
  23.  
  24. lRet = ReadProcessMemoryBytes(hProcess, lpString, buf(0), Length, lBytesWritten)
  25. If lBytesWritten = 0 And Err.LastDllError = 0 Then
  26.     While lBytesWritten = 0 And Length > 0
  27.         Length = Length - 1
  28.         lRet = ReadProcessMemoryBytes(hProcess, lpString, buf(0), Length, lBytesWritten)
  29.     Wend
  30. Else
  31.     If Err.LastDllError Then
  32.         Debug.Print LastSystemError
  33.     End If
  34. End If
  35. If lRet <> 0 Then
  36.     If Unicode Then
  37.         StringFromOutOfProcessPointer = StrConv(buf, vbFromUnicode)
  38.     Else
  39.         For lRet = 0 To lBytesWritten
  40.             If buf(lRet) = 0 Then
  41.                 Exit For
  42.             End If
  43.             sTemp = sTemp & Chr$(buf(lRet))
  44.         Next lRet
  45.         StringFromOutOfProcessPointer = sTemp
  46.     End If
  47. Else
  48.     If Err.LastDllError Then
  49.         Debug.Print LastSystemError
  50.     End If
  51. End If

In the second one I have added som error trapping which I recommend using after any API call. The code for LastSystemError is:

VB Code:
  1. Private Declare Function FormatMessage Lib "kernel32"  _
  2.               Alias "FormatMessageA" (ByVal dwFlags As Long,  _
  3.                         ByVal lpSource As Long, _
  4.                         ByVal dwMessageId As Long, _
  5.                         ByVal dwLanguageId As Long, _
  6.                         ByVal lpBuffer As String,  _
  7.                         ByVal nSize As Long, _
  8.                        Arguments As Long) As Long
  9.  
  10. '\\ -- [ LastSystemError ]----------------------------------
  11. '\\ Returns the message from the system which describes the
  12. '\\ last dll error to occur, as
  13. '\\ held in Err.LastDllError. This function should be
  14. '\\ called as soon after the API call
  15. '\\ which might have errored, as this member can be reset
  16. '\\ to zero by subsequent API calls.
  17. '\\ --------------------------------------------------------
  18. Public Function LastSystemError() As String
  19.  
  20. Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
  21. Dim sError As String * 500 '\\ Preinitilise a string buffer to put any error message into
  22. Dim lErrNum As Long
  23. Dim lErrMsg As Long
  24.  
  25. lErrNum = Err.LastDllError
  26.  
  27. lErrMsg = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, lErrNum, 0, sError, Len(sError), 0)
  28.  
  29. LastSystemError = Trim(sError)
  30.  
  31. End Function