Board index » cppbuilder » Acces Violation using variants & ActiveForms

Acces Violation using variants & ActiveForms

Hi everybody:

Im trying to call a method of an out-of-proc server using
Variant::OleFunction from within an ActiveForm.  However the call always
generates an Acces Violation on the OCX where the AF resides - (same address
for BCB4 and BCB5).  I'have a button on the AF and coded into the button's
OnClick event the following:

   Variant Monda ;
   HRESULT hr ;
   Monda = CreateOleObject( "Project2.Prueba" ) ;  // Works OK.  The server
is Up!
   hr = Monda.OleFunction( "Prueba" ) ; // Generates Acces Violation

The function I'm calling is a dummy one with no parameters.  If I use vtable
access using ATL smart pointers the call works properly, but I want to use
variants this time.

Any hint?  (try it yourself, the problem can be replicated easy)

Thank You all,

Ernesto DelVillar

 

Re:Acces Violation using variants & ActiveForms


Quote
In article <395933d3@dnews>, Ernesto DelVillar <edelvil...@usa.net> wrote:
>Im trying to call a method of an out-of-proc server using
>Variant::OleFunction from within an ActiveForm.  However the call always
>generates an Acces Violation on the OCX where the AF resides - (same address
>for BCB4 and BCB5).  I'have a button on the AF and coded into the button's
>OnClick event the following:

>   Variant Monda ;
>   HRESULT hr ;
>   Monda = CreateOleObject( "Project2.Prueba" ) ;  // Works OK.  The server
>is Up!
>   hr = Monda.OleFunction( "Prueba" ) ; // Generates Acces Violation

>The function I'm calling is a dummy one with no parameters.  If I use vtable
>access using ATL smart pointers the call works properly, but I want to use
>variants this time.

>Any hint?  (try it yourself, the problem can be replicated easy)

Hmm. I try not to use Variant:: as much as possible, but ...

can you step into the call and see how far it gets before blowing?

--
Si vales, valeo.

Other Threads