Groups > Microsoft > Microsoft Speech Tech SDK > Re: Using Speech in DLL




Using Speech in DLL

Using Speech in DLL
Thu, 6 Mar 2008 17:49:01 -0800
Can I use the Speech SDK 5.1 in a DLL rather than in a main application? This 
will enable me to centralize the voice I/O in a multi-application system that 
all share a common DLL.

The following line locks-up:
hr = cpRecoEngine.CoCreateInstance(CLSID_SpInprocRecognizer);
Post Reply
Re: Using Speech in DLL
Fri, 7 Mar 2008 01:40:22 -0500
"Bruce K." <Bruce K.@discussions.microsoft.com> wrote in message

news:35676407-DE20-475D-8045-4E97A739391F@microsoft.com...
> Can I use the Speech SDK 5.1 in a DLL rather than in a main application?

Of course.

> The following line locks-up:
> hr = cpRecoEngine.CoCreateInstance(CLSID_SpInprocRecognizer);

I can't say that I know what your problem is. I am sure, however, that there 
has to be more to it than the fact that your code is implemented in a DLL. 
Did you make sure to initialize COM first?

Regards,
Will


Post Reply
Re: Using Speech in DLL
Fri, 7 Mar 2008 08:19:06 -0800
Hello Will:

Yes, CoInitialize(NULL) is being called.  Much of the SAPI code being used 
is from a working and simple MFC Dialog sample application. Hence why I'm 
concerned about the DLL. After CoInitialize(NULL) is called, with no retrun 
error, I call CoCreateInstance where it locks.  Not much code to go wrong 
with.

I’ve found out the hard way on many occasions that certain Windows 
programmed elements can not be used in a DLL or must occur only after the 
calling application is fully loaded and window is displayed. By the way, the 
DLL is in MFC.

Thanks.  Bruce K.


"William DePalo [MVP VC++]" wrote:

> "Bruce K." <Bruce K.@discussions.microsoft.com> wrote in
message 
> news:35676407-DE20-475D-8045-4E97A739391F@microsoft.com...
> > Can I use the Speech SDK 5.1 in a DLL rather than in a main
application?
> 
> Of course.
> 
> > The following line locks-up:
> > hr = cpRecoEngine.CoCreateInstance(CLSID_SpInprocRecognizer);
> 
> I can't say that I know what your problem is. I am sure, however, that
there 
> has to be more to it than the fact that your code is implemented in a DLL.

> Did you make sure to initialize COM first?
> 
> Regards,
> Will
> 
> 
> 
Post Reply
Re: Using Speech in DLL
Fri, 7 Mar 2008 16:19:01 -0800
Will:

Problem solved.  CoInitialize(NULL) can not be called in DLLMain().  My 
latest problem is getting an exception in ATLBASE.H  line  p->Release();  
when the DLL is closing.

~CComPtr()
	{
	if (p)
	     p->Release();
	}


"Bruce K." wrote:

> Hello Will:
> 
> Yes, CoInitialize(NULL) is being called.  Much of the SAPI code being used

> is from a working and simple MFC Dialog sample application. Hence why I'm 
> concerned about the DLL. After CoInitialize(NULL) is called, with no retrun

> error, I call CoCreateInstance where it locks.  Not much code to go wrong 
> with.
> 
> I’ve found out the hard way on many occasions that certain Windows 
> programmed elements can not be used in a DLL or must occur only after the 
> calling application is fully loaded and window is displayed. By the way,
the 
> DLL is in MFC.
> 
> Thanks.  Bruce K.
> 
> 
> "William DePalo [MVP VC++]" wrote:
> 
> > "Bruce K." <Bruce K.@discussions.microsoft.com> wrote
in message 
> > news:35676407-DE20-475D-8045-4E97A739391F@microsoft.com...
> > > Can I use the Speech SDK 5.1 in a DLL rather than in a main
application?
> > 
> > Of course.
> > 
> > > The following line locks-up:
> > > hr = cpRecoEngine.CoCreateInstance(CLSID_SpInprocRecognizer);
> > 
> > I can't say that I know what your problem is. I am sure, however, that
there 
> > has to be more to it than the fact that your code is implemented in a
DLL. 
> > Did you make sure to initialize COM first?
> > 
> > Regards,
> > Will
> > 
> > 
> > 
Post Reply
Re: Using Speech in DLL
Fri, 7 Mar 2008 19:40:46 -0500
"Bruce K." <BruceK@discussions.microsoft.com> wrote in message 
news:154AC77A-01E0-40B3-BD47-EAA1ACFD3A86@microsoft.com...
> I've found out the hard way on many occasions that certain Windows
> programmed elements can not be used in a DLL or must occur only after the
> calling application is fully loaded and window is displayed.

The operating serializes calls to DllMain so you should never do anything 
that blocks there. The docs warn about this.

> By the way, the DLL is in MFC.

MFC is another kettle of fish entirely. It imposes it's own rules.

Regards,
Will

Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact