Function WaveInOpen doesn't return meesage MM_WIM_OPEN?



Hallo,

I have problem with function WaveInOpen . This function doesn't return
meesage MM_WIM_OPEN?

Shall YOU help me pleas?

Any suggestions?

Thank you!

My code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;


namespace SoundApplication
{
public partial class frmMain : Form
{
public int wav;
public IntPtr hWaveIn = IntPtr.Zero;
public IntPtr hWaveOut = IntPtr.Zero;
public IntPtr dwCallback = IntPtr.Zero;

public frmMain()
{
InitializeComponent();

}

public class Winmm
{
public struct WAVEFORMAT
{
public short wFormatTag;
public short nChannels;
public uint nSamplesPerSec;
public uint nAvgBytesPerSec;
public short nBlockAlign;
public short wBitsPerSample;
public short cbSize;
}

public class WAVEHDR
{
public IntPtr lpData = IntPtr.Zero;
public uint dwBufferLength = 0;
public uint dwBytesRecorded = 0;
public uint dwUser = 0;
public uint dwFlags = 0;
public uint dwLoops = 0;
public IntPtr lpNext = IntPtr.Zero;
public uint reserved = 0;
}

private const string mmdll = "winmm.dll";

// WaveIn calls
[DllImport(mmdll)]
public static extern int waveInGetNumDevs();
[DllImport(mmdll)]
public static extern int waveInOpen(ref IntPtr lphWaveIn,
uint DEVICEID, ref WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);

//WaveOut calls
[DllImport(mmdll)]
public static extern int waveOutOpen(ref IntPtr
lphWaveOut, uint DEVICEID, ref WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);
}

private void btOpen_Click(object sender, EventArgs e)
{
const uint WAVE_MAPPER = unchecked((uint)(-1));
const int CALLBACK_WINDOW = 0x00010000;
const int CALLBACK_TASK = 0x00020000;
const int CALLBACK_FUNCTION = 0x00030000;
const int CALLBACK_EVENT = 0x00050000;

Winmm.WAVEFORMAT wavFmt;
wavFmt.wFormatTag = 1;
wavFmt.nChannels = 1;
wavFmt.nSamplesPerSec = 44100;
wavFmt.nAvgBytesPerSec = 44100;
wavFmt.nBlockAlign = 1;
wavFmt.wBitsPerSample = 8;
wavFmt.cbSize = 0;

wav = Winmm.waveInOpen(ref hWaveIn, WAVE_MAPPER, ref
wavFmt, dwCallback, 0, CALLBACK_WINDOW);
MessageBox.Show(wav.ToString());
wav = Winmm.waveOutOpen(ref hWaveOut, WAVE_MAPPER, ref
wavFmt, dwCallback, 0, CALLBACK_WINDOW);
}

protected override void WndProc(ref Message m)
{

const int MM_WIM_OPEN = 0x3BE;
const int MM_WIM_CLOSE = 0x3BF;
const int MM_WIM_DATA = 0x3C0;

const int MM_WOM_OPEN = 0x3BB;
const int MM_WOM_CLOSE = 0x3BC;
const int MM_WOM_DONE = 0x3BD;
if (m.Msg == MM_WIM_OPEN || m.Msg == MM_WOM_OPEN || m.Msg
== MM_WIM_CLOSE)
{
MessageBox.Show("TEST");
}
switch (m.Msg)
{
case MM_WIM_OPEN:
MessageBox.Show("MM_WIM_OPEN");
break;
case MM_WIM_CLOSE:
MessageBox.Show("MM_WOM_OPEN");
break;
case MM_WOM_OPEN:
MessageBox.Show("MM_WOM_OPEN");
break;


}
base.WndProc(ref m);
}

}
}

.



Relevant Pages

  • DCOM across domains
    ... public IntPtr pIID; ... public struct COAUTHIDENTITY ... public uint DomainLength; ...
    (microsoft.public.dotnet.framework.interop)
  • Manipulating win32 app menus from c# using pinvoke...
    ... supplying the fMask of the MENUITEMINFO with the MF_OWNERDRAW constant from ... public uint cbSize; ... public IntPtr hbmpChecked; ... private static extern IntPtr GetSubMenu ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Access Denied executing Batch File from CreateProcessAsUser
    ... > public uint dwX; ... > public IntPtr lpReserved2; ... > private extern static bool CreateProcessAsUser(IntPtr hToken, ... > lpApplicationName, String lpCommandLine, ref SECURITY_ATTRIBUTES ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Can a context menu have side-by-side menu items?
    ... public uint fMask; ... public IntPtr hbmpChecked; ... fByPosition, ref MENUITEMINFO lpmii); ... const uint MFT_MENUBARBREAK = 0x20; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Connection to GPRS with P/Invoke
    ... Do you know how to close the GPRS connection ... public uint dwParams; ... private static extern int ConnMgrMapURL(string pwszURL, ...
    (microsoft.public.dotnet.framework.compactframework)