vc++问题,急,高手进

来源:百度知道 编辑:UC知道 时间:2024/06/20 15:29:56
这是一个windows程序的片段
该函数用于从ftp站点下载文档,并可以打开
请高手详细解释每一句话的意思,我马上要考试
void CServFileView::OnServFileDownloadOpen()
{

CFile m_File;
OnServFileDownload();
while(!done)
{
Sleep(10);
}
done=FALSE;

if(Lastfilenam=="")
{
MessageBox("No file downloaded yet!");
return;
}
m_File.Open(Lastfilenam,CFile::modeReadWrite);

int Max=m_File.GetLength();
char *read=new char[Max];
UINT ReadN=m_File.Read(read,Max);
read[ReadN]='\0';
m_File.Close();
readF=read;
CString szFtpInfo;
szFtpInfo=Lastfilenam;
szFtpInfo+="\t读取文件内容:\r\n";
szFtpInfo+=read;
pFtpInfoView->SendMessage(WM_RECORDFTPINFO,0,(LPARAM)(LPCTSTR)szFtpInfo);
CMyDlg dlg;
dlg.DoModal();

// dlg.OnSetfocusEdit1(read);
// GetDlgItem(IDC_EDIT1)->SetWindowText(" hello www!&qu

void CServFileView::OnServFileDownloadOpen()
{

CFile m_File;
OnServFileDownload();//调用一个函数可能是当选择保存文件的时候触发的
while(!done) //等待这个变量值为1否则 sleep 意思是暂停10毫秒正在运行的程序
{
Sleep(10);
}
done=FALSE;//复位等待标志

if(Lastfilenam=="")//文件名是否为空
{
MessageBox("No file downloaded yet!");//如果为空 弹出一个对话框 内容为No file downloaded yet!
return; //结束本函数
}
m_File.Open(Lastfilenam,CFile::modeReadWrite); //打开变量Lastfilenam中存放的文件 并且可读写

int Max=m_File.GetLength();//获得文件长度
char *read=new char[Max]; //申请一块空间用来存放读入的文件内容
UINT ReadN=m_File.Read(read,Max); //读取文件
read[ReadN]='\0'; //读取文件的缓冲区末尾添加0 可能文件为文子内容
m_File.Close(); //关闭文件
readF=read; //赋值文件缓冲区指针给readF
CString szFtpInfo; //申请一个字符串处理变量
szFtpInfo=Lastfilenam; //赋值文件名
szFtpInfo+="\t读取文件内容:\r\n";//文件名后拼接内容"读取文件内容:" \r\n是换行类似回车
szFtpInfo+