BYTE m_byRSWork[MAX_CODEBLOCK];
BYTE m_byDataCodeWord[MAX_DATACODEWORD];
int ncDataCw1;for (i = 0; i < ncBlock1; ++i)
{
ZeroMemory(m_byRSWork, sizeof(m_byRSWork)); memmove(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw1); for (j = 0; j < ncRSCw1; ++j)
{
m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];
} nDataCwIndex += ncDataCw1;
++nBlockNo;
}------------------------------------------------------------------------------------------
void CQR_Encode::GetRSCodeWord(LPBYTE lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord)
{
int i, j; for (i = 0; i < ncDataCodeWord ; ++i)
{
if (lpbyRSWork[0] != 0)
{
BYTE nExpFirst = byIntToExp[lpbyRSWork[0]]; // 弶崁學悢傛傝忔悢嶼弌 for (j = 0; j < ncRSCodeWord; ++j)
{
// 奺崁忔悢偵弶崁忔悢傪壛嶼乮% 255 仺 兛^255 = 1乯
BYTE nExpElement = (BYTE)(((int)(byRSExp[ncRSCodeWord][j] + nExpFirst)) % 255); // 攔懠榑棟榓偵傛傞忚梋嶼弌
lpbyRSWork[j] = (BYTE)(lpbyRSWork[j + 1] ^ byExpToInt[nExpElement]);
} // 巆傝寘傪僔僼僩
for (j = ncRSCodeWord; j < ncDataCodeWord + ncRSCodeWord - 1; ++j)
lpbyRSWork[j] = lpbyRSWork[j + 1];
}
else
{
// 巆傝寘傪僔僼僩
for (j = 0; j < ncDataCodeWord + ncRSCodeWord - 1; ++j)
lpbyRSWork[j] = lpbyRSWork[j + 1];
}
}
}
--------------------------------------------------------------------------------------
static BYTE byRSExp68[] = {247, 159, 223,  33, 224,  93,  77,  70,  90, 160,  32, 254,  43, 150,  84, 101, 190, 205, 133,  52,
    60, 202, 165, 220, 203, 151,  93,  84,  15,  84, 253, 173, 160,  89, 227,  52, 199,  97,  95, 231,
    52, 177,  41, 125, 137, 241, 166, 225, 118,   2,  54,  32,  82, 215, 175, 198,  43, 238, 235,  27,
   101, 184, 127,   3,   5,   8, 163, 238};static LPBYTE  byRSExp[] = {NULL,      NULL,      NULL,      NULL,      NULL,      NULL,      NULL,      byRSExp7,  NULL,      NULL,
byRSExp10, NULL,      NULL,      byRSExp13, NULL,      byRSExp15, byRSExp16, byRSExp17, byRSExp18, NULL,
byRSExp20, NULL,      byRSExp22, NULL,      byRSExp24, NULL,      byRSExp26, NULL,      byRSExp28, NULL,
byRSExp30, NULL,      byRSExp32, NULL,      byRSExp34, NULL,      byRSExp36, NULL,      byRSExp38, NULL,
byRSExp40, NULL,      byRSExp42, NULL,      byRSExp44, NULL,      byRSExp46, NULL,      byRSExp48, NULL,
byRSExp50, NULL,      byRSExp52, NULL,      byRSExp54, NULL,      byRSExp56, NULL,      byRSExp58, NULL,
byRSExp60, NULL,      byRSExp62, NULL,      byRSExp64, NULL,      byRSExp66, NULL,      byRSExp68};
----------------------------------------------------------------------------------------

