Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

Beep In The PC Speaker

Generate a beep in the PC speaker using C# and an unmanaged call to the Beep() function that is part of the Windows kernel.

On Thursday, April 24th 2008 at 01:03 AM
By Andrew Pociu (View Profile)
****-   (Rated 4 with 5 votes)
Contextual Ads
More C# Resources
Advertisement
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Windows.Forms;
  6. using System.Runtime.InteropServices;
  7.  
  8. namespace Sample
  9. {
  10.     public partial class Form1 : Form
  11.     {
  12.         public Form1()
  13.         {
  14.             InitializeComponent();
  15.         }
  16.  
  17.         [DllImport("kernel32.dll")]
  18.         public static extern bool Beep(int BeepFreq, int BeepDuration);
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             Beep(500, 100);
  23.         }
  24.     }
  25. }
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
by UTB on Wednesday, July 9th 2008 at 07:53 AM

Or you just do..
System.Console.Beep();

by james on Wednesday, May 20th 2009 at 01:46 AM

Why did you reference the dll import kernel32.dll? Is it because it is playing a system generate sound? I am trying to create a mp3 player and I have little experience in c#. I have imported "winmm.dll" to play a user selected mp3 file from a domainupdown control that is opened via an OpenFileDialog control, is that the correct .dll import? Thanks in advance for any help!

by rhovel on Sunday, August 2nd 2009 at 10:23 AM

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace beep
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

i got error from the Application.Run.(new Form1());

this is the error message:

Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) C:\sandbox\beepinthepcspeaker\beep\beep\Program.cs 18 33 beep

by GenF20 Plus on Monday, December 19th 2011 at 05:25 PM

This is a great trick and I didn’t know you can use C# to obtain the info of your computer

by Human Growth Hormone on Monday, December 19th 2011 at 05:29 PM

This is a great trick and I didn’t know you can use C# to obtain the info of your computer

by Phen375 on Monday, December 19th 2011 at 05:34 PM

Does this trick work for Mac too?

by GenFX on Monday, December 19th 2011 at 05:36 PM

Does this trick work for Mac too?

by Teeth Whitening Reviews on Monday, December 19th 2011 at 05:42 PM

I needed to create you this tiny word so as to give thanks once again for your pleasant techniques you have provided on this site. This has been shockingly open-handed with people like you to supply openly what exactly a number of people would've offered for an e book to help make some profit for themselves, precisely now that you could possibly have done it in case you desired.

by Nuratrim on Monday, December 19th 2011 at 05:43 PM

I needed to create you this tiny word so as to give thanks once again for your pleasant techniques you have provided on this site. This has been shockingly open-handed with people like you to supply openly what exactly a number of people would've offered for an e book to help make some profit for themselves, precisely now that you could possibly have done it in case you desired.

by Ultimate Maqui Berry on Monday, December 19th 2011 at 05:47 PM

Those concepts additionally worked as a good way to recognize that other people have the same desire really like my own to see significantly more in regard to this issue. Certainly there are numerous more pleasurable opportunities up front for people who looked over your blog.

by Best Diet Pills on Monday, December 19th 2011 at 05:48 PM

Those concepts additionally worked as a good way to recognize that other people have the same desire really like my own to see significantly more in regard to this issue. Certainly there are numerous more pleasurable opportunities up front for people who looked over your blog.

by Dental White on Monday, December 19th 2011 at 05:50 PM

I have to express my thanks to the writer just for rescuing me from such a difficulty. Because of browsing through the online world and seeing views which were not helpful, I believed my life was done. Existing without the presence of solutions to the problems you've fixed as a result of your main write-up is a crucial case, and the kind which could have in a wrong way affected my entire career if I hadn't discovered your website.

by Pure Acai Berry Max on Monday, December 19th 2011 at 05:53 PM

I have to express my thanks to the writer just for rescuing me from such a difficulty. Because of browsing through the online world and seeing views which were not helpful, I believed my life was done. Existing without the presence of solutions to the problems you've fixed as a result of your main write-up is a crucial case, and the kind which could have in a wrong way affected my entire career if I hadn't discovered your website.

by Leon on Tuesday, January 24th 2012 at 05:54 AM

Once you have recreated the problem and captured these steps, you can save them to a file and send it to your support person, who can then open it up and view


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs C# Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Ads

From the creators of Geekpedia, a revolutionary new coupon website!

BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.

Coupons
Discover Geekpedia
Other Resources