Board index » cppbuilder » Still tring to pass a COM Interface

Still tring to pass a COM Interface

Ok, I have a client(EXE) that calls an inproc activex library(DLL).  This
inproc DLL needs to call an out-of-proc automation server(EXE).

Client code:
IDispatch *disp = (IDispatch*)(DataModule1->DCOMConnection1->AppServer);
IRemoteTrackingClassDisp TempInterface((IRemoteTrackingClass*)disp);
if(!GSLELogonServObj)
    GSLELogonServObj = CoGSLELogonClass::Create();
GSLELogonServObj->ClientSideLogon(TempInterface, WideString("user"),
WideString("pass"));

Inproc DLL code:
STDMETHODIMP TGSLELogonClassImpl::ClientSideLogon(LPUNKNOWN Interface,  BSTR
Username, BSTR Password, BSTR* Rslt){
AnsiString User;
AnsiString Pass;
TFormLogon *TmpFormLogon = new TFormLogon(&User, &Pass, NULL);
TmpFormLogon->ShowModal();

***NEXT LINE WILL NOT COMPILE***
***TrackingClientLogon is in the remote process app server***
 Interface->TrackingClientLogon(User, Pass);
delete TmpFormLogon;
return S_OK;

Quote
}

I'm pretty sure I'm screwing up passing the LPIUNKNOWN.  I also tried
IDispatch*...no luck.  I also tried passing a pointer to the function I
wanted to call...something like:

IDispatch *disp = (IDispatch*)(DataModule1->DCOMConnection1->AppServer);
IRemoteTrackingClassDisp TempInterface((IRemoteTrackingClass*)disp);
BSTR __fastcall (__closure *fp)(BSTR, BSTR) =
&TempInterface.TrackingClientLogon;

but I don't think this is legal in automation since it can't be marshalled.
It may be for inproc though I'm not sure???  So the question remains how can
I pass an interface that the client must determine since it is where the
TDCOMConnection component resides to a inproc DLL for the DLL to call.  An
example would be great!

If someone could clear this up for me it would be much appreciated.

Thanks,
Rich

 

Re:Still tring to pass a COM Interface


In article <8b65dk$a...@bornews.borland.com>,

Quote
Richard Bair <richard.b...@NOSPAMgsle.gensig.com> wrote:
>Inproc DLL code:
>***NEXT LINE WILL NOT COMPILE***
>***TrackingClientLogon is in the remote process app server***
> Interface->TrackingClientLogon(User, Pass);

Sure.
The compiler thinks your interface is an IUnknown, and TrackingCLientLogon
is a member of some other interface which derives from IUnknown.

If this were straight c++ (no COM involved), you'd simply cast it
to a type which implemented the method, right?
--
Si vales, valeo.

Re:Still tring to pass a COM Interface


Instead of:

Quote
> ***TrackingClientLogon is in the remote process app server***
>  Interface->TrackingClientLogon(User, Pass);

Try:

IRemoteTrackingClass* RemoteInterface;
Interface->QueryInterface(IID_IRemoteTrackingClass, &RemoteInterface);
RemoteInterface->TrackingClientLogon(User, Pass);

Interface is an IUnknown pointer and has only 3 members, none of which is
TrackingClientLogon.  You need to QueryInterface to get the right interface.

Mark

Quote
Richard Bair <richard.b...@NOSPAMgsle.gensig.com> wrote in message

news:8b65dk$a0v8@bornews.borland.com...
<snip>

Other Threads