#define UNICODE
#define _UNICODE
#include <tchar.h>
#include <stdio.h>
#include <Windows.h>
#include <mshtml.h>
#include <ExDisp.h>
int main(int argc, char* argv[])
{
HRESULT hr;
CoInitialize(NULL);
IShellWindows * lpShellWindows;
hr = CoCreateInstance(CLSID_ShellWindows, NULL, 一, IID_IShellWindows, (PVOID*)&lpShellWindows);
if ( hr == S_OK )
{
IDispatch* lpDispatch;
long nCount;
lpShellWindows->get_Count(&nCount);
for ( long i = 0; i < nCount; i++ )
{
VARIANT varIndex;
varIndex.vt = VT_I 四;
varIndex.intVal = i;
hr = lpShellWindows->Item(varIndex, &lpDispatch);
if ( hr == S_OK )
{
IWebBrowser 二* lpWebBrowser 二;
hr = lpDispatch->QueryInterface(IID_IWebBrowser 二, (PVOID*)&lpWebBrowser 二);
if ( hr == S_OK )
{
IDispatch* lpDispatch;
// lpWebBrowser 二->get_HWND();
hr = lpWebBrowser 二->get_Document(&lpDispatch);
if ( hr == S_OK )
{
IHTMLDocument 二* lpDocument 二;
hr = lpDispatch->QueryInterface(IID_IHTMLDocument 二, (PVOID*)&lpDocument 二);
if ( hr == S_OK )
{
BSTR bstrCookie;
hr = lpDocument 二->get_cookie(&bstrCookie);
if ( hr == S_OK )
{
MessageBox(NULL, bstrCookie, NULL, 0);
SysFreeString(bstrCookie);
}
lpDocument 二->Release();
}
lpDispatch->Release();
}
lpWebBrowser 二->Release();
}
lpDispatch->Release();
}
}
lpShellWindows->Release();
}
CoUninitialize();
return 0;
}