Solved

Control Master Volume From App..

Posted on 1998-08-18
8
374 Views
Last Modified: 2012-08-13
How can I control the system volume from within my app using API? I found sample code for controlling the wav volumes, but I would like to control ALL output. The master volume I guess it could be called...

Thanks

Gary
0
Comment
Question by:garymace
  • 4
  • 2
  • 2
8 Comments
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429751
Well, I really do not want points for this, but Dr. GUI had an answer a while ago. I think copying the text here would not be legal, but it should be available online... Lemme see... Oops, MS's MSDN site is incompatible with ie3...  Nah, can't find it. It was in MSDN news (the big newsletter coming with a MSDN subscription) March/april 1998 (Vol. 7 Number 2), page 3, bottom of 1st column. You got access to that? The article mentions "There is no simple API", the function names "mixerGetNumDevs", "mixerGetLineInfo", "mixerGetLineControls" and "mixerGetControlDetails", and bugs in win32api.txt...

Have fun!
0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429752
0
 

Author Comment

by:garymace
ID: 1429753
No, I do not have access to MSDN. Thanks anyway..

Gary

0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429754
Didn't they offer MSDN online free? Might be worth a try. On the other hand, the 'premium' in the URL above might exclude you again... In any case, that article did not offer a complete solution anyway, so you'd search the MSDN library for those keywords I gave. The MSDN library is a must anyway.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Accepted Solution

by:
nilos earned 20 total points
ID: 1429755
Dr. GUI is gratified that you're concerned for your users' hearing. It speaks volumes for your intelligence and compassion. There are few things more annoying than an application that's just too noisy. It's almost as bad as stealing focus from the foreground application.

Unfortunately, there is no simple API call to get or set the volume. It requires iterating through four layers of functions and structures to get or set the system volume.

First, call mixerGetNumDevs to locate the correct mixer device. Next, call mixerGetLineInfo to determine which line of the device controls the volume to the speakers. Then, call mixerGetLineControls to determine which control on that line lets you change the volume. Finally, call mixerGetControlDetails to obtain the structure containing the volume setting.

To actually change the volume you must work around Visual Basic's limited ability to handle pointers. (Or you could write a COM object in Visual C++ to do this.) The availability of the VarPtr() function in Visual Basic 5.0 smooths the way considerably. Note that you'll have to declare some of the structures and functions yourself because of bugs in the WIN32API.TXT file that shipped with Visual Basic.

By the way, it would probably be a good idea to put the volume back when your application exits—changing it permanently for the user is kinda rude.


0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429756
That's the text I meant. Just I do not republish copyrighted information...
0
 
LVL 1

Expert Comment

by:nilos
ID: 1429757
I was concerned about to publish copyrighted info but, in this case I did not break any copyright law because:

a) Dr. Guy is a public information
b) I do not publish his text pretending it was mine
c) This place is not a public, in the strict sense, place

d) garymace needs this information to do a better usage of a Microsoft product.

Based on that I don't think that Microsoft will sue me.





0
 

Author Comment

by:garymace
ID: 1429758
Thank you nilos for the post.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now