Solved

16 Bit (Delphi 1) Sound Code

Posted on 1998-09-06
6
167 Views
Last Modified: 2010-04-06
I am looking for a method to play a wave on a button click and to include the wave in my program resources so I don't have to distribute it separately.  SndPlaySnd is Win32 bit so it does not work for my application.  It must be available in Delphi 1 as my client program must be 16bit.  Can anyone tell me how to play sound in Delphi 1?
0
Comment
Question by:DMM1956
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:duke_n
ID: 1338804
I don;t know anynthing special,
but you can use TMediaPlayer from 'System' page of VCL
and make it unvisible.
0
 
LVL 1

Expert Comment

by:duke_n
ID: 1338805
Or jus use the fabulous
Beep()
function......
0
 

Author Comment

by:DMM1956
ID: 1338806
Not what I want.  I have seen 16 bit programs that do it and I want to add it to my programs.  Finding difference between Delphi 1 and 2 can be quite puzzling.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
EmmDieh earned 50 total points
ID: 1338807
No, you are wrong: SndPlaySound is part of mmsystem.dll

I use(d) the following to play a sound from a resource:
var
  WavData: THandle;  { Handle auf Resource }
procedure StopMemWav;
begin
  UnlockResource(WavData);
  FreeResource(WavData);
end;
procedure PlayMemWav(ResName: PChar);
var
  ResInfo: THandle;
  P: PChar;
begin
    { Resource finden }
  ResInfo := FindResource(hInstance, ResName, RT_RCDATA);
  If ResInfo = 0 then Exit;  { Resource konnte nicht gefunden werden }
    { Resource in den Speicher laden }
  WavData := LoadResource(hInstance, ResInfo);
  If WavData = 0 then Exit;  { Resource konnte nicht geladen werden }
    { Resource sperren und Zeiger auf Wavedaten holen }
  P := LockResource(WavData);
    { Sound spielen }
      { Sound synchron spielen }
      { gerade gespielten Sound nicht unterbrechen }
      { P zeigt auf den Speicher und nicht auf den Filenamen }
  sndPlaySound(P, snd_Sync or snd_NoStop or snd_Memory);
  StopMemWav;
end;  { PlayMemWav }

0
 
LVL 2

Expert Comment

by:kjteng
ID: 1338808
0
 

Author Comment

by:DMM1956
ID: 1338809
Uh...thanks for the correction.  I never realised there was such a unit with Delphi 1.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question