[fpc-pascal] Exception when trying to set a COM object property through OleVariant

Lubos Pintes lubos.pintes at gmail.com
Fri Jun 26 10:21:09 CEST 2015


Hello,
I am using FPC 3.1.1.
I am playing with SAPI5. It almost works, but I am unable to set a Voice 
of SPVoice object through OleVariant.
The following program works fine in Delphi 6, but an exception on line 
12 is raised when compiled by FPC:

program sapi;

uses
   ActiveX, ComObj;

var
   SPVoice: OleVariant;

begin
   CoInitializeEx(nil, 0);
   SPVoice := CreateOleObject('SAPI.SPVoice');
   SPVoice.Voice := SPVoice.GetVoices.Item(5);
   SPVoice.Speak('Hello from SAPI5.', 0);
end.




More information about the fpc-pascal mailing list