|
I try to create an automation interface to my application, and I run into a problem. I have an application root that is creatable, but to create input for other objects in the automation model I need to CoCreate other objects as well. The problem is that new instances of my exe-file is created when I try to create these other objects. I want them to be created from the running instance, not that another instance is created for each CoCreateInstance. How should I do this?
Pål
|
|
|
|
|
Sounds like you are descripbing aggregation/containment. Try something like this.
// Header
CMyObj1 m_Obj1;
CMyObj2 m_Obj2;
// CPP
OnFinalConstruct
{
CoCreateInstance(MyObj1);
CoCreateInstance(MyObj2);
}
|
|
|
|
|
I think I was a bit unclear about the problem description. The object model in for instance Excel has several coclasses (Application, Sheet, Chart etc) I obviously do something wrong, because creating my coclasses from VB result in a new instance of the exe for each coclass. What mechanism ensures that the creatable objects are created in the same instance? Does anyone know?
Pål
|
|
|
|
|
hello.
i'm stuck with an issue that it is easy to write in an MFC app but because i HAVE to use ATL it makes life VERY difficult. I have to rewrite the following procedure from VB into VC++.
The VB program does this:
- checks to see if a particular database is open
- if it is get the application object and run a sub in it (through COM)
- if not then set a registry key and open the database
I can do the last thing easily but check and getting the actual object (as an IDispatch pointer) is the part I'm having trouble with.
Any ideas?
Rob Grundel
|
|
|
|
|
Checking to see if the db is open is a simple task with ATL and OLE DB. If you create an ATL project and insert a database consumer the wizard will walk you through connecting to it. Once you have this should have access to everything you need. The VB project probably uses ADO, which sit on top of OLE DB. See where this is going...
|
|
|
|
|
Hello
use oledb template like CDataSource to check the database
status. you have to include atldbcli.h.
From
Amitava Banerjee
|
|
|
|
|
When I right-click the interface and choose "New Method" in the method creation dialog the return type field is disabled. But I need to create method that returns "short". How do I do that?
|
|
|
|
|
Interface function already return a HRESULT, and your owner return value must be defined in the last argument with [out,retval], example:
myFunction([in] long id, [out,retval] long* pNumber)
By the way, you must not use "short" type , instead using "long".
|
|
|
|
|
What's the difference between COM and OLE?
|
|
|
|
|
A couple of years.
What we refer to as COM today was called OLE a few years ago. Just about every book dealing with COM has a chapter explaining the origins.
|
|
|
|
|
What's the difference between Interface and dispInterface?
|
|
|
|
|
A dispatch interface is usually used by late bound languages such as VB or JavaScript to call, or invoke, methods on your object.
|
|
|
|
|
as mentioned in the above comment the difference is the late binding but the actual differnce is under the hood in the depths of the COM architecture. Dispinterface are just IDispacth Interfaces and don't rely on v-tables. Custom interfaces (non-IDispatch) use vtables and are much faster than IDispatch interfaces. But alas VB has no support (or had no support... i hear the latest release does) for v-table driven interfaces.
Hope this helps some.
Joseph Dempsey
jdempsey@cox.rr.com
Joseph.Dempsey@thermobio.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
Hi!
I have developed a context menu shell extention.
It is registered successfully but it doesn't work.
Can anyone tell me what is reason behind it.
Thanks in anticipation.
|
|
|
|
|
Hello,
Is there another way of detecting if the client was crashed rather than
pinging it ? The same question for the server rather than to call a method
and to look at the RPC error.
Can it be possible to diagnose the origin of the error ?
In another words, what are the causes of the DCOM server crash ?
The causes can be the network, the computer or the server (software) which
was dead or was blocked... or a mixture of all of this.
Can it be possible to prevent it ?
Thanks by advance for your answers
|
|
|
|
|
Why do you care if the client crashed, especially with out of proc components. Your server is only kept alive for the time that clients hold refs to it. If the client crashes, DCOM has a ping mechanism that will shut your server down in 6 minutes. There could be anything that could cause a DCOM error including all of what you mentioned. If you are concerned you could create a thread that goes off and instantiates your DCOM server. The main thread can then carry on its merry way. You can even use WaitForSingleObject to set your own timeout so that you don't have to wait an extended period of time to see if the creation or call failed.
|
|
|
|
|
First, thanks for your answer.
I agree with you as regards the server. Furthermore, my server is an NT service and so, it is always kept alive ! (or virtually certain )
I need to know when the crash was caused and what provoked the crash of the clients which can also be server of my NT service. I can not wait 6 minutes to know if a client is dead: It would be catastrophic for my application
Can you supply me an example of use of WaitForSingleObject to test if a call failed ?
Thank you very much.
|
|
|
|
|
I'm developing a system that needs to dynamically call a number of different COM objects without the need to rebuild the service everytime a new object is added.
What I'm proposing is to have a common COM object exposing the generic method for all objects and use multiple inheritence to build each different COM object and override the generic method.
By building the service with the common COM object I can then create the appropriate COM object by getting the CLSID & LIBID from the registry and by getting the base interface have access to the common method.
Two questions.
1) Will this work, am I making it more difficult than it should be or is it a non-starter?
2) Has anybody got any examples of multiple inheritence using ATL. I've been scouring the web and haven't come up with anything half decent.
I've been away from COM for over two years working purely in C++ so I'm a bit rusty so please forgive my stupidity.
Cheers
Darren Mann
|
|
|
|
|
i´m totally ignorant about com, so don´t flame me, please
how do you declare a pointer to an interface whose "name" ( eg. IPicture ) you don´t know. I´m trying to use the real player activeX control, but i can´t find the name on their on-line docs, just the clsid. How do you get to know the names of the methods like the vb ide does. i´ve tried with Ole Viewer, but i couldn´t find anything
thanks
Gabriel
don´t worry, drink happy
|
|
|
|
|
Look in Ole View or the VB object browser
|
|
|
|
|
I have this COM object that behind a firewall the transaction support attribute is "reqired" and I am able to access this COM without any issues. However, to put this COM behind a firewall and I am forced to changed the transaction support attribute to "Not Supported" from "reqired". Are there any known issues or changes that should be implemented to work around this? What can I modify to get this to function correctly.
Thank You,
Coding Away!
David
|
|
|
|
|
Hallo.... can anybody help me to get COM tutorials on web??? i'm new to COM familiar in windows programming
-Hariharan
|
|
|
|
|
|
He all you COM gurus,
can you help a complete retard out of jam.
Hopefully this is related enough to COM to be in this forum.
I was wanting to play around with DirectPLay8.
Taking the SimpleServer Example Code that comes with the
DirectX 8.0 SDk, i am simply trying to transferr the code from Win32 api
and make it a little more modular in a MFC project.
but i ran into the snag of i cant even get COM to initialize.
taking the following line from the sample code
// Init COM so we can use CoCreateInstance
CoInitializeEx( NULL, COINIT_MULTITHREADED );
I get the following compile error:
error C2065: 'CoInitializeEx' : undeclared identifier
error C2065: 'COINIT_MULTITHREADED' : undeclared identifier
these two are defined in objbase.h.
I included all the files from the sample code:
#include <basetsd.h>
#include <dplay8.h>
#include <dpaddr.h>
#include <dxerr8.h>
#include "DXUtil.h"
and all the libs from the project:
dplay.lib dxguid.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib odbc32.lib odbccp32.lib dxerr8.lib winmm.lib kernel32.lib user32.lib ole32.lib uuid.lib
but it still doenst seem to include objbase.h
what am i missing? I just want to make this little line of code Initialize COM
and i will die happy.
thanks
|
|
|
|
|
So it doesnt get defined becuase of the following lines within objbase.h
#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
WINOLEAPI CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);
#endif // DCOM
Im not sure what i did wrong and why neither of these (_WIN32_WINNT || _WIN32_DCOM) are not defined in my MFC app that was created by appwizard
if you havnt figured it out yet, i am a complete novice.
Any leads will help.
|
|
|
|