Article View: borland.public.cppbuilder.nativeapi
Article #1099Re: SAPI Failure under Vista - Help!
From: Remy Lebeau (TeamB)
Date: Mon, 22 Oct 2007 16:33
Date: Mon, 22 Oct 2007 16:33
42 lines
2213 bytes
2213 bytes
"JohnC" <jcibulskis@sbcglobal.net> wrote in message
news:471a1686@newsgroups.borland.com...
> For the sake of this example, I've replaced the use of "Words"
> in the call to Speak() by a fixed string, just to avoid any
> discussion about how I'm converting the String to a BSTR.
Using the 'L' prefix on a string literal does not create a BSTR. You must
use one of the SysAllocString...() functions for that, ie:
BSTR bstrWords = SysAllocString(L"Hello World");
if(bstrWords)
{
pVoice->Speak(bstrWords, SPF_DEFAULT, NULL);
SysFreeString(bstrWords);
}
Since you are already using the VCL, I suggest you use the WideString class
to manage the BSTR for you:
void TJMCSpeech::Speak(String Words)
{
if(SUCCEEDED(hr))
pVoice->Speak(WideString(Words), SPF_DEFAULT, NULL);
}
Or:
void TJMCSpeech::Speak(WideString Words)
{
if(SUCCEEDED(hr))
pVoice->Speak(Words, SPF_DEFAULT, NULL);
}
> However, when I run it under Vista I get a floating point divide
> by zero when Speak() is called.
That is likely due to you not passing a true BSTR to begin with.
Gambit
Technical Details
Message-ID:
<471cd115$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<471a1686@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6c3b668ca80ad7d9 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <471a1686@newsgroups.borland.com> Subject: Re: SAPI Failure under Vista - Help! Date: Mon, 22 Oct 2007 09:33:43 -0700 Lines: 44 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 207.178.157.90 Message-ID: <471cd115$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1193070869 207.178.157.90 (22 Oct 2007 09:34:29 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail