May 18, 2024, 06:53:11 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Troubles with COMREF

Started by sapero, April 04, 2008, 03:53:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

The interface pointer - build-in comref variable - has type of integer, so passing it as function parameter declared as pointer, pushes the address instead value.
The problem is that (while converting the headers) all pointer variables like IUnknown*, RECT* were converted to simple pointers:
before: declare import, AtlAdvise(IUnknown* pUnkCP,
after:  declare import, AtlAdvise(pointer pUnkCP,


crash example:
IWebBrowser2 m_webbrowser

m_webbrowser = valid_value
AtlAdvise(m_webbrowser, this, _DIID_DWebBrowserEvents2, &m_cookie)

The m_webbrowser variable is passed by reference causing the crash.

Would be possible to change default-type of COMREF to pointer? It is probably a small change, while looking up every pointer in about 1000 headers to change it to comref, or starting again from zero looks not promising.

Ionic Wind Support Team

COMREF doesn't have a type of integer, where did you get that idea?

The correct import would be:

declare import, AtlAdvise(COMREF pUnkCP,....

However you can probably do this:

AtlAdvise(m_webbrowser+0, this, _DIID_DWebBrowserEvents2, &m_cookie)

If you want to leave the type as pointer. 

Quote
Would be possible to change default-type of COMREF to pointer?

It has its own type really, it is used to support the -> syntax and acts as an interface pointer.  The only thing I could change is the default behaviour when a pointer parameter is passed a COMREF variable.  Which would take a bit of study as I don't want to break my current code base.

Paul.
Ionic Wind Support Team