Re: Trouble figuring out DirectCall interface

Roger Corman <[email protected]> Tue, 30 Sep 2003 18:33:16 -0700
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
Are you saying that the call to GetFunctionAddress() returns an error code? Or that it crashes with a memory access violation at that point?

The IDE makes quite a bit of use of DirectCall.

Have you defined your callback function in the win32 package? 

Also, once you get the function pointer back successfully, the defun-direct-callback macro will assume the function is :c linkage by default, you need to use :pascal linkage if you are going to declare it as __stdcall. This would probably cause an access violation.

Roger


At 04:56 PM 9/30/2003, you wrote:

>Has anyone gotten the call back functions to work via the 
>DirectCall interface? I keep getting a Memory access violation. 
>
>I am trying to do something like this:
>
>(defun-direct-callback add2numbers ((a long)(b long))
>    (+ a b))
>
>
>(save-image "math.img")
>
>// SimpleMath.h
>
>.
>.
>.
>typedef long (__stdcall *pfadder)(long, long);
>
>pfadder m_pfAdder;
>
>// SimleMath.cpp
>
>
>STDMETHODIMP CSimpleMath::add(long a, long b, long* c)
>{
>        if(!m_pfAdder)
>        {
>        
>                HRESULT hr = m_iLispCall->GetFunctionAddress
>(L"ADD2NUMBERS",L"WIN32",(LPVOID*)&m_pfAdder);
>        }
>
>        *c = m_pfAdder(a, b);
>        //*c = a + b;
>        return S_OK;
>}
>
>
>//end
>The initialize and the BlessThread all return S_OK, the 
>connectionpoint to ICormanLispTextOutput is successful, corman text 
>output flows through, but it errors out 
>on the GetFunctionAddress call. Any ideas out there?
>
>
>
>
>
>To unsubscribe from this group, send an email to:
>[email protected]
>
> 
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Upgrade to 128-Bit SSL Security!
http://us.click.yahoo.com/p7cEmB/s7qGAA/yigFAA/SyjtlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/