Click here to Skip to main content
15,884,177 members
Home / Discussions / COM
   

COM

 
GeneralRe: Sorry Pin
Tim Cook6-Apr-09 8:00
Tim Cook6-Apr-09 8:00 
GeneralI'll Try to Explain Clearly Pin
Baltoro9-Apr-09 10:32
Baltoro9-Apr-09 10:32 
GeneralRe: I'll Try to Explain Clearly Pin
Tim Cook17-Apr-09 5:31
Tim Cook17-Apr-09 5:31 
Questionactivex loading from tomcat 6 Pin
aysl2-Apr-09 5:28
aysl2-Apr-09 5:28 
QuestionTroubles embedding IE8 WebBrowser control Pin
Vlasta_1-Apr-09 5:11
Vlasta_1-Apr-09 5:11 
QuestionUsing COM to receive cell updates from excel in VB .NET Pin
mmiller0391-Apr-09 5:07
mmiller0391-Apr-09 5:07 
Questionhow to get mail address in outlook express Pin
nikhil3131-Mar-09 22:25
nikhil3131-Mar-09 22:25 
QuestionC++ COM EventHandler: How to catch COM events from Delphi COM Server / VC6 Pin
ipforce30-Mar-09 4:57
ipforce30-Mar-09 4:57 
Hi all,

I'm quite new in COM but unfortunately I have to talk to a Delphi Application which supports a COM interface to other applications.

Invoking Methods of this COM Server or reading some attributes works quite well in my test application, in pseudo code it looks like

<br />
CoInitialize( NULL );<br />
...<br />
// Translate server ProgID into a CLSID. ClsidFromProgID<br />
CLSIDFromProgID( L"DVBViewerServer.DVBViewer", & clsid );<br />
...<br />
GetActiveObject( clsid, NULL, & pIUnknown );<br />
...<br />
// get IDispatch pointer<br />
pIUnknown->QueryInterface( IID_IDispatch, ( void * * ) & pIDispatch );<br />
...<br />
// Get Property ID<br />
pDispatch->GetIDsOfNames( IID_NULL, & szProperty, 1, LOCALE_SYSTEM_DEFAULT, & DispId );<br />
// Walk through the hierarchy<br />
pDispatch->Invoke(DispId, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dp, &vReturn, NULL, NULL);<br />
...<br />
vReturn.pdispVal->GetIDsOfNames( IID_NULL, & szMeth, 1, LOCALE_SYSTEM_DEFAULT, & dispID );<br />
...<br />
// Invoke the desired Method ...<br />
vReturn.pdispVal->Invoke( dispID, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, & dp20, & varRetVal, NULL, NULL );<br />
<br />
// Clean up etc.<br />


On the other hand, it doesn't seem so easy to get an own c++ function registered as a COM Eventhandler.

I've read all articles and tutorials, but i didn't found a small and simple tutorial how to get from the COM/Delphi interface description

<br />
type ICOMServerEvents = dispinterface(IDispInterface)<br />
procedure onAddRecord(ID: Integer);<br />
procedure onClose;<br />
...<br />


to something like
<br />
void CALLBACK onAddRecord( int iID) {}<br />


Do I have do define an interface
<br />
interface ICOMServerEvents : IUnknown<br />
{<br />
//Desired functionality for Component<br />
virtual void __stdcall onAddRecord( int iID) = 0;<br />
...<br />
}<br />


then derive a class

<br />
class CCOMServerEvent : public ICOMServerEvents<br />
{<br />
   virtual void __stdcall onAddRecord( int iID) { TRACE("AddRecord"); }<br />
   ....<br />
}<br />


and use something like createinstance to get this connected to the server ?

What is the simplest way ?

BR,
Andi
AnswerRe: C++ COM EventHandler: How to catch COM events from Delphi COM Server / VC6 Pin
Jonathan Davies2-Apr-09 5:32
Jonathan Davies2-Apr-09 5:32 
GeneralRe: C++ COM EventHandler: How to catch COM events from Delphi COM Server / VC6 Pin
ipforce2-Apr-09 6:08
ipforce2-Apr-09 6:08 
GeneralRe: C++ COM EventHandler: How to catch COM events from Delphi COM Server / VC6 Pin
ipforce2-Apr-09 6:59
ipforce2-Apr-09 6:59 
QuestionUpdating Resource Pin
sumedh_code30-Mar-09 0:55
sumedh_code30-Mar-09 0:55 
QuestionAccess Denied in VC++ COM Pin
RevathiRamakumar30-Mar-09 0:20
RevathiRamakumar30-Mar-09 0:20 
AnswerRe: Access Denied in VC++ COM Pin
Roger Stoltz30-Mar-09 3:35
Roger Stoltz30-Mar-09 3:35 
GeneralRe: Access Denied in VC++ COM [modified] Pin
RevathiRamakumar30-Mar-09 19:39
RevathiRamakumar30-Mar-09 19:39 
AnswerRe: Access Denied in VC++ COM Pin
Roger Stoltz30-Mar-09 22:17
Roger Stoltz30-Mar-09 22:17 
GeneralRe: Access Denied in VC++ COM Pin
RevathiRamakumar30-Mar-09 22:46
RevathiRamakumar30-Mar-09 22:46 
AnswerRe: Access Denied in VC++ COM Pin
Roger Stoltz30-Mar-09 23:04
Roger Stoltz30-Mar-09 23:04 
GeneralRe: Access Denied in VC++ COM Pin
RevathiRamakumar30-Mar-09 23:10
RevathiRamakumar30-Mar-09 23:10 
AnswerRe: Access Denied in VC++ COM Pin
Roger Stoltz30-Mar-09 23:13
Roger Stoltz30-Mar-09 23:13 
GeneralRe: Access Denied in VC++ COM Pin
RevathiRamakumar30-Mar-09 23:16
RevathiRamakumar30-Mar-09 23:16 
GeneralRe: Access Denied in VC++ COM Pin
RevathiRamakumar30-Mar-09 23:56
RevathiRamakumar30-Mar-09 23:56 
AnswerRe: Access Denied in VC++ COM Pin
Roger Stoltz31-Mar-09 3:17
Roger Stoltz31-Mar-09 3:17 
QuestionRe: Access Denied in VC++ COM Pin
Roger Stoltz31-Mar-09 3:17
Roger Stoltz31-Mar-09 3:17 
AnswerRe: Access Denied in VC++ COM Pin
RevathiRamakumar31-Mar-09 18:32
RevathiRamakumar31-Mar-09 18:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.