Einzelnen Beitrag anzeigen

venice2
(Gast)

n/a Beiträge
 
#23

AW: array of record sortieren

  Alt 9. Dez 2020, 15:45
buf: array [0 .. 255] of Char;

ListView_GetItemText entspricht in dieser Delphi-Version ListView_GetItemTextW und erwartet als Buffer ein Array aus WideChar
Als Buffergröße muss nicht die maximale Anzahl der Byte, sondern die maximale Anzahl der WideChar (je 2 Byte) angegeben werden.
Delphi-Quellcode:
buf: array [0 .. 255] of WideChar;

ListView_GetItemText(hListView, i, 1, buf, Length(buf));
Die Stringliste wird korrekt mit den Daten gefüllt.
Das Problem ist das Array.


Exception:
------------------------------------------------------------------------------------
2.2 Address: 0238A332
2.5 Type : EBufferOverflowError
2.6 Message: Application has corrupted the memory: $0674EB40 ARRAY [?] 5128 bytes.
2.7 ID : E53C0000
2.11 Sent : 0

Call Stack Information:
--------------------------------------------------------------------------------------------------------------------------------------
|Methods |Details|Stack |Address |Module |Offset |Unit |Class |Procedure/Method |Line |
--------------------------------------------------------------------------------------------------------------------------------------
|*Exception Thread: ID=2236; Parent=0; Priority=0 |
|Class=; Name=MAIN |
|DeadLock=0; Wait Chain= |
|Comment= |
|------------------------------------------------------------------------------------------------------------------------------------|
|7FFFFFFE|03 |00000000|0238A337|SK_Aero.dll |0000A337|System | |_DynArrayClear | |
|00000020|04 |0019D9D0|0256B1A7|SK_Aero.dll |001EB1A7|uListView|TSkinListView|SortItems |1863[42] |
|00000020|03 |0019E1C0|7742E892|a |0001E892|recursive|area |removed |3[0] |
|00000020|03 |0019E464|023896CA|SK_Aero.dll |000096CA|System | |_CopyRecord | |
|00000020|04 |0019E47C|0256B10F|SK_Aero.dll |001EB10F|uListView|TSkinListView|SortItems |1848[27] |
|00000020|04 |0019E6CC|02569C24|SK_Aero.dll |001E9C24|uListView|TSkinListView|ListViewProc |1271[40] |



definition von ListView_GetItemText
D2010
Delphi-Quellcode:
function ListView_GetItemText(hwndLV: HWND; i, iSubItem: Integer;
  pszText: PWideChar; cchTextMax: Integer): Integer;
D10.4
LPWSTR = PWideChar!
Delphi-Quellcode:
function ListView_GetItemText(hwndLV: HWND; i, iSubItem: Integer;
  pszText: LPWSTR; cchTextMax: Integer): Integer;
Sollte also gleich sein. Aber . Ja! Ich habe es getestet macht keinen unterschied. Danke
Anwendung stürzt ab innerhalb des Arrays

Geändert von venice2 ( 9. Dez 2020 um 17:54 Uhr)
  Mit Zitat antworten Zitat