Click here to Skip to main content
15,936,971 members
Home / Discussions / COM
   

COM

 
QuestionFFDShow in my project... Pin
R@jeev K R4-Apr-10 23:25
R@jeev K R4-Apr-10 23:25 
QuestionRe: FFDShow in my project... Pin
Cool_Dev5-Apr-10 19:13
Cool_Dev5-Apr-10 19:13 
AnswerRe: FFDShow in my project... Pin
R@jeev K R5-Apr-10 19:55
R@jeev K R5-Apr-10 19:55 
QuestionWhy this Method save the same bitmap every times called? Pin
bicphuong2-Apr-10 20:48
bicphuong2-Apr-10 20:48 
AnswerRe: Why this Method save the same bitmap every times called? Pin
Baltoro14-Apr-10 14:08
Baltoro14-Apr-10 14:08 
QuestionUnable to register simpleui5.ocx in system32 Pin
Hunzian31-Mar-10 23:55
Hunzian31-Mar-10 23:55 
AnswerRe: Unable to register simpleui5.ocx in system32 Pin
Adam Roderick J2-Apr-10 18:22
Adam Roderick J2-Apr-10 18:22 
QuestionHow to Sink Current IE IWebBrowser Interface? Pin
twblue31-Mar-10 17:55
twblue31-Mar-10 17:55 
I am sorry my pool English.

I would like to filter the URL address by sink the IWebBrowser interface of current IE. first I get the current IE's IWebBrowser Interface, And the IConnectionPoint interface. but There is error when I connect with function "Advise".
this is my code:

// Get IE
BOOL EnumIE(HWND hWnd)
{
CoInitialize(NULL);
SHDocVw::IShellWindowsPtr spShWinds;

if (FAILED(spShWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows))))
{
return FALSE;
}

long nCount = spShWinds->GetCount();

for (int n = 0; n < nCount; n++)
{
IDispatchPtr spDisp;
_variant_t var = (long)n;
spDisp = spShWinds->Item(var);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL)
{
HWND hProcHwnd = NULL;
spBrowser->get_HWND((long*)&hProcHwnd);
if (hProcHwnd == hWnd)
{
ConnectIE(spBrowser); // connect the IE
}

}
}
return TRUE;
}

// connect current IE
void ConnectIE(IUnknown *pUnkSite) // 连接IE接口
{
HRESULT hr;
IWebBrowser2 *pSite; // the currently set site
if (pUnkSite)
pUnkSite->AddRef();

hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void**)&pSite);
pUnkSite->Release();

if (FAILED(hr))
return;

IConnectionPointContainer* pCPC;
IConnectionPoint *pCP;
hr = pSite->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
if (FAILED(hr))
return;

hr = pCPC->FindConnectionPoint(DIID_DWebBrowserEvents2,&pCP); // 得到连接点
if (FAILED(hr))
{
pCPC->Release();
return;
}

CComPtr<iunknown&gt> spUnk; //得到接受器接口
CSink theSink;
DWORD m_dwCookie;

theSink.QueryInterface(IID_IUnknown, (LPVOID *)&spUnk);
hr = pCP->Advise(spUnk, &m_dwCookie); // 建立连接 注意: 此处会失败。
// here will be fail. return hr = 0x80004000
if (FAILED(hr))
return;
}

this is my sink class:
// sink.h
class CSink: public IDispatch
{
public:
CSink();
virtual ~CSink();
// IUnknown
STDMETHOD(QueryInterface)(const struct _GUID &iid,void ** ppv);
ULONG __stdcall AddRef(void);
ULONG __stdcall Release(void);
// IDispatch
STDMETHOD(GetTypeInfoCount)(unsigned int *);
STDMETHOD(GetTypeInfo)(unsigned int,unsigned long,struct ITypeInfo ** );
STDMETHOD(GetIDsOfNames)(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *);
STDMETHOD(Invoke)(long dispID,const struct _GUID &,unsigned long,unsigned short,struct tagDISPPARAMS * pParams,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *);

STDMETHODIMP SetSite(IUnknown *pUnkSite);

private:
DWORD m_dwCookie; // 连接的 cookie
};

