dmf9000
asked on
callbacks in c++
Hello, someone can to get me samples of callbacks in c++.How I define an interface callback?
How I use the interface .
Thanks.
How I use the interface .
Thanks.
If by interface you're talking COM interfaces. then read on.
-------------------------- --
Reproduced from http://www-tcsn.experts-exchange.com/questions/20751731/DCOM-Connection-Points.html
-------------------------- --
*All* that is needed is an interface pointer exchanged and held by each side of the *conversation*.
-- you do know IDL don't you --
[
object,
uuid(...),
helpstring("IMyClient Interface")
]
interface IMyClient : IUnknown
{
[helpstring("method ClientMethod")]
HRESULT ClientMethod(...);
...
};
[
object,
uuid(...),
helpstring("IMyServer Interface")
]
interface IMyServer : IUnknown
{
[helpstring("method AdviseClient")]
HRESULT AdviseClient([in] IMyClient*);
...
};
All that is required is for the client to instantiate the server:
IMyServer* pMyServer = 0;
CoCreateInstance(..., &pMyServer); // assuming the AppId registry value is set-up to instruct DCOM usage
pMyServer->AdviseClient(st atic_cast< IMyClient* >(this));
At which point the IMyServer implementation can invoke the client method ClientMethod:
m_pMyClient->ClientMethod( ...); // assuming m_pMyClient is typed as IMyClient*
as and when it feels necessary to do so.
Simple as that. No MFC. No IConnectionPoint etc.
[This example assumes that standard marshalling is employed. Also that IMyClient is implemented on the client class represented by 'this' - otherwise the normal QI mechanism should be employed instead.]
--------------------------
Reproduced from http://www-tcsn.experts-exchange.com/questions/20751731/DCOM-Connection-Points.html
--------------------------
*All* that is needed is an interface pointer exchanged and held by each side of the *conversation*.
-- you do know IDL don't you --
[
object,
uuid(...),
helpstring("IMyClient Interface")
]
interface IMyClient : IUnknown
{
[helpstring("method ClientMethod")]
HRESULT ClientMethod(...);
...
};
[
object,
uuid(...),
helpstring("IMyServer Interface")
]
interface IMyServer : IUnknown
{
[helpstring("method AdviseClient")]
HRESULT AdviseClient([in] IMyClient*);
...
};
All that is required is for the client to instantiate the server:
IMyServer* pMyServer = 0;
CoCreateInstance(..., &pMyServer); // assuming the AppId registry value is set-up to instruct DCOM usage
pMyServer->AdviseClient(st
At which point the IMyServer implementation can invoke the client method ClientMethod:
m_pMyClient->ClientMethod(
as and when it feels necessary to do so.
Simple as that. No MFC. No IConnectionPoint etc.
[This example assumes that standard marshalling is employed. Also that IMyClient is implemented on the client class represented by 'this' - otherwise the normal QI mechanism should be employed instead.]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dmf9000:
> Hello, someone can to get me samples of callbacks in c++.How I define an interface callback?
> How I use the interface .
Actually, I found a good site that describes an example similiar to the one I gave you.
http://www.gmonline.demon.co.uk/cscene/topics/misc/cs7-04.xml.html
Dex*
> Hello, someone can to get me samples of callbacks in c++.How I define an interface callback?
> How I use the interface .
Actually, I found a good site that describes an example similiar to the one I gave you.
http://www.gmonline.demon.co.uk/cscene/topics/misc/cs7-04.xml.html
Dex*
I suggest you clarify your question and explain what it is you're trying to de in DETAIL. Another suggestion would be to ask the EE moderators to move this question to a more appropriate topic area. The best choice would be the PROGRAMMING topic area for your specific operating system.