C# using winmm.dll audio recording

Thread Starter

kevinroseit

Joined Nov 7, 2011
1
Hello, I am trying to create a software that records audio information from a microphone. I am trying to do this using code in the winmm.dll file.
I can import this code fine from the DLL.
Rich (BB code):
[DllImport("winmm.dll")]
privatestaticexternbool PlaySound(string filename, int module, int flags);
However I cannot import this code
Rich (BB code):
[DllImport("winmm.dll")]
private static extern MMRESULT waveInOpen(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwCallbackInstance, DWORD fdwOpen);
The reason being waveInOpen is of type MMRESULT. I was wondering if anyone knew how I could import the MMRESULT. If I have to make it, what is actually in the MMRESULT type?

I have looked into other ways of going about programming my project and this seems like the best way, I would choose for what I want.

Also I could use CORE Audio API's. The only problem I have found is they're verry low level programming so i would have to use C/C++. I need to use C# for this project but if anyone could give some insight to how i would implement header files in C# it would be greatly appreciated!
 

ApacheKid

Joined Jan 12, 2015
1,610
Hello, I am trying to create a software that records audio information from a microphone. I am trying to do this using code in the winmm.dll file.
I can import this code fine from the DLL.
Rich (BB code):
[DllImport("winmm.dll")]
privatestaticexternbool PlaySound(string filename, int module, int flags);
However I cannot import this code
Rich (BB code):
[DllImport("winmm.dll")]
private static extern MMRESULT waveInOpen(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwCallbackInstance, DWORD fdwOpen);
The reason being waveInOpen is of type MMRESULT. I was wondering if anyone knew how I could import the MMRESULT. If I have to make it, what is actually in the MMRESULT type?

I have looked into other ways of going about programming my project and this seems like the best way, I would choose for what I want.

Also I could use CORE Audio API's. The only problem I have found is they're verry low level programming so i would have to use C/C++. I need to use C# for this project but if anyone could give some insight to how i would implement header files in C# it would be greatly appreciated!
I can help with anything to do with C#, if the code is only ever going to run on a .Net platform then avoid stepping down to C or C++ at all cost if you can and stick with .Net. The interop abilities in .Net for C and C++ are extremely good, very well designed and far better than what Java offers.

The signature for those interop calls are visible here, looks like you can remove MMRESULT, the actual type is int.

https://stackoverflow.com/questions/7105806/c-sharp-audio-recording-using-winmm-dll-native-code
 
Last edited:
Top