Take the corresponding picture resources in the WebBrowser

Source: Internet
Author: User

Using the Webbrower control in the client, the page is already displayed in the control, the corresponding picture resource should have been downloaded, the image resource is found from the cache, and both methods can be

1, Geturlcacheentryinfo

http://msdn.microsoft.com/en-us/library/aa384185 (v=vs.85). aspx

2, Findfirsturlcacheentry, FindNextUrlCacheEntry, Findcloseurlcache


voidCtesthaijiadlg::ondocumentcomplete (lpdispatch pdisp, LPCTSTR szurl) {if(Pdisp = =m_pBrowserApp)        {CString Scheckurl (szurl); if(Scheckurl.comparenocase (sloginurl) = =0)        {            if(m_sphtmldoc) {Cdispatch disp=M_sphtmldoc; Disp. Invokeptr (L"getElementById", L"txtUserName"). Put (L"value", L"ABC"); Disp. Invokeptr (L"getElementById", L"Txtpassword"). Put (L"value", L"ABC"); Cdispatch dispimg= disp. Invokeptr (L"getElementById", L"validimg"); CString s= Dispimg.get (L"src"); if(1) {Lpinternet_cache_entry_info lpcacheentry=NULL; DWORD dwentrysize=4096; Lpcacheentry= (Lpinternet_cache_entry_info)New Char[Dwentrysize]; Lpcacheentry->dwstructsize =dwentrysize; BOOL b= Geturlcacheentryinfo (S, Lpcacheentry, &dwentrysize); CString spath= lpcacheentry->Lpszlocalfilename;                    RECT RC1; SystemParametersInfo (Spi_getworkarea,0, (PVOID) &rc1,0); SetWindowPos (NULL,0, Rc1.bottom-4,0,0, swp_nosize);                    Cdlgcode Dlg; Dlg.                    SetPath (spath); if(DLG. DoModal () = =IDOK) {disp. Invokeptr (L"getElementById", L"Txtimgcode"). Put (L"value", CComVariant (Dlg.m_scode)); Disp. Invokeptr (L"getElementById", L"Btnlogin"). Invoke (L"Click"); SetWindowPos (NULL,0,0,0,0, swp_nosize); }                }                if(0) {Lpinternet_cache_entry_info lpcacheentry=NULL; HANDLE Hcachedir=NULL; DWORD dwtrysize, Dwentrysize=4096; DWORD dwerror=Error_insufficient_buffer; BOOL bsuccess, Bdone= FALSE;//has been processed and is initially set to false                     while(!bdone) {                        Switch(dwerror) { CaseError_insufficient_buffer:if(lpcacheentry) {delete [] lpcacheentry; } lpcacheentry= (Lpinternet_cache_entry_info)New Char[Dwentrysize]; Lpcacheentry->dwstructsize =dwentrysize; Dwtrysize=dwentrysize; if(!Hcachedir) {//is empty, stating the first execution, need to find the firstHcachedir = Findfirsturlcacheentry (null,lpcacheentry,&dwtrysize); Bsuccess= (Hcachedir! =NULL); }                            Else{bsuccess= FindNextUrlCacheEntry (hcachedir,lpcacheentry,&dwtrysize); }                            if(!bsuccess) {dwerror=GetLastError (); Dwentrysize= Dwtrysize;//use the resulting new length                            }                            Else{dwerror=error_success; }                             Break; //we is done                         CaseError_no_more_items:bdone=TRUE;  Break; //we have got an entry                         Caseerror_success:if(Bsuccess && (Normal_cache_entry & lpcacheentry->Cacheentrytype)) { //CString SURL1 = lpcacheentry->Lpszsourceurlname; if(Surl1.compare (s) = =0)                                {                                    //processing                                }                                //CTime lastmodified (lpcacheentry->lastmodifiedtime); //CTime lastaccessed (lpcacheentry->lastaccesstime); //a changed cookie-delete it! //if (lastmodified >= m_time | | lastaccessed >= m_time) {//Const CString NAME = lpcacheentry->lpszsourceurlname; //Const CString result = Lastmodified.format ("%i:%m:%s%p%d%b%Y"); //MessageBox (NULL, name + "Last modified" + result, "Deleting cookie", MB_OK); //deleteurlcacheentry (lpcacheentry->lpszsourceurlname);                            }                            //get ready for next entryDwtrysize =dwentrysize; if(! FindNextUrlCacheEntry (hcachedir,lpcacheentry,&dwtrysize)) {dwerror=GetLastError (); Dwentrysize= Dwtrysize;//use the resulting new length                            }                            Else{dwerror=error_success; }                             Break; //Unknown error                        default: CString strerror; Strerror.format (_t ("there is a error (%d) when trying deleting temporary internet files.\r\n"), dwerror);                            TRACE (strerror); Bdone=TRUE;  Break; if(Bdone) Break; Sleep (Ten);if(Lpcacheentry) {delete [] lpcacheentry; lpcacheentry =NULL;} if(Hcachedir) {Findcloseurlcache (hcachedir); hcachedir =NULL;}  Break; }}}}}} cdhtmldialog::ondocumentcomplete (Pdisp, szurl);} 

Take the corresponding picture resources in the WebBrowser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.