// 定义结构体

type
TmyRec= record
name:string[10];
password:string[10];
end;

function RawToBytes(const AValue; const ASize: Integer): TBytes;
begin
SetLength(Result, ASize);
if ASize > 0 then begin
Move(AValue, Result[0], ASize);
end;
end;

procedure BytesToRaw(const AValue: TBytes; var VBuffer; const ASize: Integer);
begin
Assert(Length(AValue) >= ASize);
Move(AValue[0], VBuffer, ASize);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
rec: TmyRec;
rec2: TmyRec;
db:TBytes;
begin
rec.name :='cxg';
rec.password:='929';
// 序列结构体为bytes
db := RawToBytes(rec, SizeOf(rec));
// bytes还原结构体
BytesToRaw(db, rec2, SizeOf(rec2));
Caption := rec2.name+'\'+rec2.password;
end;

http://www.cnblogs.com/hnxxcxg/p/4253919.html

最新文章

  1. netfx_NativeCompilation.msi 传说中的 .NET Native 预览版的文件列表
  2. High Aavialability with Group Replication-by宋利兵
  3. Spring使用p名称空间配置属性
  4. Linux下mysql自动备份
  5. ASP.NET中App_Code,App_Data等文件夹的作用
  6. SQLite学习第01天:参考资料
  7. injector
  8. sqlserver 分页查询总结
  9. .NET开发邮件发送功能
  10. hdu 2157 How many ways?? (可达矩阵)
  11. intra调用order
  12. WinAPI 字符及字符串函数(5): IsCharAlpha - 是否是个字母
  13. Kong安装教程(v1.0.2)
  14. 自学Linux Shell10.1-使用编辑器vim
  15. linux 下git使用教程
  16. [py]python中的==和is的区别
  17. jni 找不到本地方法的实现
  18. NavRouter
  19. 常用HTML标签的全称及描述
  20. Disillusioning #1 水题+原题赛(被虐瞎)

热门文章

  1. javascript (string 部分)
  2. pay包注释(一)
  3. activebar的用法
  4. CPU满格的元凶,这回是由于QTimer引起的(默认interval是0,太猛)
  5. CMake初步(1)
  6. k路归并(败者树,记录败者)
  7. java socket线程通信
  8. 原生app与web app的比较
  9. File 操纵目录
  10. python-Day5-深入正则表达式--冒泡排序-时间复杂度 --常用模块学习:自定义模块--random模块:随机验证码--time & datetime模块