文件名称:Delphi7 向XML中添加RTTI信息.rar
文件大小:8KB
文件格式:RAR
更新时间:2022-07-30 06:22:46
Delphi源码-文件操作
Delphi7.0 向XML中添加RTTI信息,这个例子挺简单,希望大家喜欢,面向Delphi新手的,高手请绕道哦,下面是本例Delphi向XML中添加RTTI信息的关键性代码: procedure TForm1.ComponentToDOM(iNode: IXmlNode; Comp: TPersistent); var nProps, i: Integer; PropList: PPropList; Value: Variant; newNode: IXmlNode; begin nProps := GetTypeData (Comp.ClassInfo)^.PropCount; GetMem (PropList, nProps * SizeOf(Pointer)); try GetPropInfos (Comp.ClassInfo, PropList); for i := 0 to nProps - 1 do begin Value := GetPropValue (Comp, PropList [i].Name); NewNode := iNode.AddChild(PropList [i].Name); NewNode.Text := Value; if (PropList [i].PropType^.Kind = tkClass) and (Value <> 0) then if TObject (Integer(Value)) is TComponent then NewNode.Text := TComponent (Integer(Value)).Name else ComponentToDOM (newNode, TObject (Integer(Value)) as TPersistent); end; finally FreeMem (PropList); end; end;
【文件预览】:
srcfans.com
----向XML中添加RTTI()
--------Unit1.ddp(51B)
--------Project1.res(876B)
--------Unit1.dcu(6KB)
--------Unit1.dfm(1KB)
--------Project1.cfg(434B)
--------Project1.dpr(188B)
--------Project1.dof(3KB)
--------Unit1.pas(2KB)