Harbour OLE bug

423 views
Skip to first unread message

Antonio Linares

unread,
Jan 27, 2024, 8:55:18 AMJan 27
to Harbour Developers
function Main()

local oVoice := TOleAuto():New( "Sapi.SPVoice" )

oVoice:Voice = oVoice:GetVoices():Item( 1 )   // here
oVoice:Speak( "hello" )

return nil

We have unsuccessfully tried to fix it

Any help is welcome

Antonio Linares

unread,
Jan 27, 2024, 8:56:55 AMJan 27
to Harbour Developers
   Error description: (DOS Error -2147352573) WINOLE/1006  Argument error: _VOICE
   Args:
     [   1] = O   TOLEAUTO

Enrico Maria Giordano

unread,
Jan 27, 2024, 8:59:27 AMJan 27
to harbou...@googlegroups.com
Works fine with xHarbour. Maybe we can compare the relevant code?

--
Enrico Maria Giordano

http://www.emagsoftware.it
http://www.emagsoftware.it/emgmusic
http://www.emagsoftware.it/spectrum
http://www.emagsoftware.it/tbosg

José M. C. Quintas

unread,
Jan 27, 2024, 4:24:04 PMJan 27
to harbou...@googlegroups.com

TOleAuto() is a xharbour compatibility function.

Use win_OleCreateObject()


José M. C. Quintas

--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/be81c513-f0c0-437a-9dc9-1c2fb065d3d7n%40googlegroups.com.

Enrico Maria Giordano

unread,
Jan 27, 2024, 5:24:33 PMJan 27
to harbou...@googlegroups.com


Il 27/01/2024 22:18, José M. C. Quintas ha scritto:

> TOleAuto() is a xharbour compatibility function.
>
> Use win_OleCreateObject()

function Main()

local oVoice := win_OleCreateObject( "Sapi.SPVoice" )

oVoice:Voice = oVoice:GetVoices():Item( 1 ) // here
oVoice:Speak( "hello" )

return nil

Same error.

Antonio Linares

unread,
Jan 28, 2024, 1:09:12 AMJan 28
to Harbour Developers
Fixed. Thanks Enrico for your great feedback,

In harbour/contrib/hbwin/olecore.c

HB_FUNC( WIN_OLEAUTO___ONERROR )
...
         if ((HB_ISBYREF(1)) || HB_ISARRAY(1))
             lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_( pDisp ) dispid, HB_ID_REF( IID_NULL ),
                                                   LOCALE_USER_DEFAULT,
                                                   DISPATCH_PROPERTYPUTREF, &dispparam,
                                                   NULL, &excep, &uiArgErr );
         else
             lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_(pDisp) dispid, HB_ID_REF( IID_NULL ),
                                                   LOCALE_USER_DEFAULT,
                                                   DISPATCH_PROPERTYPUT, &dispparam,
                                                   NULL, &excep, &uiArgErr);

oVoice:Voice = oVoice:GetVoices():Item( 1 ) is working fine now.

Antonio Linares

unread,
Jan 28, 2024, 5:23:25 AMJan 28
to Harbour Developers
This is a simpler and more correct fix. Thanks to Bruno Cantero for his kind explanations:

         lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_(pDisp) dispid, HB_ID_REF(IID_NULL),
                                               LOCALE_USER_DEFAULT,
                                               ( V_VT( dispparam.rgvarg ) == VT_DISPATCH ) ? DISPATCH_PROPERTYPUTREF : DISPATCH_PROPERTYPUT,
                                               &dispparam, NULL, &excep, &uiArgErr );

Bernard Mouille

unread,
Jan 28, 2024, 5:49:28 AMJan 28
to Harbour Developers
Not works with :
Harbour version     : Harbour 3.2.0dev (r2307062207)
Compileur C version : MinGW GNU C 7.3 (32-bit)
Windows version     : Microsoft Windows 10 Famille 64 bits build 19045
Regards,
Bernard.

Antonio Linares

unread,
Jan 28, 2024, 6:10:59 AMJan 28
to Harbour Developers
we have used Visual Studio Community 2022 and it works fine

Antonio Linares

unread,
Jan 28, 2024, 6:14:15 AMJan 28
to Harbour Developers
Dear Bernard,

Please try it this way:

         lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_(pDisp) dispid, HB_ID_REF(IID_NULL),
                                               LOCALE_USER_DEFAULT,
                                               ( V_VT( &dispparam.rgvarg[ 0 ] ) == VT_DISPATCH) ? DISPATCH_PROPERTYPUTREF : DISPATCH_PROPERTYPUT,

                                               &dispparam, NULL, &excep, &uiArgErr );

