SnapCrakllPop
September 29th, 2008, 12:54 PM
I was admitted about a week ago into the Help Desk at the high school I go to. The Tech Admin asked me to write him a function that will simply mute system sound from the command line. Basically he wants to be able to go into the command prompt and run my program, which will accept the arguments "mute" and "unmute."
Here's what I have. It's currently set up simply to take the argument and decide whether it says "mute" or "unmute." It was simply for testing purposes, since I haven't messed around with command line arguments in a while.
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
char mute[] = "mute";
char unmute[] = "unmute";
if(argc == 0)
{
/* check for mute/unmute and change. This is to accept no arguments. */
}
else
{
if(strcmp(unmute, argv[1]) != 0)
{
cout << "Requested operation: unmute\n";
cout << "argv[1] reads: " << argv[1];
}
else if(strcmp(mute, argv[1]) != 0)
{
cout << "Requested operation: mute\n";
cout << "argv[1] reads: " << argv[1];
}
else
cout << "ERROR";
}
return(0);
}
I've been googling and searching forums for quite a while and have came up empty-handed as to how to control the volume. Can anyone help me figure out how to mute/unmute system sound?
Thanks,
Richard
PS I've attached the .cpp file in case anyone wants to mess around with it :)
EDIT(2:05 EST, Sept 29, 2008): Meant to put this in the C++ Programming category, since I'm not sure if this DOES involve the WinAPI. Sorry.
Here's what I have. It's currently set up simply to take the argument and decide whether it says "mute" or "unmute." It was simply for testing purposes, since I haven't messed around with command line arguments in a while.
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
char mute[] = "mute";
char unmute[] = "unmute";
if(argc == 0)
{
/* check for mute/unmute and change. This is to accept no arguments. */
}
else
{
if(strcmp(unmute, argv[1]) != 0)
{
cout << "Requested operation: unmute\n";
cout << "argv[1] reads: " << argv[1];
}
else if(strcmp(mute, argv[1]) != 0)
{
cout << "Requested operation: mute\n";
cout << "argv[1] reads: " << argv[1];
}
else
cout << "ERROR";
}
return(0);
}
I've been googling and searching forums for quite a while and have came up empty-handed as to how to control the volume. Can anyone help me figure out how to mute/unmute system sound?
Thanks,
Richard
PS I've attached the .cpp file in case anyone wants to mess around with it :)
EDIT(2:05 EST, Sept 29, 2008): Meant to put this in the C++ Programming category, since I'm not sure if this DOES involve the WinAPI. Sorry.