|
Hi,
The thing that you didn't get about COM technology is that "you will not deal with classes any more, what you have to care about is interfaces". Here you are trying to create an instance of Try class, which is wrong in COM world. You have to ask the component for a certain interface, and the component itself will create the class instance for you, and it will cast it to the required interface.
To access your component you have to make a call like this one:
{
IX *pX; //See, you are defining the interface instead of the class
HRESULT hr = CoCreateinstance(CLSID_Try, NULL, CLSCTX_SERVER, IID_IX,(void**) &pX);
pX->fx();
pX->Release();
}
Regards,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
Thank you for your reply.
|
|
|
|
|
I'm totally new to COM and I want to know of some good starting reference information (online articles, books, sites).
The problem I want to address is interfacing a VB application with my VC++ app. I will be sharing data between the two apps, probably in the form of a linked-list structure (on VC++ side) and an array (on the VB side.)
Thanks for the help.
Johnny
|
|
|
|
|
I am designing a module and I want to know if this is a good design or not. My conerns are that I will be conflicting with the COM threading architecture.
Could anyone tell me if this is ok? :
I have an object, IQueue which has a method IQueue::Add([in] long nID)
IQueue is an MTA, meaning that its methods could be called multiple times simaltaneusly.
long nID will be added to a vector<long>. Adding to the vector<long> is thread safe. (using my own protection mechanism)
Till there I am fine.
Now, here is where I need help.
When IQueue is initialized, I want to create a thread that will scan this vector<long>, pick up the longs from it and do something with them.
Is it OK if I create a new thread from within IQueue? (this new thread will only be accessible internally from IQueue)
Any thoughts?
Thanks!
Jeremy.
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
Hi,
There are two things (as I saw from what you have said) that you have to care of:
1- Once you have created a new thread (withing an MTA or STA), this new thread does not know anything about COM Runtime Environment, this means that you have to call CoInitialize(0) or CoInitializeEx(0, ..).
2- Also this new thread cannot access your Vector, you have to pass this vector to the new thread.
This is what I can say about your problem
Enjoy,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
1) Ok, no problem. Thanks for pointing it out.
2) No problem there, I have a mechanism to do that.
Thanks!
Jeremy.
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
This is a real nitpicker's comment...
But "IQueue is an MTA" is not a valid statement. IQueue is an interface, and it can be implemented by many different COM objects. Each of these objects will have their own threading model.
I assume what you mean is "I have an object with an IQueue interface, and the object's threading model is MTA."
As for your question, what you are doing is a-OK, just make sure you do indeed specify the object as free-threaded. The first time something similar to what you are doing here, I had specified in the ATL wizard "Both" - and so when the object was instantiated by an object in an STA evil things began to occur .
|
|
|
|
|
Hi All!
I'm trying to add some Text To Speech and Speech Recognition capabilities to a VC++ software.
I've installed a TTS and a SR software, but they are accessible through COM objects.
The OLE View tool gives the description of these objects.
I've tried to add one of these COM objects into my software, using the following method :
- add it with the ClassView tool (choosing the corresponding DLL : ClassView
creates and adds the corresponding .h and .cpp files
- use the 'classical' COM client code :
1) OleInitialize()
2) CoCreateInstance()
The CoCreateInstance() fails and returns the following error 'ClassNotRegistered'.
As I'm a pure beginner in COM technology, I need some help for this part of my
project.
Thanks.
|
|
|
|
|
Are there any C++ samples with the TTS/SR software you are using? Do these work. It sounds like the COM object haven't been registered. Is this Microsoft Speech SDK you are using?
The only question mark over what you seem to be doing is that I use CoInitialize rather than OleInitialize.
Michael
|
|
|
|
|
No (no C++ samples code using the TTS and SR software).
The SR comes from IBM ViaVoice, and the TTS comes from Learnout and Houspie.
But to begin with COM, I tried to implement a simpler TTS object : Xvoice.dll.
The UUID is given by the Ole View Tool, but I'm not sure that this object is
registered.
It would be helpfull for me if you accept that I send you this dll, so that you can try by yourself and give me the information for :
- getting the right UUID of a COM object
- check the registering or register a COM object
- use it in a C++ software (getting the interface and initializing).
I've tried to do this, using the samples found in the MSDN package, but without success.
Many Thanks
|
|
|
|
|
Have you tried to manually register the components with regsvr32? What was the response?
|
|
|
|
|
Hi all,
Please, can I find somebody to help me in this problem, I'm using a custom made ATL component, I have the .h and .c, and I have put some create instance statments in my COM Client, but always I face this compile error on each create instance command :
error C2259: 'CMyClass' : cannot instantiate abstract class due to following members:
warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined
Anybody can help in this problem?
Yours,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
What does your CreateInstance code look like?
The error is saying that your class hasn't implemented the IUnknown methods, QueryInterface, AddRef etc. However if you are trying to create a instance this shouldn't be happening as your COM DLL should have the implementation.
Are you using smart pointers, #import or using CoCreateInstance?
Michael
|
|
|
|
|
Hi,
First thank you for your reply.
Actually I'm using a ready made component which I don't know anything about how does it implemented, but I have the component.h and component_i.c files, and I'm linking to the component using these two files and the ofcourse the .DLL itself. No #import, no smart pointers, just CoCreateInstance which directly creates the required interfaces, and on those CoCreateInstance statement I have this error.
Regards,
ShadiK.
Shadi Al-Kahwaji
|
|
|
|
|
I need to see the CoCreateInstance code fragment to help more. It seems like you are trying to create the c++ class instead of the interface.
Michael
|
|
|
|
|
Can you post some of the problematic code? Usually that error happens when you try to use use new to create an ATL class, which is the wrong way to do it, but you said you're using CreateInstance.
Does the class have a BEGIN_COM_MAP()/END_COM_MAP() section?
--Mike--
http://home.inreach.com/mdunn/
your with and
|
|
|
|
|
Sound similar to an error I have made when initially typing code.
Many times I do not declare the pointer to the COM object as a pointer and it gives the error you state.
THis is correct:
IXMLDOMDocument *pXML = NULL;
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr...
ASSERT(SUCCEEDED(hr) && pXML!=NULL);
This is not:
IXMLDOMDocument pXML = NULL; << this line produces the error not the next!
hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&pXML); // Check the return value, hr...
ASSERT(SUCCEEDED(hr) && pXML!=NULL);
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|
Thank you sir.
And I would like to thank everybody tried to help me. The problem is that I was trying to use the COM component as a smart pointers, but there were not.
Thank you all again.
Shadi Al-Kahwaji
|
|
|
|
|
[client]->[com]->[DLL] function calls
[DLL]->[com] window message
[com]->[client] function retvals and events
I have a com object where i load a DLL,
i want to recive windows message to the com from the dll
is that possible?
Christer
|
|
|
|
|
wasn't my answer adequate enough?
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
Sorry im new to this side so i could`t find the page.
Christer
|
|
|
|
|
Has anyone here ever seen this error.
"fatal error C1084: Cannot read type library file: 'TLBs\astm.tlb': Error loading type library/DLL."
I really have no idea what is going on. I get that when doing a regual #import statement. We designed the TLB. The tlb file was just compiled with no errors. It isn't a sharing violation since i made a complete copy of the file just for use in this application. The TLB file comes from a ATL/COM project. If anyone has seen this and knows whats going on please help. I have tried everything i can think of. There doesn't seem to be much of anything on the internet about it and there is NOTHING of MSDN about it.
Any help is greatly appreciated.
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
|
|
|
|
|
try by importing it from your com dll or exe modules, as these also contain the type library ?
i.e. #import "astm.dll"
|
|
|
|
|
I already have the IDispatch pointer of an ActiveX control. Can someone tell me how to get the following information from my code?
1. The type of a property, given the dispid of the property.
2. The type of the return value and the types of parameters of a method, given the dispid of the method .
I need specific information/suggestion, instead of book names or URLs. Thanks.
|
|
|
|
|
You can get just about any sort of information you could possibly want about a dispatch interface through its ITypeInfo interface. Call IDispatch::GetTypeInfoCount to verify that the object supports the ITypeInfo interface (1 if it does, 0 otherwise), then call IDispatch::GetTypeInfo to get the ITypeInfo interface. Take a look at ITypeInfo::GetFuncDesc to get info about the parameters and return type of a function member of an IDispatch interface (given its id), and ITypeInfo::GetVarDesc to get info about a variable member of an IDispatch interface, including its type (given its id).
|
|
|
|