|
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).
|
|
|
|
|
Thanks. But which field of the returned structures (FUNCDESC, VARDESC, ELEMDESC, PARAMDESC, etc.) is the type?
|
|
|
|
|
Well, properties are actually function calls in dispatch interfaces. Variables would be things like the symbolic constants of an enum declaration. It's a little bit messy, but once you've got the ITypeInfo for an interface, you can iterate through the functions of the interface like this:
// First off, get the type attributes
TYPEATTR* pTypeAttr = NULL;
FUNCDESC* pFuncDesc = NULL;
pTypeInfo->GetTypeAttr(&pTypeAttr); // Should be dispatch
// Now you can iterate the functions in the interface
for(int j=0; j < pTypeAttr->cFuncs; j++)
{
pTypeInfo->GetFuncDesc(j, &pFuncDesc);
printf("\ncParams = %i", pFuncDesc->cParams);
printf("\ncParamsOpt = %i", pFuncDesc->cParamsOpt);
// The type of function invokation
switch(pFuncDesc->invkind)
{
// A "normal" function
case INVOKE_FUNC: printf("\ninvkind = INVOKE_FUNC"); break;
// A property
case INVOKE_PROPERTYGET: printf("\ninvkind = INVOKE_PROPERTYGET"); break;
case INVOKE_PROPERTYPUT: printf("\ninvkind = INVOKE_PROPERTYPUT"); break;
case INVOKE_PROPERTYPUTREF: printf("\ninvkind = INVOKE_PROPERTYPUTREF"); break;
}
// The return type of the function
switch(pFuncDesc->elemdescFunc.tdesc.vt)
{
case VT_EMPTY: printf("\nelemdescFunc.tdesc.vt = VT_EMPTY // Not specified."); break;
case VT_NULL: printf("\nelemdescFunc.tdesc.vt = VT_NULL // SQL-style Null."); break;
case VT_I2: printf("\nelemdescFunc.tdesc.vt = VT_I2 // 2-byte signed int."); break;
case VT_I4: printf("\nelemdescFunc.tdesc.vt = VT_I4 // 4-byte-signed int."); break;
case VT_R4: printf("\nelemdescFunc.tdesc.vt = VT_R4 // 4-byte real."); break;
case VT_R8: printf("\nelemdescFunc.tdesc.vt = VT_R8 // 8-byte real."); break;
<etc...>
}
// Parameter types of a function
// Parameter type of a function
k = 0;
while(k < pFuncDesc->cParams)
{
vt = (VARENUM)pFuncDesc->lprgelemdescParam[k].tdesc.vt;
k++;
}
pTypeInfo->ReleaseFuncDesc(pFuncDesc);
}
pTypeInfo->ReleaseTypeAttr(pTypeAttr);
The "return type" will be the type of the property in question. The FUNCDESC will contain a memid, use this to identify the function/property in question as it is defined in the interface. More than one function may map to a given memid, for instance, a propertyput and a propertyget would map to a single property on an interface, bu will nevertheless show up twice when iterating the functions through the ITypeInfo interface. If all you want is the type of each property, you could create a map<long, varenum=""> and fill it up while traversing the functions of the interface. Then, later:
long memid;
VARENUM vt = return_types[memid];
Or something similar. Unfortunately, the type info mechanism doesn't give you a way to get info for a given member id, so you have to iterate through all of them for a given interface and make your own map. The array FUNCDESC::lprgelemdescParam should have the parameter types accepted by the function.
|
|
|
|
|
|
I try to use gdi+ lib in my atl projects. but when i did it, i found that the function gdiplusshutdown is always failed when i want to exit the program. how can i do it?
|
|
|
|
|
hello gurus,
How do i set the homepage in IE? i would also like to display my own error pages and expedite search. Is this possible? Pl. send me any useful links to articles etc. I'm using VC.
TIA.
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
Well setting the default homepage is simple enough. I just add the relevant registry entries.But what about displaying custom error pages? Do I actually have to write a psuedo proxy of somesort?
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|