Frage

Dies ist ein Ausschnitt aus meinem Code.

Declare Function ReadProcessMemory Lib "kernel32" _
                              (ByVal hProcess As Long, _
                              ByVal lpBaseAddress As Long, _
                              lpBuffer As Any, _
                              ByVal nSize As Long, _
                              lpNumberOfBytesRead As Long) As Long

Dim bytearray As String * 65526
Dim GetWindowsFormsID

ReadProcessMemory(processHandle, bufferMem, ByVal bytearray, size, lp)
GetWindowsFormsID = ByteArrayToString(bytearray, retLength)

Function ByteArrayToString(bytes As String, length As Long) As String
    Dim retValStr As String
    Dim l As Long
    retValStr = String$(length + 1, Chr(0))
    l = WideCharToMultiByte(CP_ACP, 0, bytes, -1, retValStr, length + 1, Null, Null)
    ByteArrayToString = retValStr
End Function

Ich habe '94 null‘Fehler beim WideCharToMultiByte aufrufen. Aber ich bin sicher, dass Bytes ist nicht leer.

alt text

Ist dies der genaue Ablauf dieser Ausgabe in String zu konvertieren?

War es hilfreich?

Lösung

OK, das ist gelöst (und auch diese Frage ) . Das Problem ist eigentlich WideChar Zeichenfolge in ANSI-Zeichenfolge konvertieren. Ich benutze Copymemory statt WideCharToMultiByte.

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Function ByteArrayToString(bytes As String, Length As Long) As String
    Dim retValStr As String
    retValStr = String(Length - 1, Chr$(0))
    CopyMemory ByVal StrPtr(retValStr), ByVal bytes, Length * 2
    ByteArrayToString = retValStr
End Function
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top