Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to turn on/off  the pc speaker in W2K?

Posted on 2002-06-23
7
Medium Priority
?
348 Views
Last Modified: 2010-04-04
Hi all,
This codes work fine with win98, but can't work with Win2000, How to change it? (Please don't just tell me a component, I need the source)


 if BeepOn then        //BeepOn is a logic flag
 begin
 asm
   mov al,3            //turn on the pc speaker
   out $61,al
   mov al,$0B6
   out $43,al
   mov al,200
   out $42,al
   mov al,20
   out $42,al
 end;
 end
 else
 begin
 asm
  mov al,0            //turn off the pc speaker
  out $61,al
 end;
 end;
0
Comment
Question by:xbbin
[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
7 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7101585
hello

  I think you can't do that with win2000/xp, cuz it's not allowed you to direct access the hardware

the code which using assemply with ports, doesn't work in any version based on NT, i'm not sure with that also with the PC speaker, but i think it's the same cuz u r using assembly code to access the hardware
0
 

Author Comment

by:xbbin
ID: 7101682
Hi,
I just want to turn on/off the pc speaker, How to do that without assembly code?
0
 
LVL 2

Expert Comment

by:Tasomia
ID: 7101693
Try this:

// Disable Enable:
procedure TForm1.Button1Click(Sender: TObject);
begin
  SystemParametersInfo(SPI_SETBEEP,0,NIL,SPIF_SENDWININICHANGE);
end;


// Enable Beep:
procedure TForm1.Button2Click(Sender: TObject);
begin
  SystemParametersInfo(SPI_SETBEEP,1,NIL,SPIF_SENDWININICHANGE);
end;
 
tas
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:xbbin
ID: 7101706
Hi Tasomia,
Not have any sound at all.
0
 
LVL 2

Accepted Solution

by:
freshman3k earned 200 total points
ID: 7101927
Hello!

1)Download the following component:
http://www.torry.net/vcl/system/portaccess/smport.zip

2)Install the component

3)Place the component on the form

4)Put the following code in the formshow event:
SmallPort->OpenDriver;

5)Put the following code in the formclose event:
SmallPort->CloseDriver;

6)Use the following code to turn the pc speaker off:
SmallPort->SpeakerOff;

7)Use the following code to enable the pc and beep the speaker with a specified tone:
SmallPort->SpeakerOn(Tone);

8)Use the following code to enable the pc and beep the speaker with a specified Freq and delay:
SmallPort->Sound(Freq,Delay);

And This will work in all versions of windows.

>Please don't just tell me a component, I need the source

There is no way to accomplish that you want in winnt/win2k/winxp with just using assembly and not using drivers.

This component is free and includes sources for the drivers and the component.  

Good Luck! :-)
0
 

Author Comment

by:xbbin
ID: 7114073
Hi freshman,
Why can't install it on Delphi3? The compiler say: SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START and SERVICE_ERROR_NORMAL are undeclared identifier.

(Should I need to declared some unit on the "use" section??)

Delphi4 not have this problem.

Regards, bin
0
 
LVL 2

Expert Comment

by:freshman3k
ID: 7114901
Hello bin,

Try Putting 'WinSvc.pas' unit in the implementation's uses
 

0

Featured Post

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

730 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