// sink.cpp
CSink::CSink()
{
}

CSink::~CSink()
{

}
// STDMETHODIMP 是宏,等价于 long __stdcall
STDMETHODIMP CSink::QueryInterface(const struct _GUID &iid,void ** ppv)
{
*ppv=this;
return S_OK;
}

ULONG __stdcall CSink::AddRef(void)
{ return 1; }

ULONG __stdcall CSink::Release(void)
{ return 0; }

STDMETHODIMP CSink::GetTypeInfoCount(unsigned int *)
{ return E_NOTIMPL; }

STDMETHODIMP CSink::GetTypeInfo(unsigned int,unsigned long,struct ITypeInfo ** )
{ return E_NOTIMPL; }

STDMETHODIMP CSink::GetIDsOfNames(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *)
{ return E_NOTIMPL; }

STDMETHODIMP CSink::Invoke(
long dispID,
const struct _GUID &,
unsigned long,
unsigned short,
struct tagDISPPARAMS * pParams,
struct tagVARIANT *,
struct tagEXCEPINFO *,
unsigned int *)
{
switch(dispID)
{
case DISPID_BEFORENAVIGATE2:
MessageBox(NULL, "Filter", "HAHA", MB_OK);
break;
default:
break;
}
return S_OK;
}


Hope to get help, Thank you.
Questionhow to register OCX on the 64 bit vista machine Pin
PrafullaShirke2723-Mar-10 19:59
professionalPrafullaShirke2723-Mar-10 19:59 
AnswerRe: how to register OCX on the 64 bit vista machine Pin
KingsGambit23-Mar-10 23:36
KingsGambit23-Mar-10 23:36 
AnswerRe: how to register OCX on the 64 bit vista machine Pin
Abhinav S27-Mar-10 19:50
Abhinav S27-Mar-10 19:50 
QuestionError handling using HRESULT Pin
PaulowniaK23-Mar-10 19:32
PaulowniaK23-Mar-10 19:32 
AnswerRe: Error handling using HRESULT PinPopular
Stephen Hewitt23-Mar-10 21:36
Stephen Hewitt23-Mar-10 21:36 
AnswerRe: Error handling using HRESULT Pin
KarstenK6-Apr-10 21:27
mveKarstenK6-Apr-10 21:27 
QuestionCom Exe server Pin
ashish8patil21-Mar-10 20:28
ashish8patil21-Mar-10 20:28 
AnswerRe: Com Exe server Pin
KingsGambit21-Mar-10 23:09
KingsGambit21-Mar-10 23:09 
GeneralRe: Com Exe server Pin
ashish8patil22-Mar-10 4:11
ashish8patil22-Mar-10 4:11 
GeneralRe: Com Exe server Pin
KingsGambit22-Mar-10 20:36
KingsGambit22-Mar-10 20:36 
AnswerRe: Com Exe server Pin
Adam Roderick J24-Mar-10 19:36
Adam Roderick J24-Mar-10 19:36 
Questionhow to connection to a remote sql server via ado? [modified] Pin
kcynic20-Mar-10 23:43
kcynic20-Mar-10 23:43 
AnswerRe: how to connection to a remote sql server via ado? Pin
T21024-Apr-10 20:49
T21024-Apr-10 20:49 
QuestionGIT CPU usage Pin
marko201019-Mar-10 15:13
marko201019-Mar-10 15:13 
QuestionQuestion on Regcomplus.exe Pin
Simon Mandy19-Mar-10 8:44
Simon Mandy19-Mar-10 8:44 
QuestionDrag and drop shell extension blocking explorer.exe Pin
Sebastien Mongrain19-Mar-10 8:15
Sebastien Mongrain19-Mar-10 8:15 
QuestionIDispatch Pin
trioum18-Mar-10 2:23
trioum18-Mar-10 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.