IonicWind Software

IWBasic => General Questions => Topic started by: sapero on April 04, 2008, 03:53:29 PM

Title: Troubles with COMREF
Post by: sapero on April 04, 2008, 03:53:29 PM
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.
Title: Re: Troubles with COMREF
Post by: Ionic Wind Support Team on April 04, 2008, 04:08:48 PM
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.