Reputation: 371
I made beeps using
[DllImport("KERNEL32.DLL")]
extern public static void Beep(int freq, int dur);
// and
Beep(2222, 55);
Beep(3333, 55);
I have planted this code ( Beep( freq, dura) ) almost a hundread times here and there(with various frequency, duration and times).
Now, I want to switch between Sound and Mute programtically.
I could do it with something like
if ( my_Flag )
{
Beep( 2222, 55);
Beep( 3333, 55);
}
It should be tedious work to do. Is there any better ideas ?
Thanks.
Upvotes: 1
Views: 63
Reputation: 4381
If everything is defined as Beep(x,y)
method, You can write Your own method and then Refactor->Rename all methods to MyBeep(x,y)
for example.
public void MyBeep(int freq, int dur)
{
if(myFlag)
Beep(freq, dur);
}
Upvotes: 4