📄 uploaddialog.cpp
字号:
//上传对话框
#include "stdafx.h"
#include "resource.h"
#include "xmldata.h"
#include <string>
#include <direct.h>
#include <atlsimpstr.h>
#include ".\UploadDialog.h"
#include "stdlib.h"
#include "imapi.h"
extern CXMLDATA XmlData;
using namespace std;
//
DWORD WINAPI AutoYesThread( LPVOID index ) ;
//
LRESULT CUploadDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
this->CenterWindow ();
IsDes=false;
IsSplit=false;
return TRUE;
}
LRESULT CUploadDialog::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
this->EndDialog(0);
return 0;
}
LRESULT CUploadDialog::OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
this->EndDialog (0);
return 0;
}
LRESULT CUploadDialog::OnBnClickedButtonWhere(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加控件通知处理程序代码
WTL::CFolderDialog fd;
fd.DoModal ();
NowWhere=fd.GetFolderPath ();
GetDlgItem(IDC_STATIC_WHERE).SetWindowText(NowWhere.c_str ());
return 0;
}
LRESULT CUploadDialog::OnBnClickedUploadDescribe(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加控件通知处理程序代码
if(!Test()) return 0;
vector <string> VFileName;
_chdir(NowWhere.c_str ());
WIN32_FIND_DATA FindData;
HANDLE FindFileHandle=FindFirstFile("*",&FindData);
if(INVALID_HANDLE_VALUE==FindFileHandle) return 0;
if(!FindNextFile(FindFileHandle,&FindData)) return 0;
while(FindNextFile(FindFileHandle,&FindData))
{
if(strstr(FindData.cFileName,"DESCRIBE")!=NULL) continue;
if(strstr(FindData.cFileName,".")==NULL) continue;
VFileName.push_back (FindData.cFileName );
}
XmlDescribeData.Vdescribe =VFileName;
XmlDescribeData.VSaveName =VFileName;
XmlDescribeData.MailBoxName =ToMail;
XmlDescribeData.DownLoadCode =DownLoadCode;
int n;
for(n=0;n<XmlDescribeData.VSaveName .size ();n++)
{
string FileName;
FileName=DownLoadCode+".part";
char index[5];
memset(index,0,5);
::itoa (n,index,10);
FileName.append (index);
XmlDescribeData.VFileName .push_back (FileName);
}
if(IsSplit==false)
{
XmlDescribeData.DescrbeForUser="欢迎下载!" ;
}
else
{
XmlDescribeData.DescrbeForUser="欢迎下载!请下载所有项然后使用WinRAR解压。" ;
}
//描述文件信息填充完毕
XmlDescribeData.WriteData (NowWhere+"\\"+"DESCRIBE.xml");
IsDes=true;
GetDlgItem(IDC_STATIC_WHERE).SetWindowText("描述文件生成完毕!");
return 0;
}
LRESULT CUploadDialog::OnBnClickedUploadSendmail(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
if(!Test()) return 0;
if(IsDes==false)
{
GetDlgItem(IDC_STATIC_WHERE).SetWindowText("描述文件还没有生成!");
return 0;
}
// TODO: 在此添加控件通知处理程序代码
int n;
for(n=0;n<XmlDescribeData.VFileName .size ();n++)
{
CIMapi mail;
if (mail.Error() == CIMapi::IMAPI_SUCCESS)
{
mail.To (ToMail.c_str ());
mail.From ("BQYAHOO@BQYAHOO.COM");
mail.Attach ((NowWhere+"\\"+XmlDescribeData.VSaveName [n]).c_str ());
mail.Subject (XmlDescribeData.VFileName [n].c_str ());
mail.Send ();
}
}
CIMapi mail;
mail.To (ToMail.c_str ());
mail.From ("BQYAHOO@BQYAHOO.COM");
mail.Attach ((NowWhere+"\\"+"DESCRIBE.xml").c_str ());
mail.Subject((DownLoadCode+".describe").c_str());
mail.Send ();
return 0;
}
LRESULT CUploadDialog::OnBnClickedUploadSplit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加控件通知处理程序代码
if(!Test()) return 0;
_chdir(NowWhere.c_str ());
string cl;
cl="winrar a -v5m -m0 -df ";
cl=cl+DownLoadCode;
WinExec(cl.c_str (),SW_SHOW);
IsSplit=true;
if(IsSplit==true)
{
GetDlgItem(IDC_STATIC_WHERE).SetWindowText("进入大文件压缩模式");
return 0;
}
return 0;
}
bool CUploadDialog::Test()
{
char buf[200];
memset(buf,0,200);
int n;
GetDlgItem(IDC_EDIT_USERNAME).GetWindowText (buf,200);
ToMail=buf;
ToMail=ToMail+"@yahoo.com.cn";
memset(buf,0,200);
GetDlgItem(IDC_EDIT_DOWNLOADCODE).GetWindowText (buf,200);
DownLoadCode=buf;
if(NowWhere.size ()==0)
{
GetDlgItem(IDC_STATIC_WHERE).SetWindowText("你还没有指出欲上传文件所在目录!");
return false;
}
if(DownLoadCode.size ()==0)
{
GetDlgItem(IDC_STATIC_WHERE).SetWindowText("你还没有输入下载码!");
return false;
}
if(ToMail.size ()==0)
{
GetDlgItem(IDC_STATIC_WHERE).SetWindowText("你还没有输入用户名!");
return false;
}
return true;
}
DWORD WINAPI AutoYesThread( LPVOID index )
{
return 0;
}
bool CUploadDialog::AutoYes()
{
DWORD dwThreadId, dwThrdParam =0;
HANDLE hThread;
hThread = CreateThread(
NULL,
0,
AutoYesThread,
&dwThrdParam,
0,
&dwThreadId);
if (hThread == NULL) return false;
CloseHandle( hThread );
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -