delphi 判断大小端方法
2016-01-28 13:23
561 查看
type
int32 = LongInt;
uint32 = Longword;
int16 = SmallInt;
uint16 = Word; //
int8 = ShortInt;
uint8 = Byte;
type
T_E_ByteOrder =(
EBO_unknown = 0,
EBO_LittleEndian = 1,
EBO_BigEndian = 2 ) ;
Function FindMachineTransferSyntax(): T_E_ByteOrder;
var
localByteOrderFlag: T_E_ByteOrder ;
tl: record
case msg: integer of
0: (ul: uint32);
1: (uc: array[0..3]of uint8);
end;
ts: record
case msg: integer of
0: (us: uint16);
1: (uc: array[0..1]of uint8);
end;
bflag,bflag1: uint8;
begin
tl.msg := 0;
tl.ul := 1;
ts.msg :=0;
ts.us := 1;
bflag := (tl.uc[1] or tl.uc[2] or tl.uc[3]);
bflag1:= (tl.uc[0] or tl.uc[1] or tl.uc[2]);
if (tl.uc[0] = 1)and (bflag = 0)and (ts.uc[0] = 1)and (ts.uc[1] = 0) then
localByteOrderFlag := EBO_LittleEndian
else
if (tl.uc[3] = 1)and(bflag1 = 0)and (ts.uc[1] = 1)and(ts.uc[0] = 0) then
localByteOrderFlag := EBO_BigEndian
else
localByteOrderFlag := EBO_unknown;
result := localByteOrderFlag;
end;
int32 = LongInt;
uint32 = Longword;
int16 = SmallInt;
uint16 = Word; //
int8 = ShortInt;
uint8 = Byte;
type
T_E_ByteOrder =(
EBO_unknown = 0,
EBO_LittleEndian = 1,
EBO_BigEndian = 2 ) ;
Function FindMachineTransferSyntax(): T_E_ByteOrder;
var
localByteOrderFlag: T_E_ByteOrder ;
tl: record
case msg: integer of
0: (ul: uint32);
1: (uc: array[0..3]of uint8);
end;
ts: record
case msg: integer of
0: (us: uint16);
1: (uc: array[0..1]of uint8);
end;
bflag,bflag1: uint8;
begin
tl.msg := 0;
tl.ul := 1;
ts.msg :=0;
ts.us := 1;
bflag := (tl.uc[1] or tl.uc[2] or tl.uc[3]);
bflag1:= (tl.uc[0] or tl.uc[1] or tl.uc[2]);
if (tl.uc[0] = 1)and (bflag = 0)and (ts.uc[0] = 1)and (ts.uc[1] = 0) then
localByteOrderFlag := EBO_LittleEndian
else
if (tl.uc[3] = 1)and(bflag1 = 0)and (ts.uc[1] = 1)and(ts.uc[0] = 0) then
localByteOrderFlag := EBO_BigEndian
else
localByteOrderFlag := EBO_unknown;
result := localByteOrderFlag;
end;
相关文章推荐
- Delphi 62进制转10进制
- 关于socket error 10054
- 我写过的Delphi程序(从大学到工作)
- Delphi 编码常用快捷键
- 使用Delphi实现票据精确打印
- Delphi的CPU调试窗口
- 开源的Delphi性能调试工具
- Delphi 7中ADO控件打开Access数据库文件
- Delphi 调试
- Calling 64-bit assembly language functions lodged inside the Delphi source code
- delphi imagen usb vid&pid
- delphi 浮点 精度
- Delphi中TStringList类常用属性方法详解
- 一个开源Delphi分类组件推荐网页
- Delphi XE6 试用Android视频采集
- Delphi获取其它进程窗口句柄的3种方法
- delphi 线程 TTask
- 常用delphi funtion
- delphi 年月日自动加一减一函数,月加一,月减一
- delphi 如何判断编码格式,解决乱码问题