www.pudn.com > GMAIL.rar > GMAILView.cpp
// GMAILView.cpp : implementation of the CGMAILView class // #include "stdafx.h" #include "GMAIL.h" #include "GMAILDoc.h" #include "GMAILView.h" #include "mainfrm.h" #include "SetProxy.h" #include "Directions.h" #include#include < atlbase.h > #include CComModule _Module; #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CString m_CShttp; extern CGMAILApp theApp; ///////////////////////////////////////////////////////////////////////////// // CGMAILView IMPLEMENT_DYNCREATE(CGMAILView, CHtmlView) BEGIN_MESSAGE_MAP(CGMAILView, CHtmlView) //{{AFX_MSG_MAP(CGMAILView) ON_BN_CLICKED(IDC_BUTTONBROWN, OnButtonbrown) ON_CBN_EDITCHANGE(IDC_COMBOHTTP, OnEditchangeCombohttp) ON_COMMAND(CDR_GO, OnGo) ON_COMMAND(CDR_FUR, OnFur) ON_COMMAND(CDR_INPUT, OnInput) ON_COMMAND(ID_EDIT_COPY, OnEditCopy) ON_COMMAND(ID_EDIT_CUT, OnEditCut) ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) ON_COMMAND(ID_SET_INTER, OnSetInter) ON_COMMAND(ID_GMAIL, OnGmail) ON_COMMAND(ID_EBAY, OnEbay) ON_BN_CLICKED(IDC_BUTTONGOBACK, OnButtongoback) ON_BN_CLICKED(IDC_BUTTONGOP, OnButtongop) ON_COMMAND(ID_SET_COOKIE, OnSetCookie) ON_COMMAND(CDR_SAVE, OnSave) ON_COMMAND(CDR_HTM, OnHtm) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGMAILView construction/destruction CGMAILView::CGMAILView() { // TODO: add construction code here } CGMAILView::~CGMAILView() { } BOOL CGMAILView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CHtmlView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CGMAILView drawing void CGMAILView::OnDraw(CDC* pDC) { CGMAILDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } void CGMAILView::OnInitialUpdate() { CHtmlView::OnInitialUpdate(); // TODO: This code navigates to a popular spot on the web. // change the code to go where you'd like. srand((unsigned)time(NULL)); ge=0; m_CShttp="about:blank"; Navigate2(_T(m_CShttp),NULL,NULL); } ///////////////////////////////////////////////////////////////////////////// // CGMAILView diagnostics #ifdef _DEBUG void CGMAILView::AssertValid() const { CHtmlView::AssertValid(); } void CGMAILView::Dump(CDumpContext& dc) const { CHtmlView::Dump(dc); } CGMAILDoc* CGMAILView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGMAILDoc))); return (CGMAILDoc*)m_pDocument; } #endif //_DEBUG bool HasItem(IHTMLElementCollection *pobjAllElement,CString strName) { CComPtr pDisp; pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp); if(pDisp==NULL) return false; else return true; } void CheckItem(IHTMLElementCollection *pobjAllElement,CString strName) { CComPtr pDisp; pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { AfxMessageBox(strName+"没有找到!"); } else { pElement=pDisp; pElement->click(); } } void SubmitPage(IHTMLElementCollection *pobjAllElement,CString strName) { CComPtr pDisp; pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp); //CComQIPtr pElement; CComQIPtr pElement; if(pDisp==NULL) { AfxMessageBox(strName+"没有找到!"); } else { pElement=pDisp; pElement->click(); } } void InputIE(IHTMLElementCollection *pobjAllElement,CString strName,CString tmp,int itemno) { CComPtr pDisp; pobjAllElement->item(COleVariant(strName),COleVariant((long)itemno),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { AfxMessageBox(strName+"没有找到!"); } else { pElement=pDisp; pElement->put_innerText(tmp.AllocSysString()); } } void InputSelect(IHTMLElementCollection *pobjElement,CString strName,int tmp,int itemno) { CComPtr pDisp; pobjElement->item(COleVariant(strName),COleVariant((long)itemno),&pDisp); CComQIPtr Pelement; if(pDisp==NULL) { AfxMessageBox(strName+"没有找到!"); } else { Pelement=pDisp; Pelement->put_selectedIndex(tmp); } } CString CGMAILView::RanLastName(int max) { int x =1+rand()%max; CString SQL; SQL.Format("SELECT word FROM words where ID=%d",x); // SQL.Format("select top 1 word from words order by Rnd(len(word))");//第二种随机方式 m_pRecordset.CreateInstance(__uuidof(Recordset)); try { m_pRecordset->Open( _variant_t(SQL), theApp.m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText); } catch(_com_error *e) { AfxMessageBox(e->ErrorMessage()); } _variant_t var; var = m_pRecordset->GetCollect("word"); if(var.vt != VT_NULL) SQL = (LPCSTR)_bstr_t(var); return SQL; } CString RanNum(int max,int Nlength) { CString rett=""; for(int i=0;i ..."); Navigate2(m_CShttp,NULL,NULL); Invalidate(FALSE); } void CGMAILView::OnEditchangeCombohttp() { // TODO: Add your control notification handler code here CMainFrame *pw=(CMainFrame *)AfxGetMainWnd(); CDialogBar *pb=pw->GetDialogBar(); pb->GetDlgItemText(IDC_COMBOHTTP,m_CShttp); } void CGMAILView::OnGo() { // TODO: Add your command handler code here //自动执行注册功能的函数 } void CGMAILView::OnFur() { // TODO: Add your command handler code here if (1==ge) { m_CShttp="http://mail.google.com/mail/signup"; } else if(2==ge) { m_CShttp="https://scgi.ebay.co.uk/ws/eBayISAPI.dll?RegisterEnterInfo"; } Navigate2(_T(m_CShttp),NULL,NULL); flag=false; } void CGMAILView::OnEditCopy() { // TODO: Add your command handler code here if(GetFocus()) { GetFocus()->SendMessage(WM_COPY); ExecWB(OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); } } void CGMAILView::OnEditCut() { // TODO: Add your command handler code here if(GetFocus()) { GetFocus()->SendMessage(WM_CUT); ExecWB(OLECMDID_CUT, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); } } void CGMAILView::OnEditPaste() { // TODO: Add your command handler code here if(GetFocus()) { GetFocus()->SendMessage(WM_PASTE); ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); } } void CGMAILView::OnSetInter() { // TODO: Add your command handler code here CSetProxy dig; dig.DoModal(); } void CGMAILView::OnHtm() { // TODO: Add your command handler code here CDirections da; da.DoModal(); } void CGMAILView::OnGmail() { // TODO: Add your command handler code here m_CShttp="http://mail.google.com/mail/signup"; Navigate2(_T(m_CShttp),NULL,NULL); ge=1; flag=false; } void CGMAILView::OnEbay() { // TODO: Add your command handler code here m_CShttp="https://scgi.ebay.co.uk/ws/eBayISAPI.dll?RegisterEnterInfo"; Navigate2(_T(m_CShttp),NULL,NULL); ge=2; flag=false; } void CGMAILView::OnButtongoback() { // TODO: Add your control notification handler code here CHtmlView::GoBack(); } void CGMAILView::OnButtongop() { // TODO: Add your control notification handler code here CHtmlView::GoForward(); } BOOL CGMAILView::EmptyDirectory(LPCTSTR szPath, BOOL bDeleteDesktopIni, BOOL bWipeIndexDat) { WIN32_FIND_DATA wfd; HANDLE hFind; CString sFullPath; CString sFindFilter; DWORD dwAttributes = 0; sFindFilter = szPath; sFindFilter += _T("\\*.*"); if ((hFind = FindFirstFile(sFindFilter, &wfd)) == INVALID_HANDLE_VALUE) { return FALSE; } do { if (_tcscmp(wfd.cFileName, _T(".")) == 0 || _tcscmp(wfd.cFileName, _T("..")) == 0 || (bDeleteDesktopIni == FALSE && _tcsicmp(wfd.cFileName, _T("desktop.ini")) == 0)) { continue; } sFullPath = szPath; sFullPath += _T('\\'); sFullPath += wfd.cFileName; //去掉只读属性 dwAttributes = GetFileAttributes(sFullPath); if (dwAttributes & FILE_ATTRIBUTE_READONLY) { dwAttributes &= ~FILE_ATTRIBUTE_READONLY; SetFileAttributes(sFullPath, dwAttributes); } if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { EmptyDirectory(sFullPath, bDeleteDesktopIni, bWipeIndexDat); RemoveDirectory(sFullPath); } else { if (bWipeIndexDat && _tcsicmp(wfd.cFileName, _T("index.dat")) == 0) { WipeFile(szPath, wfd.cFileName); } DeleteFile(sFullPath); } } while (FindNextFile(hFind, &wfd)); FindClose(hFind); return TRUE; } BOOL CGMAILView::WipeFile(LPCTSTR szDir, LPCTSTR szFile) { CString sPath; HANDLE hFile; DWORD dwSize; DWORD dwWrite; char sZero[SWEEP_BUFFER_SIZE]; memset(sZero, 0, SWEEP_BUFFER_SIZE); sPath = szDir; sPath += _T('\\'); sPath += szFile; hFile = CreateFile(sPath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return FALSE; } dwSize = GetFileSize(hFile, NULL); //skip file header (actually, I don't know the file format of index.dat) dwSize -= 64; SetFilePointer(hFile, 64, NULL, FILE_BEGIN); while (dwSize > 0) { if (dwSize > SWEEP_BUFFER_SIZE) { WriteFile(hFile, sZero, SWEEP_BUFFER_SIZE, &dwWrite, NULL); dwSize -= SWEEP_BUFFER_SIZE; } else { WriteFile(hFile, sZero, dwSize, &dwWrite, NULL); break; } } CloseHandle(hFile); return TRUE; } BOOL CGMAILView::DeleteUrlCache(DEL_CACHE_TYPE type) { BOOL bRet = FALSE; HANDLE hEntry; LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL; DWORD dwEntrySize; //delete the files dwEntrySize = 0; hEntry = FindFirstUrlCacheEntry(NULL, NULL, &dwEntrySize); lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize]; hEntry = FindFirstUrlCacheEntry(NULL, lpCacheEntry, &dwEntrySize); if (!hEntry) { goto cleanup; } do { if (type == File && !(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY)) { DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName); } else if (type == Cookie && (lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY)) { DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName); } dwEntrySize = 0; FindNextUrlCacheEntry(hEntry, NULL, &dwEntrySize); delete [] lpCacheEntry; lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize]; } while (FindNextUrlCacheEntry(hEntry, lpCacheEntry, &dwEntrySize)); bRet = TRUE; cleanup: if (lpCacheEntry) { delete [] lpCacheEntry; } return bRet; } void CGMAILView::OnSetCookie() { // TODO: Add your command handler code here TCHAR szPath[MAX_PATH]; DeleteUrlCache(Cookie); if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_COOKIES, FALSE)) { BOOL ck=EmptyDirectory(szPath); if (ck) { MessageBox("COOKIE清空成功!"); } } } void CGMAILView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel) { // TODO: Add your specialized code here and/or call the base class m_CShttp=lpszURL; CMainFrame *pw=(CMainFrame *)AfxGetMainWnd(); CDialogBar *pb=pw->GetDialogBar(); pb->SetDlgItemText(IDC_COMBOHTTP,m_CShttp); CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel); } void CGMAILView::OnInput() { // TODO: Add your command handler code here if (1==ge) { IHTMLDocument2 *objDocument=NULL; IHTMLElementCollection *objAllElement=NULL; IHTMLSelectElement *objSElement=NULL; CString strUrl,strTemp; strUrl=m_CShttp;//得到当前网页的URL if(strUrl.IsEmpty()) return; objDocument=(IHTMLDocument2 *)GetHtmlDocument(); objDocument->get_all(&objAllElement); if(strstr(strUrl,"http://mail.google.com/mail/signu"))/*基本GMAIL注册页*/ { CComPtr pDisp; if(HasItem(objAllElement,_T("createaccount"))==true) { objAllElement->item(COleVariant(_T("createaccount")),COleVariant((long)0),&pDisp); //CComQIPtr pElement; if(pDisp==NULL) { MessageBox("接口指针获取失败"); return; } else { } Lastname=RanLastName(10000); Firstname=RanLastName(13000); Email=RanLastName(12000)+RanNum(9,7); Passwd=RanPass(61,10); Anwer=RanPass(61,18); Choose=RanNum1(4,1); InputIE(objAllElement,_T("LastName"),Lastname,0); InputIE(objAllElement,_T("FirstName"),Firstname,0); InputIE(objAllElement,_T("Email"),Email,0); InputIE(objAllElement,_T("Passwd"),Passwd,0); InputIE(objAllElement,_T("PasswdAgain"),Passwd,0); InputSelect(objAllElement,_T("questions"),Choose,0); InputIE(objAllElement,_T("IdentityAnswer"),Anwer,0); flag=TRUE; //CheckItem(objAllElement,_T("PersistentCookie")); //将form中id为chk2的CheckBox选中 //SubmitPage(objAllElement,_T("submitbutton")); //提交网页,vote为submit按钮的id或name } } else if (strstr(strUrl,"https://www.google.com/accounts/"))/*出错GMAIL注册页*/ { CComPtr pDisp; if(HasItem(objAllElement,_T("createaccount"))==true) { objAllElement->item(COleVariant(_T("createaccount")),COleVariant((long)0),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { MessageBox("接口指针获取失败"); return; } else { } Lastname=RanLastName(10000); Firstname=RanLastName(13000); Email=RanLastName(12000)+RanNum(9,7); Passwd=RanPass(61,10); Anwer=RanPass(61,18); Choose=RanNum1(4,1); InputIE(objAllElement,_T("LastName"),Lastname,1); InputIE(objAllElement,_T("FirstName"),Firstname,1); InputIE(objAllElement,_T("Email"),Email,1); InputIE(objAllElement,_T("Passwd"),Passwd,1); InputIE(objAllElement,_T("PasswdAgain"),Passwd,1); InputSelect(objAllElement,_T("questions"),Choose,0); InputIE(objAllElement,_T("IdentityAnswer"),Anwer,1); flag=TRUE; } } else if(strstr(strUrl,"http://www.googleadservices.com/pagead/conver"))/*GMAIL注册成功页*/ { if (flag) { flag=FALSE; m_pRecordset.CreateInstance(__uuidof(Recordset)); try { m_pRecordset->Open("select * FROM email", // 查询DemoTable表中所有字段 theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针 adOpenDynamic, adLockOptimistic, adCmdText); } catch(_com_error *e) { AfxMessageBox(e->ErrorMessage()); } try { // 写入各字段值 m_pRecordset->AddNew(); m_pRecordset->PutCollect("LastName", _variant_t(Lastname)); m_pRecordset->PutCollect("FirstName", _variant_t(Firstname)); m_pRecordset->PutCollect("Email", _variant_t(Email)); m_pRecordset->PutCollect("Passwd", _variant_t(Passwd)); m_pRecordset->PutCollect("IdentityAnswer", _variant_t(Anwer)); m_pRecordset->Update(); AfxMessageBox("注册成功,已加入数据库!"); } catch(_com_error *e) { AfxMessageBox(e->ErrorMessage()); } } } } else if(2==ge)/*EBAY*/ { IHTMLDocument2 *objDocument=NULL; IHTMLElementCollection *objAllElement=NULL; IHTMLSelectElement *objSElement=NULL; CString strUrl,strTemp; strUrl=m_CShttp;//得到当前网页的URL if(strUrl.IsEmpty()) return; objDocument=(IHTMLDocument2 *)GetHtmlDocument(); objDocument->get_all(&objAllElement); if(strstr(strUrl,"https://securepics.ebaystatic.com"))/*基本EBAY注册页*/ { CComPtr pDisp; if(HasItem(objAllElement,_T("RegisterEnterInfo"))==true) { objAllElement->item(COleVariant(_T("RegisterEnterInfo")),COleVariant((long)0),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { MessageBox("接口指针获取失败"); return; } else { //另一页打开 } Lastname=RanLastName(10000); Firstname=RanLastName(13000); address1=RanLastName(13000); Email=RanLastName(12000)+RanNum(9,7); Passwd=RanPass(61,10); Anwer=RanPass(61,18); Choose=RanNum1(5,1); userid=RanLastName(12000)+RanNum(9,3); address1=RanLastName(13000); address2=RanLastName(13000); city=RanLastName(13000); state=RanNum1(50,1); zip.Format("%d",RanNum1(99999,400000)); dayphone1.Format("%d",RanNum1(899,100)); dayphone2.Format("%d",RanNum1(89999,10000)); // dayphone3.Format("%d",RanNum1(89999,10000)); // dayphone4.Format("%d",RanNum1(89999,10000)); birthdate2=RanNum1(11,1); birthdate1=RanNum1(28,1); birthdate3.Format("%d",RanNum1(20,1970)); InputIE(objAllElement,_T("lastname"),Lastname,0); InputIE(objAllElement,_T("firstname"),Firstname,0); InputIE(objAllElement,_T("email"),Email,0); InputIE(objAllElement,_T("retype_email"),Email,0); InputIE(objAllElement,_T("pass"),Passwd,0); InputIE(objAllElement,_T("rpass"),Passwd,0); InputSelect(objAllElement,_T("state"),state,1); //InputSelect(objAllElement,_T("countryID"),4);不用设置此处 InputIE(objAllElement,_T("myanswer"),Anwer,0); InputIE(objAllElement,_T("userid"),userid,1); InputSelect(objAllElement,_T("canned"),Choose,0); InputSelect(objAllElement,_T("birthdate2"),birthdate2,0); InputSelect(objAllElement,_T("birthdate1"),birthdate1,0); InputIE(objAllElement,_T("birthdate3"),birthdate3,0); InputIE(objAllElement,_T("zip"),zip,0); InputIE(objAllElement,_T("address1"),address1,0); InputIE(objAllElement,_T("address2"),address2,0); InputIE(objAllElement,_T("dayphone1"),dayphone1,0); InputIE(objAllElement,_T("dayphone2"),dayphone2,0); // InputIE(objAllElement,_T("dayphone3"),dayphone3,0); // InputIE(objAllElement,_T("dayphone4"),dayphone4,0); InputIE(objAllElement,_T("city"),city,1); flag=TRUE; //CheckItem(objAllElement,_T("PersistentCookie")); //将form中id为chk2的CheckBox选中 //SubmitPage(objAllElement,_T("submitbutton")); //提交网页,vote为submit按钮的id或name } } else if(strstr(strUrl,"EBAYRE")) { } } } void CGMAILView::OnProgressChange(long nProgress, long nProgressMax) { // TODO: Add your specialized code here and/or call the base class if(nProgress==-1) { if (1==ge) { IHTMLDocument2 *objDocument=NULL; IHTMLElementCollection *objAllElement=NULL; IHTMLSelectElement *objSElement=NULL; CString strUrl,strTemp; strUrl=m_CShttp;//得到当前网页的URL if(strUrl.IsEmpty()) return; objDocument=(IHTMLDocument2 *)GetHtmlDocument(); objDocument->get_all(&objAllElement); if(strstr(strUrl,"http://mail.google.com/mail/signu")&&!flag)/*基本GMAIL注册页*/ { CComPtr pDisp; if(HasItem(objAllElement,_T("createaccount"))==true) { objAllElement->item(COleVariant(_T("createaccount")),COleVariant((long)0),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { MessageBox("接口指针获取失败"); return; } else { } Lastname=RanLastName(10000); Firstname=RanLastName(13000); Email=RanLastName(12000)+RanNum(9,7); Passwd=RanPass(61,10); Anwer=RanPass(61,18); Choose=RanNum1(4,1); InputIE(objAllElement,_T("LastName"),Lastname,0); InputIE(objAllElement,_T("FirstName"),Firstname,0); InputIE(objAllElement,_T("Email"),Email,0); InputIE(objAllElement,_T("Passwd"),Passwd,0); InputIE(objAllElement,_T("PasswdAgain"),Passwd,0); InputSelect(objAllElement,_T("questions"),Choose,0); InputIE(objAllElement,_T("IdentityAnswer"),Anwer,0); flag=TRUE; //CheckItem(objAllElement,_T("PersistentCookie")); //将form中id为chk2的CheckBox选中 //SubmitPage(objAllElement,_T("submitbutton")); //提交网页,vote为submit按钮的id或name } } else if (strstr(strUrl,"https://www.google.com/accounts/"))/*出错GMAIL注册页*/ { CComPtr pDisp; if(HasItem(objAllElement,_T("createaccount"))==true) { objAllElement->item(COleVariant(_T("createaccount")),COleVariant((long)0),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { MessageBox("接口指针获取失败"); return; } else { } Lastname=RanLastName(10000); Firstname=RanLastName(13000); Email=RanLastName(12000)+RanNum(9,7); Passwd=RanPass(61,10); Anwer=RanPass(61,18); Choose=RanNum1(4,1); InputIE(objAllElement,_T("LastName"),Lastname,1); InputIE(objAllElement,_T("FirstName"),Firstname,1); InputIE(objAllElement,_T("Email"),Email,1); InputIE(objAllElement,_T("Passwd"),Passwd,1); InputIE(objAllElement,_T("PasswdAgain"),Passwd,1); InputSelect(objAllElement,_T("questions"),Choose,0); InputIE(objAllElement,_T("IdentityAnswer"),Anwer,1); flag=TRUE; } } else if(strstr(strUrl,"http://www.googleadservices.com/pagead/conver")&&flag)/*GMAIL注册成功页*/ { flag=FALSE; m_pRecordset.CreateInstance(__uuidof(Recordset)); try { m_pRecordset->Open("select * FROM email", // 查询DemoTable表中所有字段 theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针 adOpenDynamic, adLockOptimistic, adCmdText); } catch(_com_error *e) { AfxMessageBox(e->ErrorMessage()); } try { // 写入各字段值 m_pRecordset->AddNew(); m_pRecordset->PutCollect("LastName", _variant_t(Lastname)); m_pRecordset->PutCollect("FirstName", _variant_t(Firstname)); m_pRecordset->PutCollect("Email", _variant_t(Email)); m_pRecordset->PutCollect("Passwd", _variant_t(Passwd)); m_pRecordset->PutCollect("IdentityAnswer", _variant_t(Anwer)); m_pRecordset->Update(); AfxMessageBox("注册成功,已加入数据库!"); } catch(_com_error *e) { AfxMessageBox(e->ErrorMessage()); } } } else if(2==ge)/*EBAY*/ { IHTMLDocument2 *objDocument=NULL; IHTMLElementCollection *objAllElement=NULL; IHTMLSelectElement *objSElement=NULL; CString strUrl,strTemp; strUrl=m_CShttp;//得到当前网页的URL if(strUrl.IsEmpty()) return; objDocument=(IHTMLDocument2 *)GetHtmlDocument(); objDocument->get_all(&objAllElement); if(strstr(strUrl,"https://securepics.ebaystatic.com")&&!flag)/*基本EBAY注册页*/ { CComPtr pDisp; if(HasItem(objAllElement,_T("RegisterEnterInfo"))==true) { objAllElement->item(COleVariant(_T("RegisterEnterInfo")),COleVariant((long)0),&pDisp); CComQIPtr pElement; if(pDisp==NULL) { MessageBox("接口指针获取失败"); return; } else { //另一页打开 } Lastname=RanLastName(10000); Firstname=RanLastName(13000); address1=RanLastName(13000); Email=RanLastName(12000)+RanNum(9,7); Passwd=RanPass(61,10); Anwer=RanPass(61,18); Choose=RanNum1(5,1); userid=RanLastName(12000)+RanNum(9,3); address1=RanLastName(13000); address2=RanLastName(13000); city=RanLastName(13000); state=RanNum1(50,1); zip.Format("%d",RanNum1(99999,400000)); dayphone1.Format("%d",RanNum1(899,100)); dayphone2.Format("%d",RanNum1(89999,10000)); // dayphone3.Format("%d",RanNum1(89999,10000)); // dayphone4.Format("%d",RanNum1(89999,10000)); birthdate2=RanNum1(11,1); birthdate1=RanNum1(28,1); birthdate3.Format("%d",RanNum1(20,1970)); InputIE(objAllElement,_T("lastname"),Lastname,0); InputIE(objAllElement,_T("firstname"),Firstname,0); InputIE(objAllElement,_T("email"),Email,0); InputIE(objAllElement,_T("retype_email"),Email,0); InputIE(objAllElement,_T("pass"),Passwd,0); InputIE(objAllElement,_T("rpass"),Passwd,0); InputSelect(objAllElement,_T("state"),state,1); //InputSelect(objAllElement,_T("countryID"),4);不用设置此处 InputIE(objAllElement,_T("myanswer"),Anwer,0); InputIE(objAllElement,_T("userid"),userid,1); InputSelect(objAllElement,_T("canned"),Choose,0); InputSelect(objAllElement,_T("birthdate2"),birthdate2,0); InputSelect(objAllElement,_T("birthdate1"),birthdate1,0); InputIE(objAllElement,_T("birthdate3"),birthdate3,0); InputIE(objAllElement,_T("zip"),zip,0); InputIE(objAllElement,_T("address1"),address1,0); InputIE(objAllElement,_T("address2"),address2,0); InputIE(objAllElement,_T("dayphone1"),dayphone1,0); InputIE(objAllElement,_T("dayphone2"),dayphone2,0); // InputIE(objAllElement,_T("dayphone3"),dayphone3,0); // InputIE(objAllElement,_T("dayphone4"),dayphone4,0); InputIE(objAllElement,_T("city"),city,1); flag=TRUE; //CheckItem(objAllElement,_T("PersistentCookie")); //将form中id为chk2的CheckBox选中 //SubmitPage(objAllElement,_T("submitbutton")); //提交网页,vote为submit按钮的id或name } } else if(strstr(strUrl,"EBAYRE")) { } } } CHtmlView::OnProgressChange(nProgress, nProgressMax); } void CGMAILView::OnSave() { if (1==ge||strstr(m_CShttp,"http://mail.google.com/mail/signu")||strstr(m_CShttp,"http://www.googleadservices.com/pagead/conver")) { // TODO: Add your command handler code here IHTMLDocument2* pIHTMLDocument2 = (IHTMLDocument2 *)GetHtmlDocument(); HRESULT hr; CString output = ""; CComBSTR bstrTitle; pIHTMLDocument2->get_title(&bstrTitle); //取得文档标题 USES_CONVERSION; CString count; count.Format("网页标题:%s ",OLE2CT(bstrTitle)); CComQIPtr< IHTMLElementCollection > spElementCollection; hr = pIHTMLDocument2->get_forms( &spElementCollection ); //取得表单集合 if ( FAILED( hr ) ) { MessageBox("error"); return; } long nFormCount=0; //取得表单数目 hr = spElementCollection->get_length( &nFormCount ); if ( FAILED( hr ) ) { MessageBox("获取表单数目错误"); return; } for(long i=0; i item(CComVariant(i), CComVariant(), &pDisp); if ( FAILED( hr ) ) continue; CComQIPtr< IHTMLFormElement > spFormElement = pDisp; pDisp->Release(); long nElemCount=0; //取得表单中域的数目 hr = spFormElement->get_length( &nElemCount ); if ( FAILED( hr ) ) continue; for(long j=0; j item(CComVariant(j),CComVariant(),&spInputElement); if(FAILED(hr)) continue; CComVariant vName,vVal,vType; //取得表单域的名值类型 hr=spInputElement.GetPropertyByName(L"name",&vName); if(FAILED(hr)) continue; hr=spInputElement.GetPropertyByName(L"value",&vVal); if(FAILED(hr)) continue; hr=spInputElement.GetPropertyByName(L"type",&vType); if(FAILED(hr)) continue; LPCTSTR lpName = vName.bstrVal? OLE2CT( vName.bstrVal ) : _T("NULL"); //未知域名 LPCTSTR lpVal = vVal.bstrVal? OLE2CT( vVal.bstrVal ) : _T("NULL"); //空值未输入 LPCTSTR lpType = vType.bstrVal? OLE2CT( vType.bstrVal ) : _T("NULL"); //未知类型 if((CString)lpName=="LastName") { Lastname=lpVal; } else if((CString)lpName=="FirstName") { Firstname=lpVal; } else if((CString)lpName=="Email") { Email=lpVal; } else if((CString)lpName=="Passwd") { Passwd=lpVal; } else if((CString)lpName=="IdentityAnswer") { Anwer=lpVal; } } } MessageBox("手动输入数据保存到缓存!"); } }