// - Enumeral IE all Element code
#include "stdafx.h"
#pragma Warning (Disable: 4049) #pragma Warning (Disable: 4192) #pragma Warning (Disable: 4146)
// # import "shdocvw.dll" exclude ( "tagREADYSTATE") # import "shdocvw.dll" // # import "shdocvw.dll" rename_namespace ( "SHELL_WINDOW") // using namespace SHELL_WINDOW; #define SHELL_WINDOW SHDocVw
#include
#include
INT iElement (htmldocument2ptr sp_doc) {int RET = 0; ccomptr
Do {
COUT << "--- list all ie element ---" << endl; // - failed // if (! successded)) if (! ")) IF (!")) ing (! " & pcollection))))))))))))))))
{COUT << "failed." << endl; break;
INT count = 0; int count = 0; if (! succeeded (pcollection-> get_length)) {cout << "failed." << endl;
For (int i = 0; i CComPtr Pelement-> get_tagname (& bstr); if (bstr.length ()> 0) cout << "tag =" << (char *) _ BSTR_T (BSTR); // << end1 Pelement-> get_innertext (& BSTR); if (bstr.length ()> 0) cout << "/ ttext = << (char *) _ bstr_t (bstr) << endl; else cout <<" / ttext = "< // pelement-> release ();} // spdispatch-> release ();}} // pcollection-> release (); cout << "--- list count = << count <<< | < RET = count; Break; WHILE (FALSE); Return Ret;} INT Main (int Argc, char * argv []) {cout << "--- Test ---" << endl; // - COM COINITIALIZE (NULL); Do {cout << "--- list all IE window --- "<< endl; SHELL_WINDOW :: IShellWindowsPtr msp_SHWinds = NULL; HRESULT hr = msp_SHWinds.CreateInstance (__ uuidof (SHELL_WINDOW :: ShellWindows)); ". FAILED" if (! S_OK = hr || NULL == msp_SHWinds) {cout << << endl; break } Int count = 0; int count = msp_shwinds-> getCount (); for (int i = 0; i IHTMLDocument2ptr sp_doc (sp_browser-> getDocument ()); if (null! = Sp_doc) {count ; CCOMBSTR BSTR; sp_doc-> get_title (& bstr); cout << (char *) _ BSTR_T (BSTR) << ENDL; Static int E = 0; if (0 == e) E = Ilement (sp_doc); sp_doc.release ();} sp_browser.release ();}} msp_shwinds.release (); COUT << "--- list count =" << count << "---" << endl; break;} while (false); // - com // counitialize (); // - ?? ? OleunInitialize (); return 0;}