Witam,
Posiadam uchwyt do okna z klasą "Internet Explorer_Server" i chciałbym pobrać zawartość całego dokumentu HTML, jest to możliwe, jeśli tak to w jaki sposób?
Mam taki kod:
#include "stdafx.h"
#include <windows.h>
#include <mshtml.h>
#include <Oleacc.h>
#include <iostream>
#pragma comment(lib, "oleacc.lib")
BOOL CALLBACK EnumWindowsProc(HWND hwnd, UINT nMsg);
int main()
{
UINT nMsg = RegisterWindowMessage(L"WM_HTML_GETOBJECT");
CoInitialize(NULL);
EnumChildWindows(GetDesktopWindow(), (WNDENUMPROC)EnumWindowsProc, nMsg);
CoUninitialize();
std::cin.get();
return 0;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, UINT nMsg)
{
TCHAR classname[64];//zmienna przechowuje nazwe klasy
GetClassName(hwnd, classname, 64);//pobieramy nazwe klasy z hwnd z maksymalna dlugoscia 64 znaki
classname[63] = 0;//konczymy lancuch znakow
if (!lstrcmp(classname, L"Internet Explorer_Server"))//Porownuje stringi, jesli nazwa klasy to internet explorer_server to znalezlismy
{
DWORD dwResult;
IHTMLDocument2* spDoc;
SendMessageTimeout(hwnd, nMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, &dwResult);
if (!ObjectFromLresult(dwResult, IID_IHTMLDocument2, 0, (void**)&spDoc))
{
BSTR ss = NULL;
IHTMLElementCollection *all;
if (!spDoc->get_all(&all) && all)
{
long count;
all->get_length(&count) && count;
std::cout << "dlugosc wynosi:" << count << std::endl;
SysFreeString(ss);
}
spDoc->Release();
}
}
return true;
}
I jeśli n