你看这样可以吗 var temp1,temp2,temp:string; begin temp:='sdlkfjalsdkfglasdjf'; temp1:=RightStr(temp,4); temp2:=copy(temp,1,4); temp:=temp1+temp2; ShowMessage(temp); end;
I shr $04; I and $04;
噢, 居然写错了 应该是 I shr $0F I and $0F比方说 01010111 右移4 位 为 00000101 01010111 and 00001111 为 00000111好了, 睡觉!
var
temp1,temp2,temp:string;
begin
temp:='sdlkfjalsdkfglasdjf';
temp1:=RightStr(temp,4);
temp2:=copy(temp,1,4);
temp:=temp1+temp2;
ShowMessage(temp);
end;
I and $04;
I shr $0F
I and $0F比方说
01010111 右移4 位 为 00000101
01010111 and 00001111 为 00000111好了, 睡觉!
I shr $04
I and $0F
另外Char要转为Byte类型
DWORD要如何转换为BYTE类型,Char转为Byte类型
谢谢
var
i : char;
begin
byte(I) Shr $04 取前四位
byte(I) and $0F 取后四位
end;
DWORD -> BYTE Byte(yourbytevariable) 会丢失数据
Char -> Byte Byte(yourcharvariable) 现在不会, 将来可能会
DWORD -> BYTE Byte(yourbytevariable) 会丢失数据
DWORD是32位的,byte是8位当然会丢失数据,这样转换是不是只取DWORD的最底那8位???
我可不可以声明4个byte,然后再对DWORD变量移位,比如这样:
var
b1,b2,b3,b4 : byte;
d : dword;
b1:=byte(d shr 24);
b2:=byte(d shr 16);
b3:=byte(d shr 8);
b4:=byte(d);