Ok j'ai cherché sur le site mais les codes que j'ai trouvé ne marche pas sur mon ordi
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionImports System Imports System.Collections.Generic Imports System.Text Imports System.Runtime.InteropServices ''' <summary> ''' Permet de changer le volume de Windows ''' </summary> Public Module Son ''' <summary> ''' The waveOutGetVolume function retrieves the current volume level of the specified waveform-audio output device. ''' </summary> ''' Handle to an open waveform-audio output device. This parameter can also be a device identifier. ''' Pointer to a variable to be filled with the current volume setting. The low-order word of this location contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence. ''' <returns>Returns MMSYSERR_NOERROR if successful or an error otherwise. </returns> <DllImport("winmm.dll")> _ Private Function waveOutGetVolume(ByVal hwo As IntPtr, ByRef dwVolume As UInteger) As Integer End Function ''' <summary> ''' The waveOutSetVolume function sets the volume level of the specified waveform-audio output device. ''' </summary> ''' Handle to an open waveform-audio output device. This parameter can also be a device identifier. ''' New volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence. ''' <returns>Returns MMSYSERR_NOERROR if successful or an error otherwise.</returns> <DllImport("winmm.dll")> _ Private Function waveOutSetVolume(ByVal hwo As IntPtr, ByVal dwVolume As UInteger) As Integer End Function ''' <summary> ''' Volume maximum ''' </summary> Public Const VolumeMax As Integer = &HFFFF ''' <summary> ''' Changer le volume pour l'enceinte à et à . ''' </summary> ''' Volume de l'enceinte de gauche, si null alors le volume de l'enceinte de gauche n'est pas changé. ''' Volume de l'enceinte de droite, si null alors le volume de l'enceinte de droite n'est pas changé. Private Sub ChangerVolume(ByVal gauche As System.Nullable(Of Integer), ByVal droite As System.Nullable(Of Integer)) Dim volume As UInteger If gauche Is Nothing Then gauche = VolumeGauche End If If droite Is Nothing Then droite = VolumeDroite End If volume = (CUInt(gauche.Value) And &HFFFF) << 16 volume = volume Or (CUInt(droite.Value) And &HFFFF) waveOutSetVolume(IntPtr.Zero, volume) End Sub ''' <summary> ''' Récupère le volume d'une des enceinte ou les deux. ''' </summary> ''' true pour récupérer le volume de l'enceint de gauche, false pour celle ''' de droite, null pour les deux. ''' <returns>Le volume de l'enceint spécifiée ou la moyenne des deux.</returns> Private Function GetVolume(ByVal récupérerVolumeGauche As System.Nullable(Of Boolean)) As Integer Dim volume As UInteger Dim gauche As Integer Dim droite As Integer waveOutGetVolume(IntPtr.Zero, volume) gauche = CInt(((volume And &HFFFF0000) >> 16)) droite = CInt((volume And &HFFFF)) If récupérerVolumeGauche IsNot Nothing Then If récupérerVolumeGauche.Value = True Then Return gauche Else Return droite End If Else Return (gauche + droite) / 2 End If End Function ''' <summary> ''' Obtient ou défini le volume des enceintes ''' </summary> ''' <exception cref="ArgumentOutOfRangeException">Si est null.</exception> Public Property Volume() As Integer Get Return GetVolume(Nothing) End Get Set(ByVal value As Integer) If value < 0 AndAlso value > VolumeMax Then Throw New ArgumentOutOfRangeException([String].Format("Le volume doit être compris entre 0 et {0}", VolumeMax), "value") End If ChangerVolume(value, value) End Set End Property ''' <summary> ''' Obtient ou défini le volume de l'enceinte de gauche ''' </summary> ''' <remarks> doit être compris entre 0 et <see cref="VolumeDroite"/>.</remarks> ''' <exception cref="ArgumentOutOfRangeException">Si n'est pas compris entre 0 et <see cref="VolumeMax"/>.</exception> Public Property VolumeGauche() As Integer Get Return GetVolume(True) End Get Set(ByVal value As Integer) If value < 0 AndAlso value > VolumeMax Then Throw New ArgumentOutOfRangeException([String].Format("Le volume doit être compris entre 0 et {0}", VolumeMax), "value") End If ChangerVolume(value, Nothing) End Set End Property ''' <summary> ''' Obtient ou défini le volume de l'enceinte de droite. ''' </summary> ''' <remarks> doit être compris entre 0 et <see cref="VolumeDroite"/>.</remarks> ''' <exception cref="ArgumentOutOfRangeException">Si n'est pas compris entre 0 et <see cref="VolumeDroite"/>.</exception> Public Property VolumeDroite() As Integer Get Return GetVolume(False) End Get Set(ByVal value As Integer) If value < 0 AndAlso value > VolumeMax Then Throw New ArgumentOutOfRangeException([String].Format("Le volume doit être compris entre 0 et {0}", VolumeMax), "value") End If ChangerVolume(Nothing, value) End Set End Property End Module
Son.Volume = TextBox1.textle volume sonore de l'appli baisse.
Forum > Visual Basic 6