473,513 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't find P/Invoke winmm.dll

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

May 4 '06 #1
5 11225
>I copied winmm.dll from
Windows\system32 directory into the root directory of my project.


Why? It should be found in the System32 directory.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 4 '06 #2
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
|
May 5 '06 #3
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
|


May 5 '06 #4
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
May 5 '06 #5
Thanks Lucian! I Pinvoked coredll.dll and it worksed fine :-)

-Krupa

May 8 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
3710
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...
1
12391
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...
0
1844
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...
2
2017
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...
2
4488
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! ...
2
1265
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...
21
2373
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...
6
6916
oll3i
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...
2
3825
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...
0
7259
marktang
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,...
0
7158
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...
0
7380
Oralloy
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,...
0
7535
jinu1996
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...
0
5683
agi2029
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,...
0
4745
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...
0
3232
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...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
455
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.