各位高手,如何用按位与获得信息??? ( 积分: 100 )

  • 主题发起人 主题发起人 rzqcjwrz
  • 开始时间 开始时间
R

rzqcjwrz

Unregistered / Unconfirmed
GUEST, unregistred user!
海康卡中有一函数:
int _stdcall Mp4_ClientIsSupport()系统是否支持网络播放器.返回值的低8位每位表示一个信息.用按位与获得信息.
如何得到每一位???
 
if I and 1 = 1 then
//最后一位为1,否则为0 //00000001
if I and 2 = 2 then
//倒数第二位为1,否则为0 //00000010
if I and 4 = 4 then
//..第三位....... //00000100
if I and 8 = 8 then

...
..
if I and 128 = 128 then
//倒数第八位为1,否则为0 //10000000
当然也可以有其它的,
if I and 3 = 3 then
//最后两位为1,否则为0 //00000011
 
ANiDelphi:请问Mp4_ClientIsSupport是不是这样表达:
var
i:integer;
begin

i:=inttohex(Mp4_ClientIsSupport());
if I and 1 = 1 then
//最后一位为1,否则为0 //00000001
if I and 2 = 1 then
//倒数第二位为1,否则为0 //00000010
if I and 4 = 1 then
//..第三位....... //00000100
if I and 8 = 1 then

...
..
end.

我这样对???
 
ANiDelphi:返回值的[red]低8位[/red]每位表示一个信息.用按位与获得信息.
 
var
Newtemp:integer;
begin

Newtemp:=lobyte(MP4_ClientIsSupport());
if Newtemp and 1 = 1 then

ShowMessage(' SUPPORT_DDRAW')
else

ShowMessage(' Not SUPPORT_DDRAW');
if Newtemp and 2 = 2 then

ShowMessage(' SUPPORT_BLT')
else

ShowMessage(' Not SUPPORT_BLT');
if Newtemp and 3 = 4 then

ShowMessage(' SUPPORT_BLTFOURCC')
else

ShowMessage('Not SUPPORT_BLTFOURCC');
if Newtemp and 4 = 8 then

ShowMessage(' SUPPORT_BLTSHRINKX')
else

ShowMessage('Not SUPPORT_BLTSHRINKX');
if Newtemp and 5 = 16 then

ShowMessage(' SUPPORT_BLTSHRINKY')
else

ShowMessage('Not SUPPORT_BLTSHRINKY');
if Newtemp and 6 = 32 then

ShowMessage(' SUPPORT_BLTSTRETCHX')
else

ShowMessage('Not SUPPORT_BLTSTRETCHX');
if Newtemp and 7 = 64 then

ShowMessage(' SUPPORT_BLTSTRETCHY')
else

ShowMessage('Not SUPPORT_BLTSTRETCHY');
if Newtemp and 8 = 128 then

ShowMessage('SUPPORT_CPU')
else

ShowMessage('Not SUPPORT_CPU');
end;

我这样对吗?
如果不用showmessage,要显示在label1.caption中该怎么办:?
 
不好意思,昨晚写错了,应该是这样的(已在原帖修改)

当然要写成函数了。应该是2的n次方n为0-7(即1, 2, 4, 8, 16, 32, 64, 128),当然Delphi习惯用十六进制表示的
function GetStatus: string;
var
NewTemp: Integer;
begin

Newtemp:=lobyte(MP4_ClientIsSupport());
//如果是低八位的话,不用lobyte也行
if Newtemp and 1 = 1 then

Result := ' SUPPORT_DDRAW'
else

Result := ' Not SUPPORT_DDRAW';
if Newtemp and 2 = 2 then

Result := ' SUPPORT_BLT'
else

Result := ' Not SUPPORT_BLT';
if Newtemp and 4 = 4 then

Result := ' SUPPORT_BLTFOURCC'
else

Result := 'Not SUPPORT_BLTFOURCC';
if Newtemp and 1288 = 128 then

Result := 'SUPPORT_CPU'
else

Result := 'Not SUPPORT_CPU';
end;


Label1.Caption := GetStatus;
 
谢谢你!!!
 
function TForm1.GetStatus: string;
//检测显卡和CPU
var
NewTemp: Integer;
begin

Newtemp:=lobyte(MP4_ClientIsSupport());
//如果是低八位的话,不用lobyte也行
if Newtemp and 1 = 1 then

Result := Result+'SUPPORT_DDRAW'+#13#10
else

Result :=Result+'Not SUPPORT_DDRAW'+#13#10;
if Newtemp and 2 = 2 then

Result := Result+'SUPPORT_BLT'+#13#10
else

Result :=Result+'Not SUPPORT_BLT'+#13#10;
if Newtemp and 4 = 4 then

Result := Result+'SUPPORT_BLTFOURCC'+#13#10
else

Result :=Result+ 'Not SUPPORT_BLTFOURCC'+#13#10;
if Newtemp and 5 = 16 then

Result := Result+'SUPPORT_BLTSHRINKY'+#13#10
else

Result := Result+'Not SUPPORT_BLTSHRINKY'+#13#10;
if Newtemp and 6 = 32 then

Result := Result+'SUPPORT_BLTSTRETCHX'+#13#10
else

Result := Result+'Not SUPPORT_BLTSTRETCHX'+#13#10;
if Newtemp and 7 = 64 then

Result := Result+'SUPPORT_BLTSTRETCHY'+#13#10
else

Result := Result+'Not SUPPORT_BLTSTRETCHY'+#13#10;
if Newtemp and 8 = 128 then

Result := Result+'SUPPORT_CPU'+#13#10
else

Result := Result+'Not SUPPORT_CPU'+#13#10;
end;
 
后退
顶部