vb.netaudiomodulecodedom

Me.Handle in Module - Alternative?


I am currently programming something but I've hit a small problem, which is:

Using Me.Handle in a module that will be used as the source for a CodeDom-Compiler.

I want or rather need to use it in the following procedure:

Private Const APPCOMMAND_VOLUME_MUTE As Integer = &H80000
Private Const WM_APPCOMMAND As Integer = &H319
Declare Function SendMessageW Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

Private Sub Mute()
    SendMessageW(Me.Handle, WM_APPCOMMAND, Me.Handle, CType(APPCOMMAND_VOLUME_MUTE, IntPtr))
End Sub

You get the idea, I want to mute the System-Sound. I am more or less searching for some way of doing this without using Me.Handle, as it is not working in my module for some reason...

Any help is appreciated, thanks in advance guys!


Solution

  • Alright guys I managed to fix it by doing this:

    Private frm As New System.Windows.Forms.Form()  
    SendMessageW(frm.Handle, WM_APPCOMMAND, frm.Handle, CType(APPCOMMAND_VOLUME_MUTE, IntPtr))
    

    That's basically what it does inside of the module, thanks anyways!