DWORD WINAPI GetDyncodeSize(PBYTE pb)
{
DWORD dwRet = 0;
while ( TRUE )
{
++dwRet;
if ( *pb++ == 0xC3 )
break;
}
return dwRet;
}
谁能将这段C代码转成delphi的?

解决方案 »

  1.   

    代码没测试function GetDyncodeSize(pb:PByte):LongInt;stdcall;
    var
      dwRet: LongInt;
    begin
      dwRet := 0;
      while true do begin
        Inc(dwRet);
        if pb^=0$c3 then
          break;
        Inc(pb);
      end;
      result := dwRet;
    end;
      

  2.   

    function GetDyncodeSize(pb:PByte):DWORD;stdcall;
    begin
      result := 0;
      while true do
      begin
        Inc(result);
        if pb^=$c3 then
          break ;
        Inc(pb);
      end;
    end;
      

  3.   

    function GetDyncodeSize(pb:PByte):LongInt;stdcall;
    var
      p: PByte;
    begin
      p := pb;
      while p^ <> $c3 do Inc(p);
      Result := LongInt(p) - LongInt(pb) + 1;
    end;