Hello everyone!

I am in need of help.

My code is suppose to read an address in the memory which holds some text..

When it reads the address it returns numbers instead of text..

By the way if its because I have txt() declared as long then what do I do because if I use string it closes everything including visual basics studio.


Module code
Code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Const PROCESS_ALL_ACCESS = &H1F0FFF




Form code
Code:
Dim hwnd As Long ' Holds the handle returned by FindWindow
Dim pid As Long ' Used to hold the Process Id
Dim pHandle As Long ' Holds the Process Handle
Dim txt(255) As Long
Dim tstring As String
Dim buffer2 As String

' First get a handle to the "game" window
hwnd = FindWindow(vbNullString, "legend of mir2")
If (hwnd = 0) Then MsgBox ("Window not found!")

' We can now get the pid
GetWindowThreadProcessId hwnd, pid

' Use the pid to get a Process Handle

pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)


If (pHandle = 0) Then MsgBox ("Could not get process handle")

' Now we can read from memory

Dim lpBytesWritten As Long
ReadProcessMemory pHandle, &H12AD3F, txt(0), ByVal 255, lpBytesWritten

If lpBytesWritten > 0 Then
  tstring = Trim(StrConv(txt(0), vbUnicode))
  Text1.Text = tstring
Else
  MsgBox Err.LastDllError
End If
' Close the Process Handle
CloseHandle pHandle