•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 402,636 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,313 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
It's spring break, so let's beep in C# code, actually a 440 Hz A. We are just borrowing the Beep() function from the Windows kernel.
Last edited : Apr 1st, 2007.
// using InteropServices // the necessary WinApi functions are in kernel32.dll // in C# Handle = IntPtr DWORD = uint WORD = int // just a console program compiled with: // C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe using System; using System.Runtime.InteropServices; // DllImport() class Class1 { // WinApi Beep() is in kernel32.dll [DllImport("kernel32")] private static extern int Beep(int dwFreq, int dwDuration); static void Main(string[] args) { Console.WriteLine("It's spring time so let's beep!!!!\n\n"); int freq = 440; // hertz int duration = 2000; // milliseconds Console.WriteLine("Beeping at " + freq + " Hz for " + duration + " milliseconds"); Beep(freq, duration); } }
Comments (Newest First)
HLA91 | Junior Poster | Oct 13th, 2007
•
•
•
•
Awesome I modified it sent it to my friend and it said
"If your computer beeps it has a virus" and he went nuts I did tell him the truth (after half hour)
Cheers
HLA91
"If your computer beeps it has a virus" and he went nuts I did tell him the truth (after half hour)
Cheers
HLA91
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)