delphi XE5 如何決議 未知型別陣列,取出陣列中資料
ArrayOflong = array of Int64;
ArrayOfstring = array of string;
// 獲取物件的 RTTI 屬性與事件的函式
function GetPropertyAndEventList(obj: TObject;
pList, eList: TStringList): Boolean;
var
ClassTypeInfo: PTypeInfo; { 類的資訊結構指標 }
ClassDataInfo: PTypeData; { 類的資料結構指標 }
propertyList: PPropList; { TPropInfo 是屬性的資料結構;
PPropList 是其指標;
TPropList 是屬性結構指標的串列陣列;
PPropList 是指向這個陣列的指標 }
num: Integer; { 記錄屬性的總數 }
size: Integer; { 記錄屬性結構的大小 }
i: Integer;
begin
ClassTypeInfo := obj.ClassInfo; { 先獲取: 類的資訊結構指標 }
ClassDataInfo := GetTypeData(ClassTypeInfo); { 再獲取: 類的資料結構指標 }
num := ClassDataInfo.PropCount; { 屬性總數 }
size := SizeOf(TPropInfo); { 屬性結構大小 }
GetMem(propertyList, size * num); { 給屬性陣列分配記憶體 }
GetPropInfos(ClassTypeInfo, propertyList); { 獲取屬性串列 }
for i := 0 to num - 1 do
begin
if propertyList[i].PropType^.Kind = tkDynArray then
如何能取出資料
else
pList.Add(propertyList[i].Name);
end;
FreeMem(propertyList); { 釋放屬性陣列的記憶體 }
Result := True;
end;
uj5u.com熱心網友回復:
紅色字體部分是取出未知陣列的值轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/64660.html
標籤:語言基礎/算法/系統設計
上一篇:有關網頁的求教
