首页 > Windows开发 > 详细

Delphi中GUID相等检查中经典指针应用

时间:2015-03-27 16:21:25      阅读:241      评论:0      收藏:0      [点我收藏+]

 

 

type
  PGUID = ^TGUID;
  TGUID = packed record
    D1: LongWord;
    D2: Word;
    D3: Word;
    D4: array[0..7] of Byte;
    class operator Equal(const Left, Right: TGUID): Boolean;
    class operator NotEqual(const Left, Right: TGUID): Boolean;
    class function Empty: TGUID; static;
  end;
 
 IntegerArray  = array[0..$effffff] of Integer;
  PIntegerArray = ^IntegerArray;

function IsEqualGUID(const Guid1, Guid2: TGUID): Boolean;
var
  a, b: PIntegerArray;
begin
  a := PIntegerArray(@Guid1);
  b := PIntegerArray(@Guid2);
  Result := (a^[0] = b^[0]) and (a^[1] = b^[1]) and (a^[2] = b^[2]) and (a^[3] = b^[3]);
end;

 

遗留问题:Word 怎么转换成Ineger的? D2,D3:Word

@Guid1 内存存储结构是什么样的? 0xffff 0xff 0xff 0xff 转到PintegerArray后是什么样的? a^[1]=0xff 还是a^[1]=0xffff 为什么?

 

Delphi中GUID相等检查中经典指针应用

原文:http://www.cnblogs.com/ZhouXiHong/p/4371823.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!