[fpc-pascal]Yet another bug in Win32 CRT unit

Marco van de Voort marcov at stack.nl
Thu Mar 7 12:14:19 CET 2002

> Jonas Maebe wrote:
> > From a win32 program, it's not possible to
> > write directly to the PC speaker ports like under Dos, so you either have
> > to use win32 api calls (and it seems there aren't any which allow you to
> > specify the tone/duration), or you have to write a VxD (since that one
> > runs with kernel privileges and as such it should be able to access the
> > hardware directly which in) which in turn can be called from FPC programs.
> Yikes, now I understand the problem.
> Here's an idea: How about code that would generate a waveform "on the
> fly" (in this case, a square wave would do) and then play it through
> the Windows API (as if it were a WAV file)?  Or maybe a (very short)
> MIDI sequence through the MIDI device?  I know these are through the
> Windows sound system, not the PC speaker, but at least ported apps
> would sound about like they were supposed to.

That is dangerous, since it could disrupt already running audio using apps.
(the beep would simply be not audible, or other porgs might even crash.)

Don't forget that non-Dos oses are often multitasking!

It could be done like that if needed for special purposes, but it isn't fit
as a general solution for the above reasons.

More information about the fpc-pascal mailing list