Delphi 类与对象内存结构浅析(附件2)
*类的公开属性(代码)
示例:访问类的published属性
说明:vmtFieldTable(Published Field表)指向Published Field表有序排列,只存储当前类的PublishedField表,得到父类的Published Field表需要往上遍历。
注意:只有类型是类或接口的数据成员才可定义为published的访问级别
代码:
type
TMyObject = class(TObject)
private
FField1: Integer;
FField2: string;
FField3: array[0..2] of Integer;
published
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
AObject: TMyObject;
//---
procedure _ShowDMTInfo(ALines: TStrings; AClass: TClass);
var
AClassAddress,AFTAddress: Integer;
AFieldCount,AFieldIndex,AFieldOffset,AFieldNameLen: Integer;
APos,i: Integer;
AFieldName: ShortString;
begin
AClassAddress := Integer(AClass);
with ALines do
begin
Add(Format('类名: %s ', [AClass.ClassName]));
//---
AFTAddress := Integer(PPointer(AClassAddress + vmtFieldTable)^);
if AFTAddress = 0 then
&n
相关文档:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button ......
Delphi中建议使用的语句
楼主zswang(伴水清清)(专家门诊清洁工)2002-05-15 13:37:54 在 Delphi / VCL组件开发及应用 提问
No.1 判断逻辑类型
var B: Boolean;
begin
B := Boolean(2); //这样只是为了调试//B ......
Delphi 能不能从Ring 3进入Ring 0?
楼主skyworld_xm(skyworld)2004-11-19 09:58:55 在 Delphi / Windows SDK/API 提问
Delphi 能不能从Ring 3进入Ring 0?
有例子吗?
多谢. 问题点数:100、回复次数:20Top
1 楼jinjazz(近身剪)回复于 2004-11-19 10:13:27 得 ......
1.因为KeyPreview默认是 False;我们这里需要响应键盘事件的话,需要将其修改为True;
所以KeyPreview:=True; 这对一些快捷键会有用。
在窗体属性上修改KeyPreview := True;
2.在窗体的FormKeyDown函数里写:
if KeyPreview then
Form将先响应键盘事件(在TEdit等控件之前)
else
除非Fo ......
附件资料
*类的内存信息(代码)
示例:获取类信息
说明:比对通过类地址以及通过类方法获取信息的效果。
代码:
type
TMyObject = class(TObject)
private
FData: Integer;
protected
......