拷贝许多文件并处理其中数据,显示进度的程序在xp下出现问题,而2000下正确。在xp中选择右键中的兼容性属性页将里面的设为与2000兼容也没有问题。诸位有遇到类似问题的吗?问题具体表现是开始时进度条,进度数据都正确,但过一会儿就进度条显示停止,进度百分数也停止,但调试跟踪这些数据都没有问题。鼠标指针变成沙漏形状。表现象死机了一样,但实际安装进度仍在进行到最后安装处理结果也正常。这是兼容性的问题吧,有哪位大侠遇到过,提提解决意见吧,这两天就要完成呢。处理过程代码是原有代码,仔细看了也没有xp不支持的。

解决方案 »

  1.   

    多debug一下,多几条trace语句,看看到底问题出在哪条语句,这样问,很难回答阿
      

  2.   

    没有Code不好说。不过如果2000下正确,那么XP下应该没有什么问题的,呵呵
      

  3.   

    麻烦大家分析一下省略了一些无关部分
    第一部分:
    void CMyINSTALLApp::DoProgressDlg()
    {
       ....
       CProgressDlg    prgDlg;
        if (!prgDlg.Create(CProgressDlg::IDD, NULL))
            return;
        totFileLength = 0;
        totWriteLength = 0;
       ....
       //上面省略部分无关代码,取得所有文件总大小   for (i = 0; i < SeltNum; i++)
      {
           no = FontInst[FontSelt[i]];
           curWriteLength = 0;
          if (pDataInfo[no].DataNo >= 0)
           {
                if (!bDataTag[pDataInfo[no].DataNo])
                {
             curFileLength = pDataInfo[no].F1FileLength+pCIDFontInfo[no].F0FileLength;
    prgDlg.ShowCur(no, curWriteLength, curFileLength, totWriteLength, totFileLength);
    ....
                    //  Write F1 and T0 file
    if (!Install_F1F0(prgDlg, no, true))
                    {
    prgDlg.EndDialog(IDCANCEL);
    return;
                    }
                }
                else
                {
    curFileLength = pDataInfo[no].F0FileLength;
    prgDlg.ShowCur(no, curWriteLength, curFileLength, totWriteLength, totFileLength);

                     //  Write F1 and F0 file
    if (!Install_F1F0(prgDlg, no, false))
                  {
    prgDlg.EndDialog(IDCANCEL);
                  return;
                  }
                }
            }
            else
            {
         curFileLength = pDataInfo[no].F1FileLength+pDataInfo[no].F0FileLength;
    prgDlg.ShowCur(no, curWriteLength, curFileLength, totWriteLength, totFileLength);             //  Write F1 and F0 file
    if (!Install_F1F0(prgDlg, no, true))
    {
    prgDlg.EndDialog(IDCANCEL);
                         return;
                     }
            }
        } Install_C0File(prgDlg);
    prgDlg.EndDialog(IDCANCEL); //AfxMessageBox("结束", MB_OK);
    AfxMessageBox(cstr, MB_OK); return;
    }void CProgressDlg::ShowCur(int no, long curWriteLength, long curFileLength, long totWriteLength, long totFileLength)
    {
        CProgressCtrl   *theCurProgress, *theTotProgress;
        WORD            curPercent, totPercent;
        static WORD     cur0, tot0, no0;   ....
       if( no != -1 )
       {
            if (no != no0)
            {
    //Show Sample Picture
    m_pSample.DrawPicture(FontSampleID[no]);
    no0 = no;
            }
      }    //Show CurPercent Progress and Text
        curPercent = (WORD)((double)curWriteLength*100/(double)curFileLength);
        if (curPercent != cur0)
        {
    theCurProgress = (CProgressCtrl *)GetDlgItem(IDC_PROGRESS_CURRENTPERCENT)
             theCurProgress->SetPos(curPercent);
    theCurProgress->UpdateWindow();

            _itoa(curPercent, str, 10);
            strcat(str, "%");
            SetDlgItemText(IDC_TEXT_CURPERCENT, str);
            cur0 = curPercent;    }    // Show TotPercent Progress and Text
        totPercent = (WORD)((double)totWriteLength*100/(double)totFileLength);
       if (totPercent != tot0)
        {
            theTotProgress = (CProgressCtrl *)GetDlgItem(IDC_PROGRESS_TOTALPERCENT);
            theTotProgress->SetPos(totPercent);
            theTotProgress->UpdateWindow();
            _itoa(totPercent, str, 10);
            strcat(str, "%");
            SetDlgItemText(IDC_TEXT_TOTPERCENT, str);
            tot0 = totPercent;
        }
    }
      

  4.   

    在2000上拷贝你程序需要的dll文件放在你xp下程序的目录里面看看问题要出现不!
      

  5.   

    第二部分:bool CPSINSTALLApp::Install_F1F0(CProgressDlg& prgDlg, WORD no, bool bInstall)
    {
        char                cPathName[256], ErrBuf[256];
        HFILE               hFile;
        OFSTRUCT            OfStruct;
        CString             szFileName;
        WORD                no2;
        CFileStatus         status;
        CString             cstr, cFileName, tFileName;
        bool                bGood;
        CString      sSrcFileName, sDestFileName;    //  1. Install *.f1 file
        strcpy (cPathName, m_sDataFilePath);
        strcat (cPathName, pDataInfo[no].DataFolderName);
        if (bInstall)
        {
                .....
                if ((hFile = OpenFile(szFileName, (LPOFSTRUCT)&OfStruct, OF_EXIST)) != -1)
                {
                .....
                    if ((hFile = OpenFile(tFileName, (LPOFSTRUCT)&OfStruct, OF_EXIST)) != -1)
                    {
                          ......                    if (m_ReplaceMode == REPLACEIT || m_ReplaceMode == REPLACEALL)
                        { bGood = InstallOneF1(pDataInfo[no].F1Name, pDataInfo[no].F1ResName, (const char *)m_sPath, cPathName, serialnumber, prgDlg, true);
          }
                    }
                }
                 else
                {
                       totWriteLength += pDataInfo[no].F1Length;
                       prgDlg.ShowCur(-1, 1, 1, totWriteLength, totFileLength);
                }
           }
           else
           {
    bGood = InstallOneF1(pCIDFontInfo[no].F1Name, pDataInfo[no].F1ResName, (const char *)m_sPath, cPathName, serialnumber, prgDlg, true);       }
      }
        //  2. Install *.F0 file
       //过程和上面类似省略    return true;
    }bool InstallOneF1(PSTR cSorFileName, CString cDestFileName, const char *CDestFontPath, PSTR szSorPathName, long SerialNumber, CProgressDlg& prgDlg, bool bShowCurrent)
    {
        if (bShowCurrent)
    prgDlg.ShowCur(-1, theApp.curWriteLength, theApp.curFileLength, theApp.totWriteLength, theApp.totFileLength);
        else
    prgDlg.ShowCur(-1, 1, 1, theApp.totWriteLength, theApp.totFileLength);    CFile Sorfile;
        CFileException fe;          
        CFile Dstfile;
        
        bRet = F1ToF1( Sorfile, Dstfile, cSorFileName, SerialNumber, prgDlg, bShowCurrent );
        Sorfile.Close();
        Dstfile.Close();
        if( !bRet )
        {
            remove (cDstFileName);
            return( bRet );
        }   return( TRUE );
    }bool F1ToF1( CFile& Sorfile, CFile& Dstfile, PSTR cSorFileName, long SerialNumber, CProgressDlg& prgDlg, bool bShowCurrent )
    {
        Sorfile.Seek( 0, CFile::begin );
        Dstfile.Seek( 0, CFile::begin );
        HeadLength = ReadF1Info( Sorfile );    if (!HeadLength)
            return false;    if( ... )
            return( FALSE );
            
        //  write cid head and dict
        if( !ToF1Head(  Sorfile, Dstfile, HeadLength ) )
            return( FALSE );    theApp.curWriteLength += HeadLength;
        theApp.totWriteLength += HeadLength;
        if (bShowCurrent)
            prgDlg.ShowCur(-1, theApp.curWriteLength, theApp.curFileLength, theApp.totWriteLength, theApp.totFileLength);
        else
            prgDlg.ShowCur(-1, 1, 1, theApp.totWriteLength, theApp.totFileLength);     ......
        //  write F1Map and SubrMap
        ToF1MapAndSubrMap( Sorfile, Dstfile, lpF1MapStr, lpSubrMapStr, HeadLength );        .....
            Dstfile.Write( lpTmpBuffer, BuffLength );
            theApp.curWriteLength += BuffLength;
            theApp.totWriteLength += BuffLength;
            if (bShowCurrent)
                prgDlg.ShowCur(-1, theApp.curWriteLength, theApp.curFileLength, theApp.totWriteLength, theApp.totFileLength);
            else
                prgDlg.ShowCur(-1, 1, 1, theApp.totWriteLength, theApp.totFileLength);
        }
        if( hSubrMap != NULL )
        {
            GlobalUnlock( hSubrMap );
            GlobalFree( hSubrMap );
        }
        //  write charstring
           Dstfile.Write( lpTmpBuffer, BuffLength );
            theApp.curWriteLength += BuffLength;
            theApp.totWriteLength += BuffLength;
            if (bShowCurrent)
                prgDlg.ShowCur(-1, theApp.curWriteLength, theApp.curFileLength, theApp.totWriteLength, theApp.totFileLength);
            else
                prgDlg.ShowCur(-1, 1, 1, theApp.totWriteLength, theApp.totFileLength);        i = endi;
        }
        .......

        WORD LeftLength = (WORD)( Sorfile.GetLength() - Sorfile.Seek( 0, CFile::current ) );
        Sorfile.Read( lpTmpBuffer, LeftLength );
        Dstfile.Write( lpTmpBuffer, LeftLength );
        theApp.curWriteLength += LeftLength;
        theApp.totWriteLength += LeftLength;
        if (bShowCurrent)
            prgDlg.ShowCur(-1, theApp.curWriteLength, theApp.curFileLength, theApp.totWriteLength, theApp.totFileLength);
        else
            prgDlg.ShowCur(-1, 1, 1, theApp.totWriteLength, theApp.totFileLength);
        
        //  free alloc memory sapce
        if( hTmpMem != NULL )
        {
            GlobalUnlock( hTmpMem );
            GlobalFree( hTmpMem );
        }
        return( TRUE );
    }void ToF1MapAndSubrMap( CFile& Sorfile, CFile& Dstfile, LPSTR lpCIDMap, LPSTR lpSubrMap, long HeadLength )
    {
        long ReadSize;    Sorfile.Seek( HeadLength, CFile::begin );
        Dstfile.Seek( HeadLength, CFile::begin );
        ReadSize = Sorfile.Read( lpCIDMap, ((WORD)(CidInfo.CIDCount+1))*((WORD)(CidInfo.FDBytes+CidInfo.GDBytes)) );
        Dstfile.Write( lpCIDMap, ReadSize );
      ReadSize = Sorfile.Read( lpSubrMap, ((WORD)(CidInfo.SubrCount+1))*((WORD)CidInfo.SDBytes) );
      Dstfile.Write( lpSubrMap, ReadSize );}
      

  6.   

    说明:
    对f1文件中的数据要分段读出处理(处理部分省略了单纯数据运算处理),每次读出一段,计算当前所写的长度,计算进度的当前值和总进度值,f1是许多个分别比较大的文件几兆到十几兆大.所有的显示是由ShowCur函数完成的,这个函数共计调用了23次.CProgressDlg是两个进度条所在窗口类