struct POS
{
LONG start;
LONG end;
POS()
{
start=-1;
end=-1;
}
};
struct INFO
{
char url[100];
char localFile[50];
BOOL ifFinish;
BOOL MulThread;
long fileLen;
POS pos[4];
long lenFinish;
CTime lastModify;
INFO()
{
url[0]='\0';
localFile[0]='\0';
ifFinish=TRUE;
MulThread=TRUE;
fileLen=-1;
lenFinish=0;
}
};

解决方案 »

  1.   

    动态字段的处理,我想,或许可以用类似链表的结点插入。做这么一个链表:设备编号->设备名称->设备购买人->设备价格->设备购买时间,那么需要什么添加什么就用插入了。
    而且读数据的时候可以按上边的链表顺序来读,各种不同内容的结点从一个基类派生出来。
      

  2.   

    struct POS
    {
    LONG start;
    LONG end;
    POS()
    {
    start=-1;
    end=-1;
    }
    };
    struct INFO
    {
    char url[100];
    char localFile[50];
    BOOL ifFinish;
    BOOL MulThread;
    long fileLen;
    POS pos[4];
    long lenFinish;
    CTime lastModify;
    INFO()
    {
    url[0]='\0';
    localFile[0]='\0';
    ifFinish=TRUE;
    MulThread=TRUE;
    fileLen=-1;
    lenFinish=0;
    }
    };
      

  3.   

    写文件就直接把结构写入文件
    void CHttpBotDlg::ReadInfo(BOOL isFinish)
    {
    m_tList.DeleteAllItems();
    // ifFinishList=IsFinish;
    CFile file;
    if(!file.Open("d:\\HttpBot.txt", CFile::modeRead))
    {
    file.Open("d:\\HttpBot.txt",CFile::modeCreate);
    file.Close();
    return;
    }
    else
    {
    INFO *info = new INFO();
    file.SeekToBegin();
    int index;
    while(file.Read(info,sizeof(INFO)) == sizeof(INFO))
    {
    if(info->ifFinish != isFinish)
    continue;
    ITEMINFO *item = new ITEMINFO();
    if(isFinish == FALSE)
    {
    CFile f;
    LONG size=0;
    for(int i=0; i<4; i++)
    {
    CString name;
    name.Format(".bot%d",i);
    name = info->localFile+name;
    if(f.Open(name, CFile::modeRead))
    {
    size+=f.GetLength();
    f.Close();
    }
    }
    item->downloadSize = size;

    }
    item->fileSize = info->fileLen;
    // int ti = info->fileLen / 100;
    item->downloadSize = info->lenFinish;
    item->per = (item->downloadSize / item->fileSize) * 100;
    CString temp = info->localFile;
    int j = temp.ReverseFind('\\');
    item->fileName = temp.Mid(j + 1);
    item->savePath = temp.Left(j+1);
    item->remoteUrl = info->url;
    item->per = (info->lenFinish * 100) / info->fileLen;
    if(isFinish)
    item->state = TA_FINISH;
    else
    item->state = TA_STOP;
    index = m_tList.InsertItem(item);
    delete item;
    item = NULL;
    }
    file.Close();
    }
    }
      

  4.   

    一个小例子,留个email,一起研究研究