Itamar M. Lins Jr. Lins

unread,
Jan 28, 2024, 6:21:41 AMJan 28
to harbou...@googlegroups.com
Hi!
>Not works with :
>Harbour version     : Harbour 3.2.0dev (r2307062207)
Waiting commit this fix on Harbour Git. /contrib/hbwin

Best regards,
Itamar M. Lins Jr.

--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.

Enrico Maria Giordano

unread,
Jan 28, 2024, 6:35:21 AMJan 28
to harbou...@googlegroups.com


Il 28/01/2024 12:21, Itamar M. Lins Jr. Lins ha scritto:

> Waiting commit this fix on Harbour Git. /contrib/hbwin

Did you test the last proposed code by Antonio?

lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_(pDisp) dispid,
HB_ID_REF(IID_NULL),
LOCALE_USER_DEFAULT,
( V_VT(
&dispparam.rgvarg[ 0 ] ) == VT_DISPATCH) ? DISPATCH_PROPERTYPUTREF :
DISPATCH_PROPERTYPUT,
&dispparam, NULL,
&excep, &uiArgErr );

Please test it and let us know if it is working fine for you.

Antonio Linares

unread,
Jan 30, 2024, 5:20:58 PMJan 30
to Harbour Developers
It seems as there is another possible OLE bug here:

Tracing  __axRegisterHandler() it seems to work fine but the events don't arrive


function Main()

   local oVoice := TOleAuto():New( "Sapi.SPVoice" )

   oVoice:__hSink := __axRegisterHandler( oVoice:__hObj, { | ... | alert( ... ) } )

   oVoice:Voice = oVoice:GetVoices():Item( 1 )
   oVoice:Speak( "The Harbour project" )

return nil

Antonio Linares

unread,
Feb 1, 2024, 1:46:22 AMFeb 1
to Harbour Developers
__axRegisterHandler() is working nicely

It seems as something else is required to trigger the SPVoice events from high level, in example:

function main()

local oVoice := CreateObject( "Sapi.SPVoice", "WithEvents" ) // I have not checked if the second parameter is taken into account

// oVoice:WithEvents = .T.
oVoice:EventInterests = 327679
oVoice:__hSink := __axRegisterHandler( oVoice:__hObj, { | ... | QOut( ... ) } )
oVoice:Speak( "harbour and xharbour" )

return nil

Antonio Linares

unread,
Feb 11, 2024, 4:46:09 AMFeb 11
to Harbour Developers
Solved mistery: a window/dialog is required to be in use for the events to arrive!

They are working fine now!

Enrico Maria Giordano

unread,
Feb 11, 2024, 5:07:29 AMFeb 11
to harbou...@googlegroups.com


Il 11/02/2024 10:46, Antonio Linares ha scritto:

> Solved mistery: a window/dialog is required to be in use for the events
> to arrive!
>
> They are working fine now!

Yes, this is true for some other functions, if I remember correctly.

Antonio Linares

unread,
Feb 11, 2024, 5:36:38 AMFeb 11
to Harbour Developers
My mistake again...

The real difference is to speak in ASYNC mode!

oVoice:Speak( "harbour and xharbour", 1 )

That 1 makes the difference so the events arrive to __axRegisterHandler()

solved mistery finally :-)

Enrico Maria Giordano

unread,
Feb 11, 2024, 6:00:23 AMFeb 11
to harbou...@googlegroups.com


Il 11/02/2024 11:36, Antonio Linares ha scritto:

> My mistake again...
>
> The real difference is to speak in ASYNC mode!
>
> oVoice:Speak( "harbour and xharbour", 1 )
>
> That 1 makes the difference so the events arrive to __axRegisterHandler()

Great! Can I see a working sample, please?

José M. C. Quintas

unread,
Feb 11, 2024, 9:53:18 AMFeb 11
to harbou...@googlegroups.com
Several years ago I get a better result using multithread and gtwvg.

Seems there exists a time limit for pending play.

FUNCTION PlayText( cText )

   LOCAL oTalk

   IF ! AppIsPlayText() .OR. Empty( cText )
      RETURN NIL
   ENDIF
   hb_gtReload( "WVG" )
   oTalk := win_OleCreateObject( "SAPI.SPVoice" )
   oTalk:Speak( cText ) // , SVSFDefault
   oTalk:WaitUntilDone( 1 )

   RETURN NIL

carloskds

unread,
Feb 23, 2024, 1:05:49 PMFeb 23
to Harbour Developers
please can you share

AppIsPlayText function

thank you!

Reply all
Reply to author
Forward
0 new messages