
检查下任务栏右下角的输入法指示器是否还在。
如果没有,再看看这伍孝和个输入法图标是否变成活动慎态的了,停在了别的地方。
可以按Alt+Shift试试。(有的时候安装或卸载过其它输入法时会导致这样的问题)
如果不行,再试试按Ctrl+Space(空格)键,这是切换中英文输入法的(有的腔盯时候系统不稳定或你做过系统优化和修复等 *** 作会导致这样的问题)。
Option ExplicitPrivate hmem As Long
Const MMSYSERR_NOERROR = 0
Const MAXPNAMELEN = 32
Const MIXER_LONG_NAME_CHARS = 64
Const MIXER_SHORT_NAME_CHARS = 16
Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
Const MIXER_SETCONTROLDETAILSF_VALUE = &H0&
Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = _
(MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = _
(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
Const MIXERLINE_COMPONENTTYPE_SRC_LINE = _
(MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
Const MIXERCONTROL_CONTROLTYPE_FADER = _
(MIXERCONTROL_CT_CLASS_FADER Or _
MIXERCONTROL_CT_UNITS_UNSIGNED)
Const MIXERCONTROL_CONTROLTYPE_VOLUME = _
(MIXERCONTROL_CONTROLTYPE_FADER + 1)
Private Type MIXERCONTROLDETAILS
cbStruct As Long
dwControlID As Long
cChannels As Long
item As Long
cbDetails As Long
paDetails As Long
End Type
Private Type MIXERCONTROLDETAILS_UNSIGNED
dwValue As Long
End Type
Private Type MIXERCONTROL
cbStruct As Long
dwControlID As Long
dwControlType As Long
fdwControl As Long
cMultipleItems As Long
szShortName As String * MIXER_SHORT_NAME_CHARS
szName As String * MIXER_LONG_NAME_CHARS
lMinimum As Long
lMaximum As Long
reserved(10) As Long
End Type
Private Type MIXERLINECONTROLS
cbStruct As Long
dwLineID As Long
dwControl As Long
cControls As Long
cbmxctrl As Long
pamxctrl As Long
End Type
Private Type MIXERLINE
cbStruct As Long
dwDestination As Long
dwSource As Long
dwLineID As Long
fdwLine As Long
dwUser As Long
dwComponentType As Long
cChannels As Long
cConnections As Long
cControls As Long
szShortName As String * MIXER_SHORT_NAME_CHARS
szName As String * MIXER_LONG_NAME_CHARS
dwType As Long
dwDeviceID As Long
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
End Type
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
ByVal dwBytes As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hmem As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hmem As Long) As Long
Private Declare Sub CopyPtrFromStruct Lib "kernel32" Alias "RtlMoveMemory" _
(ByVal ptr As Long, struct As Any, ByVal cb As Long)
Private Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" _
(struct As Any, ByVal ptr As Long, ByVal cb As Long)
Private Declare Function mixerOpen Lib "winmm.dll" _
(phmx As Long, ByVal uMxId As Long, ByVal dwCallback As Long, _
ByVal dwInstance As Long, ByVal fdwOpen As Long) As Long
Private Declare Function mixerSetControlDetails Lib "winmm.dll" _
(ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, _
ByVal fdwDetails As Long) As Long
Private Declare Function mixerGetLineInfo Lib "winmm.dll" _
Alias "mixerGetLineInfoA" (ByVal hmxobj As Long, _
pmxl As MIXERLINE, ByVal fdwInfo As Long) As Long
Private Declare Function mixerGetLineControls Lib "winmm.dll" _
Alias "mixerGetLineControlsA" (ByVal hmxobj As Long, _
pmxlc As MIXERLINECONTROLS, ByVal fdwControls As Long) As Long
Private hmixer As Long
Private volCtrl As MIXERCONTROL ' 波形音量
Private micCtrl As MIXERCONTROL ' 麦克风音量
'以下用力保存变量
Private mvarprMicVolume As Long
Private mvarprMicMaxVolume As Long
Private mvarprMicMinVolume As Long
Private mvarprSpeakerVolume As Long
Private mvarprSpeakerMaxVolume As Long
Private mvarprSpeakerMinVolume As Long
Private mvarprMixerErr As Long
Private Function fGetVolumeControl(ByVal hmixer As Long, _
ByVal componentType As Long, ByVal ctrlType As Long, _
ByRef mxc As MIXERCONTROL) As Boolean
' 该函数将控制混音效果
Dim mxlc As MIXERLINECONTROLS
Dim mxl As MIXERLINE
Dim hmem As Long
Dim rc As Long
mxl.cbStruct = Len(mxl)
mxl.dwComponentType = componentType
rc = mixerGetLineInfo(hmixer, mxl, MIXER_GETLINEINFOF_COMPONENTTYPE)
If MMSYSERR_NOERROR = rc Then
With mxlc
.cbStruct = Len(mxlc)
.dwLineID = mxl.dwLineID
.dwControl = ctrlType
.cControls = 1
.cbmxctrl = Len(mxc)
End With
' 指定一个缓冲区
hmem = GlobalAlloc(&H40, Len(mxc))
mxlc.pamxctrl = GlobalLock(hmem)
mxc.cbStruct = Len(mxc)
rc = mixerGetLineControls(hmixer, mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)
If MMSYSERR_NOERROR = rc Then
fGetVolumeControl = True
' 在目标结构中加入控制
Call CopyStructFromPtr(mxc, mxlc.pamxctrl, Len(mxc))
Else
fGetVolumeControl = False
End If
Call GlobalFree(hmem)
Exit Function
End If
fGetVolumeControl = False
End Function
Private Function fSetVolumeControl(ByVal hmixer As Long, _
mxc As MIXERCONTROL, ByVal volume As Long) As Boolean
' 该函数设置控制音量的变量
Dim rc As Long
Dim mxcd As MIXERCONTROLDETAILS
Dim vol As MIXERCONTROLDETAILS_UNSIGNED
With mxcd
.item = 0
.dwControlID = mxc.dwControlID
.cbStruct = Len(mxcd)
.cbDetails = Len(vol)
End With
hmem = GlobalAlloc(&H40, Len(vol))
mxcd.paDetails = GlobalLock(hmem)
mxcd.cChannels = 1
vol.dwValue = volume
' 拷贝控制音量的变量到缓冲区
Call CopyPtrFromStruct(mxcd.paDetails, vol, Len(vol))
' 设置控制变量
rc = mixerSetControlDetails(hmixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
Call GlobalFree(hmem)
If MMSYSERR_NOERROR = rc Then
fSetVolumeControl = True
Else
fSetVolumeControl = False
End If
End Function
Public Function meOpenMixer() As Long
Dim rc As Long
Dim bOK As Boolean
rc = mixerOpen(hmixer, 0, 0, 0, 0)
mvarprMixerErr = rc
If MMSYSERR_NOERROR <>rc Then
MsgBox "Could not open the mixer.", vbCritical, "Volume Control"
Exit Function
End If
' 获取Wave音量控制
bOK = fGetVolumeControl(hmixer, _
MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, _
MIXERCONTROL_CONTROLTYPE_VOLUME, volCtrl)
' 如果函数取得对音量的控制
' 那么最大、最小音量则和变量lMaximum、lMinimum相符合
If bOK Then
mvarprSpeakerMaxVolume = volCtrl.lMaximum
mvarprSpeakerMinVolume = volCtrl.lMinimum
End If
' 获取对麦克风音量的控制
bOK = fGetVolumeControl(hmixer, _
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, _
MIXERCONTROL_CONTROLTYPE_VOLUME, micCtrl)
If bOK Then
mvarprMicMaxVolume = micCtrl.lMaximum
mvarprMicMinVolume = micCtrl.lMinimum
End If
End Function
Public Property Get prMixerErr() As Long
prMixerErr = mvarprMixerErr
End Property
Public Property Get prSpeakerMinVolume() As Long
prSpeakerMinVolume = mvarprSpeakerMinVolume
End Property
Public Property Get prSpeakerMaxVolume() As Long
prSpeakerMaxVolume = mvarprSpeakerMaxVolume
End Property
Public Property Let prSpeakerVolume(ByVal vData As Long)
mvarprSpeakerVolume = vData
Call fSetVolumeControl(hmixer, volCtrl, vData)
End Property
Public Property Get prSpeakerVolume() As Long
prSpeakerVolume = mvarprSpeakerVolume
End Property
Public Property Get prMicMinVolume() As Long
prMicMinVolume = mvarprMicMinVolume
End Property
Public Property Get prMicMaxVolume() As Long
prMicMaxVolume = mvarprMicMaxVolume
End Property
Public Property Let prMicVolume(ByVal vData As Long)
mvarprMicVolume = vData
Call fSetVolumeControl(hmixer, micCtrl, vData)
End Property
Public Property Get prMicVolume() As Long
prMicVolume = mvarprMicVolume
End Property
剩下的就是调用的
调用的方法你应该是知道的我只是提一下
Set MyVolume = New clsVolume
这样你就可以用里面的方法了,看看吧,至少有启发,祝你好运
这个需要调用麦克风的驱动吧。
你去查一下调用麦克风驱动方面的知识
用程序控制windows的麦克风的静音开关的方法:用MIXER来做。example:
BOOL CMixer::GetRecordradio()
{
UINT m_uMxId2
// HWND m_hWnd//回调句柄
HMIXER m_hmx2
MIXERCAPS mxcaps
//返回系统中混音器数量(如:一块普通声卡提供一个混音器设备)
int devnum=mixerGetNumDevs()
int i=0
for(ii{
m_uMxId2=i
if (MMSYSERR_NOERROR !=
mixerOpen(&m_hmx2, m_uMxId2,(DWORD)m_hWnd, 0, CALLBACK_WINDOW))
//使用dwCallback参数
return -1
//得到相应设备标识号
//mixerGetID((HMIXEROBJ)m_hmx2,&m_uMxId,MIXER_OBJECTF_HMIXER)
//确定各混音器设备的能力:保存在mxcaps结构中(wMid,wPid,szname,cDestinations)
if (MMSYSERR_NOERROR !=
mixerGetDevCaps(m_uMxId2,&mxcaps,sizeof(MIXERCAPS)))
return FALSE
//检索指定音频线路的信息,保存在MIXERLINE结构中,
//其中一些成员根据不同情况要初始化
MIXERLINE mxl
mxl.cbStruct = sizeof(MIXERLINE)//必须赋值
//可以通过多种条件来检索:
//方式一:根据目标单元编号
//mxl.dwDestination=0等同用mxl.dwComponentType=
MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
//mxl.dwDestination=1等同用mxl.dwComponentType=
MIXERLINE_COMPONENTTYPE_DST_WAVEIN
//对应flag: MIXER_GETLINEINFOF_DESTINATION
//mxl.dwDestination=1
//方式二:根据线路类型
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN
//对应flag: MIXER_GETLINEINFOF_COMPONENTTYPE
if (::mixerGetLineInfo((HMIXEROBJ)m_hmx2,
&mxl,
MIXER_OBJECTF_HMIXER |
MIXER_GETLINEINFOF_COMPONENTTYPE)
!= MMSYSERR_NOERROR) return -1
//查询 录音控制面版中 麦克风线路的编号
MIXERLINE mxl_v
UINT cConnections = (UINT)mxl.cConnections
UINT dwSource_v=0
do
{
mxl_v.cbStruct = sizeof(mxl_v)
mxl_v.dwDestination = mxl.dwDestination
mxl_v.dwSource = dwSource_v
dwSource_v++
if (MMSYSERR_NOERROR !=
mixerGetLineInfo((HMIXEROBJ)m_hmx2,
&mxl_v,
MIXER_GETLINEINFOF_SOURCE))
return FALSE
} while ((dwSource_v <cConnections) &&
(mxl_v.dwComponentType != MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE))
if((dwSource_v >cConnections) ||
(mxl_v.dwComponentType !=MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE))
return FALSE
dwSource_v--//得到编号
//下面这段文字说明在本例中已经没有什么实际意义,是以前调试时留下的,也不删除了,
//可以知清兆道如何控制主音(Volume)线路的禁音状态答御租:
//--可以利用得到的主音(Volume)线路的mxl.dwLineID,
//来查询拆哪Volume的禁音状态
//要想查询(或设置)可以混音到DST_SPEAKERS主音(Volume)中的
//相关音源线路(如:wave、micphone等)的禁音状态,还必须再使用
//一次 mixerGetLineInfo 进一步指定其dwLineID
//注意:不要简单的直接修改上面的:
//mxl.dwComponentType = 类型
//虽然可能有时不会报错,但这成了我们程序中的隐患,
//因为有的线路在DST_SPEAKERS和DST_WAVEIN中均有,如:
//MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
//下面实现了"强制"单选麦克风线路为录音源输入
MIXERCONTROL mxc
MIXERLINECONTROLS mxlc
mxlc.cbStruct = sizeof(MIXERLINECONTROLS)
mxlc.dwLineID = mxl.dwLineID
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX
//MIXERCONTROL_CONTROLTYPE_MUTE
mxlc.cControls = 1
mxlc.cbmxctrl = sizeof(MIXERCONTROL)
mxlc.pamxctrl = &mxc//为了得到相应的mxc.dwControlID,
//锁定mxlc.dwLineID和mxlc.dwControlType指定的线路控制
//目前将对录音目标单元的录音音源线路做单选(多路复用)
if (::mixerGetLineControls((HMIXEROBJ)m_hmx2,
&mxlc,
MIXER_OBJECTF_HMIXER |
MIXER_GETLINECONTROLSF_ONEBYTYPE)
!= MMSYSERR_NOERROR) return -1
//根据mxc.dwControlID检索线路,
MIXERCONTROLDETAILS_BOOLEAN mxcdMute[8]
MIXERCONTROLDETAILS mxcd
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS)
mxcd.dwControlID = mxc.dwControlID//在上面的&mxc得到
mxcd.cChannels = 1
mxcd.cMultipleItems =mxc.cMultipleItems//多路因子数目
mxcd.cbDetails = sizeof(*mxcdMute)
mxcd.paDetails =&mxcdMute//存放检索结果
if (::mixerGetControlDetails((HMIXEROBJ)m_hmx2,
&mxcd,
MIXER_OBJECTF_HMIXER |
MIXER_GETCONTROLDETAILSF_value)
!= MMSYSERR_NOERROR) return -1
//做相应单选改变
int j
for(j=0j<(int)mxc.cMultipleItemsj++)
mxcdMute[j].fvalue=false
mxcdMute[dwSource_v].fvalue=true
//重新设置dwControlID锁定的线路控制
if (::mixerSetControlDetails((HMIXEROBJ)m_hmx2,
&mxcd,
MIXER_OBJECTF_HMIXER |
MIXER_GETCONTROLDETAILSF_value)
!= MMSYSERR_NOERROR) return -1
}//for(iireturn TRUE
}
================
::ZeroMemory(&m_mxcaps, sizeof(MIXERCAPS))//指定区域清零
(iwgh)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)