3

I want to use the Windows SAPI COM object to make a sound during installation. I know that in VBScript they do it like this:

Set oVoice = CreateObject("SAPI.SpVoice")
set oSpFileStream = CreateObject("SAPI.SpFileStream")
oSpFileStream.Open "xxx.wav"
oVoice.SpeakStream oSpFileStream
oSpFileStream.Close

I asked, how to do this in an Inno Setup script. I'm pretty new to Inno Setup, and still have not learned how to use the CreateOleObject function and so on. I tried to understand the Inno Setup documentation and it did not help me. Other answers about using COM objects also did not make me understand this. Thanks for your help

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
yonni
  • 248
  • 2
  • 11

1 Answers1

3

Use CreateOleObject support function:

var
  oVoice, oSpFileStream: Variant;
begin
  oVoice := CreateOleObject('SAPI.SpVoice');
  oSpFileStream := CreateOleObject('SAPI.SpFileStream');
  oSpFileStream.Open('xxx.wav');
  oVoice.SpeakStream(oSpFileStream);
end;

See Pascal Scripting: Using COM Automation objects.


For alternate solution, see Playing sound during an Inno Setup install.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    Thanks. I did try to work this way, but unlike VBScript where the code is `oSpFileStream.Open "xxx.wav"` with _space_, I had to do it with _parentheses_: `oSpFileStream.Open ('xxx.wav')` That's what complicated me. – yonni Feb 23 '22 at 11:21