Connect the code for the IE browser window

zhaozj2021-02-17  52

// - Connect the code to the IE browser window

// connie.cpp: Defines the entry point for the console application.//

#include "stdafx.h"

#pragma Warning (Disable: 4049) #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

#import // Internet explorer 5 // # import "mshtml.dll"

#include using namespace std;

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 Item (va); SHELL_WINDOW :: IWebBrowser2Ptr sp_Browser (sp_Disp); // SHELL_WINDOW :: IWebBrowser2Ptr sp_Browser = sp_Disp; // - OK if (! NULL = sp_Browser) {// cout << (char *) sp_Browser-> GetLocationName () << Endl; mshtml :: htmldocument2ptr SPDOC (sp_browser-> getDocument ()); if (null! = SPDOC) {Count ; cout << (char *) SPDOC-> gettitle () << Endl; SPDOC .Velease ();

sp_browser.release ();}} msp_shwinds.release ();

转载请注明原文地址:https://www.9cbs.com/read-28684.html

New Post(0)