zoukankan      html  css  js  c++  java
  • Delphi中GUID相等检查中经典指针应用

    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 为什么?
  • 相关阅读:
    月食照片
    宾得镜头大全与发展史
    月食照片
    关于镜头系数的疑问
    经验和教训
    常用正则表达式
    12月19日
    部長面談
    周六
    异度空间
  • 原文地址:https://www.cnblogs.com/ZhouXiHong/p/4371823.html
Copyright © 2011-2022 走看看