解决方案 »

  1.   

    先声明,就这些代码肯定是编译不过的,因为楼主你给的出来的只是一些片段,其中很多东西都缺少前置定义。
    var
      m_byRSWork: array[0..MAX_CODEBLOCK - 1] of Byte;
      m_byDataCodeWord: array[0..MAX_DATACODEWORD - 1] of Byte;
      ncDataCw1: Integer;
      i, j: Integer;
    begin
      for I := 0 to ncBlock1 - 1 do
      begin
        ZeroMemory(m_byRSWork, SizeOf(m_byRSWork));
        MoveMemory(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw1);    for J := 0 to List.Count - 1 do
        begin
          m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];
        end;    nDataCwIndex := nDataCwIndex + ncDataCw1;
        Inc(nBlockNo);
      end;
    end;{$J+}const byRSExp68: array[0..67] of Byte = (
      247, 159, 223, 33,  224, 93,  77,  70,  90,  160, 32,  254, 43,  150, 84,  101, 190, 205, 133, 52,
      60,  202, 165, 220, 203, 151, 93,  84,  15,  84,  253, 173, 160, 89,  227, 52,  199, 97,  95,  231,
      52,  177, 41,  125, 137, 241, 166, 225, 118, 2,   54,  32,  82,  215, 175, 198, 43,  238, 235, 27,
      101, 184, 127, 3,   5,   8,   163, 238
    );const byRSExp: array[0..78] of PByte = (
      nil,       nil, nil,       nil,       nil,       nil,       nil,       byRSExp7,  nil,       nil,
      byRSExp10, nil, nil,       byRSExp13, nil,       byRSExp15, byRSExp16, byRSExp17, byRSExp18, nil,
      byRSExp20, nil, byRSExp22, nil,       byRSExp24, nil,       byRSExp26, nil,       byRSExp28, nil,
      byRSExp30, nil, byRSExp32, nil,       byRSExp34, nil,       byRSExp36, nil,       byRSExp38, nil,
      byRSExp40, nil, byRSExp42, nil,       byRSExp44, nil,       byRSExp46, nil,       byRSExp48, nil,
      byRSExp50, nil, byRSExp52, nil,       byRSExp54, nil,       byRSExp56, nil,       byRSExp58, nil,
      byRSExp60, nil, byRSExp62, nil,       byRSExp64, nil,       byRSExp66, nil,       byRSExp68
    );{$J-}procedure CQR_Encode.GetRSCodeWord(lpbyRSWork: PByte; ncDataCodeWord, ncRSCodeWord: Integer);
    var
      i, j: Integer;
      nExpFirst: Byte;
      nExpElement: Byte;
    begin
      for I := 0 to ncDataCodeWord - 1 do
      begin
        if lpbyRSWork[0] <> 0 then
        begin
          nExpFirst = byIntToExp[lpbyRSWork[0]];      for J := 0 to ncRSCodeWord - 1 do
          begin
            nExpElement = Byte(((int)(byRSExp[ncRSCodeWord][j] + nExpFirst)) div 255);
            lpbyRSWork[j] = Byte(Power(lpbyRSWork[j + 1], byExpToInt[nExpElement]));
          end;      for j := ncRSCodeWord to ncDataCodeWord + ncRSCodeWord - 1 do
          begin
            lpbyRSWork[j] = lpbyRSWork[j + 1];
          end;
        end
        else
        begin
          for j := 0 to ncDataCodeWord + ncRSCodeWord - 2 do
          begin
            lpbyRSWork[j] = lpbyRSWork[j + 1];
          end;
        end;
      end;
    end;
      

  2.   


    先声明,就这些代码肯定是编译不过的,因为楼主你给的出来的只是一些片段,其中很多东西都缺少前置定义。 
    Delphi(Pascal) codevar
      m_byRSWork: array[0..MAX_CODEBLOCK - 1] of Byte;
      m_byDataCodeWord: array[0..MAX_DATACODEWORD - 1] of Byte;
      ncDataCw1: Integer;
      i, j: Integer;
    begin
      for I := 0 to ncBlock1 - 1 do
      begin
        ZeroMemory(m_byRSWork, SizeOf(m_byRSWork));
        MoveMemory(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw1);    for J := 0 to Lenght(m_byRSWork)-1 do//这里改成这样貌似合情理点..........个人看法     begin
          m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];
        end;    nDataCwIndex := nDataCwIndex + ncDataCw1;
        Inc(nBlockNo);
      end;
    end;{$J+}const byRSExp68: array[0..67] of Byte = (
      247, 159, 223, 33,  224, 93,  77,  70,  90,  160, 32,  254, 43,  150, 84,  101, 190, 205, 133, 52,
      60,  202, 165, 220, 203, 151, 93,  84,  15,  84,  253, 173, 160, 89,  227, 52,  199, 97,  95,  231,
      52,  177, 41,  125, 137, 241, 166, 225, 118, 2,   54,  32,  82,  215, 175, 198, 43,  238, 235, 27,
      101, 184, 127, 3,   5,   8,   163, 238
    );const byRSExp: array[0..78] of PByte = (
      nil,       nil, nil,       nil,       nil,       nil,       nil,       byRSExp7,  nil,       nil,
      byRSExp10, nil, nil,       byRSExp13, nil,       byRSExp15, byRSExp16, byRSExp17, byRSExp18, nil,
      byRSExp20, nil, byRSExp22, nil,       byRSExp24, nil,       byRSExp26, nil,       byRSExp28, nil,
      byRSExp30, nil, byRSExp32, nil,       byRSExp34, nil,       byRSExp36, nil,       byRSExp38, nil,
      byRSExp40, nil, byRSExp42, nil,       byRSExp44, nil,       byRSExp46, nil,       byRSExp48, nil,
      byRSExp50, nil, byRSExp52, nil,       byRSExp54, nil,       byRSExp56, nil,       byRSExp58, nil,
      byRSExp60, nil, byRSExp62, nil,       byRSExp64, nil,       byRSExp66, nil,       byRSExp68
    );{$J-}procedure CQR_Encode.GetRSCodeWord(lpbyRSWork: PByte; ncDataCodeWord, ncRSCodeWord: Integer);
    var
      i, j: Integer;
      nExpFirst: Byte;
      nExpElement: Byte;
    begin
      for I := 0 to ncDataCodeWord - 1 do
      begin
        if lpbyRSWork[0] <> 0 then
        begin
          nExpFirst = byIntToExp[lpbyRSWork[0]];      for J := 0 to ncRSCodeWord - 1 do
          begin
            nExpElement = Byte(((int)(byRSExp[ncRSCodeWord][j] + nExpFirst)) div 255);
            lpbyRSWork[j] = Byte(Power(lpbyRSWork[j + 1], byExpToInt[nExpElement]));
          end;      for j := ncRSCodeWord to ncDataCodeWord + ncRSCodeWord - 1 do
          begin
            lpbyRSWork[j] = lpbyRSWork[j + 1];
          end;
        end
        else
        begin
          for j := 0 to ncDataCodeWord + ncRSCodeWord - 2 do
          begin
            lpbyRSWork[j] = lpbyRSWork[j + 1];
          end;
        end;
      end;
    end;太乱了,再发次......
      

  3.   

    @kfcoffe
    谢谢指正,自动生成的代码没改到,粗心了。
      

  4.   

    delphi中的MoveMemory的参数是指针类型,所以MoveMemory(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw1);肯定不对啦,这个怎么弄,难道写成MoveMemory(@m_byRSWork, TPoint(m_byDataCodeWord + nDataCwIndex), ncDataCw1);么?
      

  5.   


    你试试不就知道了么?     如果不喜欢用这个  用Move()也可以..........
      

  6.   

    我疑惑的是vc中的m_byDataCodeWord + nDataCwIndex,前面是array后面的是int这两个相加然后要指针调用,这么回事呢
      

  7.   


    vc里面的基础知识啊,   数组名代表数组的首地址+int数值(偏移)=具体数组元素的地址注意delphi中这里就有点区别了 应该是  :
     数组第一个元素的地址+integer数值(偏移)=具体数组元素的地址
      

  8.   


      Move(m_byRSWork[0],pointer(Integer(@m_byDataCodeWord[0]) + nDataCwIndex)^, ncDataCw1);