Hi All,
I am trying to call the waveOutGetVolume() function in winmm.dll from
my VS 2005 C# project using P/Invoke. I copied winmm.dll from
Windows\system32 directory into the root directory of my project. When
I run the solution, I get an error: Can't find PInvoke DLL 'winmm.dll'.
I have my code below. Could someone please help?
<code>
public partial class Form1 : Form
{
private class volAPI
{
[DllImport("winmm.dll" , EntryPoint = "waveOutGetVolume",
SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int waveOutGetVolume(IntPtr hwo, out
uint dwVolume);
[DllImport("winmm.dll", EntryPoint = "waveOutSetVolume",
SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int waveOutSetVolume(IntPtr hwo, uint
dwVolume);
}
public Form1()
{
InitializeComponent();
uint CurrVol = 0;
// At this point, CurrVol gets assigned the volume
volAPI.waveOutGetVolume(IntPtr.Zero, out CurrVol);
// Calculate the volume
ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
MessageBox.Show("Vol: " + CalcVol.ToString());
}
}
</code>
Regards,
Krupa 5 11225
As Mattias said you should not copy te dll from system32 to your application
directory.
What is the "exact" message you get when you call this function?
Note also that this function will fail with a null Handle for hwo! You have
to open a waveout device before you can call waveOutGetVolume or most other
Waveform function.
Willy.
<kr*****@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
| Hi All,
|
| I am trying to call the waveOutGetVolume() function in winmm.dll from
| my VS 2005 C# project using P/Invoke. I copied winmm.dll from
| Windows\system32 directory into the root directory of my project. When
| I run the solution, I get an error: Can't find PInvoke DLL 'winmm.dll'.
|
| I have my code below. Could someone please help?
|
| <code>
|
| public partial class Form1 : Form
| {
| private class volAPI
| {
| [DllImport("winmm.dll" , EntryPoint = "waveOutGetVolume",
| SetLastError = true, CharSet = CharSet.Unicode)]
| public static extern int waveOutGetVolume(IntPtr hwo, out
| uint dwVolume);
|
| [DllImport("winmm.dll", EntryPoint = "waveOutSetVolume",
| SetLastError = true, CharSet = CharSet.Unicode)]
| public static extern int waveOutSetVolume(IntPtr hwo, uint
| dwVolume);
| }
|
| public Form1()
| {
| InitializeComponent();
| uint CurrVol = 0;
| // At this point, CurrVol gets assigned the volume
| volAPI.waveOutGetVolume(IntPtr.Zero, out CurrVol);
| // Calculate the volume
| ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
| MessageBox.Show("Vol: " + CalcVol.ToString());
| }
| }
|
| </code>
| Regards,
| Krupa
|
Thanks Willy and Mattias for your replies.
I am debugging my application on a Win CE device. I get a
MissingMethodException on the device when I call this function. The
error reads:
Error
VOL_TEST.EXE
MissingMethodException
Can't find PInvoke DLL 'winmm.dll'
Any ideas?
-Krupa
Willy Denoyette [MVP] wrote: As Mattias said you should not copy te dll from system32 to your application directory. What is the "exact" message you get when you call this function? Note also that this function will fail with a null Handle for hwo! You have to open a waveout device before you can call waveOutGetVolume or most other Waveform function.
Willy.
<kr*****@gmail.com> wrote in message news:11**********************@v46g2000cwv.googlegr oups.com... | Hi All, | | I am trying to call the waveOutGetVolume() function in winmm.dll from | my VS 2005 C# project using P/Invoke. I copied winmm.dll from | Windows\system32 directory into the root directory of my project. When | I run the solution, I get an error: Can't find PInvoke DLL 'winmm.dll'. | | I have my code below. Could someone please help? | | <code> | | public partial class Form1 : Form | { | private class volAPI | { | [DllImport("winmm.dll" , EntryPoint = "waveOutGetVolume", | SetLastError = true, CharSet = CharSet.Unicode)] | public static extern int waveOutGetVolume(IntPtr hwo, out | uint dwVolume); | | [DllImport("winmm.dll", EntryPoint = "waveOutSetVolume", | SetLastError = true, CharSet = CharSet.Unicode)] | public static extern int waveOutSetVolume(IntPtr hwo, uint | dwVolume); | } | | public Form1() | { | InitializeComponent(); | uint CurrVol = 0; | // At this point, CurrVol gets assigned the volume | volAPI.waveOutGetVolume(IntPtr.Zero, out CurrVol); | // Calculate the volume | ushort CalcVol = (ushort)(CurrVol & 0x0000ffff); | MessageBox.Show("Vol: " + CalcVol.ToString()); | } | } | | </code> | Regards, | Krupa | kr*****@gmail.com wrote: Error VOL_TEST.EXE MissingMethodException Can't find PInvoke DLL 'winmm.dll' Any ideas?
winmm.dll is kind of like a device-driver for windows multimedia
functions. It certainly won't work to copy the DLL from "real" windows
to CE!
You need to go back and read the CE documentation for the functions
you're trying to call. In this case, read the CE documentation for
waveOutGetVolume. It says: "Link library coredll.lib". http://msdn.microsoft.com/library/de...tgetvolume.asp
So I suggest you look for a DLL with a similar name on your CE device,
and PInvoke it.
--
Lucian
Thanks Lucian! I Pinvoked coredll.dll and it worksed fine :-)
-Krupa This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: MLH |
last post by:
I have some audio help files that play fine from within Access 97
and Access 2.0. Both are running on a Windows XP box. But I
do not know what program plays the files.
If I click Start, Run and...
|
by: sirusdv |
last post by:
Has anyone been able to record microphone data via C# in any way? I
know there is a way with winmm.dll but I have not been able to manage
the whole process yet.
Any code would be GREATLY...
|
by: Dom Lague |
last post by:
Hello...
I'am creating a program to check the volume and to records sounds from
the digital input of my soundcard. I think that the best way to do it
is with de winmm.dll api using the sound...
|
by: Dom Lague |
last post by:
I need to get the signal level from the wave in input from a
soundblaster. I have tried to modify a program I found that uses the
winmm.dll functions.
I was able to open up the mixer , but I...
|
by: Mats-Lennart Hansson |
last post by:
Hi,
Is there a way to check for sound cards in c#? I don't want to force the
user to have DirectX9 or so, can I perhaps use winmm.dll?
Any help, and code snippets, is highly appreciated!
...
| |
by: Eric T |
last post by:
Hello friends, I'm in charge of some pure VC++ code but we're adding new
features using managed C++ (7.1). On two of three developer machines the
execution of this code has become impossible...
|
by: Steven T. Hatton |
last post by:
I'm trying to improve my formal understanding of C++. One significant part
of that effort involves clarifying my understanding of the vocabulary used
to describe the language.
This is from the...
|
by: oll3i |
last post by:
when i run my jsp file i get an error
SEVERE: Servlet.service() for servlet jsp threw exception
java.util.MissingResourceException: Can't find bundle for base name MessagesBundle, locale pl_PL...
|
by: btcoder |
last post by:
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException and the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |