| 
 | 
 
Project-> Link: winmm.lib 
#include "mmsystem.h" 
 
 
BOOL GetRecordradio () 
{ 
Ranch 
UINT m_uMxId2; 
// HWND m_hWnd; // Callback handle 
HMIXER m_hmx2; 
MIXERCAPS mxcaps; 
Ranch 
// Return the number of mixers in the system (e.g. a common sound card provides a mixer device) 
int devnum = mixerGetNumDevs (); 
int i = 0; 
Ranch 
for (i; i <devnum; i ++) 
{ 
m_uMxId2 = i; 
if (MMSYSERR_NOERROR! = 
mixerOpen (&m_hmx2, m_uMxId2, NULL, 0, CALLBACK_WINDOW)) 
// use dwCallback parameter 
return -1; 
Ranch 
// Get the corresponding device identification number 
// mixerGetID ((HMIXEROBJ) m_hmx2,&m_uMxId, MIXER_OBJECTF_HMIXER); 
Ranch 
// Determine the capabilities of each mixer device: saved in the mxcaps structure (wMid, wPid, szname, cDestinations) 
if (MMSYSERR_NOERROR! = 
mixerGetDevCaps (m_uMxId2,&mxcaps, sizeof (MIXERCAPS))) 
return FALSE; 
Ranch 
// Retrieve the information of the specified audio line and save it in the MIXERLINE structure, 
// Some of these members need to be initialized according to different situations 
MIXERLINE mxl; 
mxl.cbStruct = sizeof (MIXERLINE); // Must be assigned 
Ranch 
// can be retrieved by multiple conditions: 
// Method 1: According to the target unit number 
//mxl.dwDestination=0; equivalent to mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS 
//mxl.dwDestination=1; equivalent mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN 
// Corresponding flag: MIXER_GETLINEINFOF_DESTINATION 
//mxl.dwDestination=1; 
Ranch 
// Method 2: According to the type of line 
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; 
// Corresponding flag: MIXER_GETLINEINFOF_COMPONENTTYPE 
Ranch 
if (:: mixerGetLineInfo ((HMIXEROBJ) m_hmx2, 
&mxl, 
MIXER_OBJECTF_HMIXER | 
MIXER_GETLINEINFOF_COMPONENTTYPE) 
! = MMSYSERR_NOERROR) return -1; 
Ranch 
// Query the number of the microphone line in the recording control panel 
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)); 
Ranch 
if ((dwSource_v> cConnections) || 
(mxl_v.dwComponentType! = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE)) 
return FALSE; 
dwSource_v-; // Get the number 
Ranch 
// The following text indicates that it has no practical meaning in this example, it was left in the previous debugging and will not be deleted. 
// You can know how to control the muted state of the main line: 
// --- can use the mxl.dwLineID of the obtained volume (Volume) line, 
// To query the volume's silence status 
// If you want to query (or set), you can mix it into the DST_SPEAKERS main volume (Volume) 
// Relevant sound source lines (such as: wave, micphone, etc.) must be used again. 
// One mixerGetLineInfo further specifies its dwLineID 
// Note: Don't simply modify the above directly: 
//mxl.dwComponentType = type; 
// Although sometimes an error may not be reported, this has become a hidden danger in our program. 
// Because some lines are available in DST_SPEAKERS and DST_WAVEIN, such as: 
// MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC 
Ranch 
Ranch 
// The following implements a "mandatory" radio microphone input for the recording source 
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; // In order to get the corresponding mxc.dwControlID, 
        // Lock the line control specified by mxlc.dwLineID and mxlc.dwControlType 
        // At present, the radio source line of the recording target unit will be selected (multiplexed) 
if (:: mixerGetLineControls ((HMIXEROBJ) m_hmx2, 
&mxlc, 
MIXER_OBJECTF_HMIXER | 
MIXER_GETLINECONTROLSF_ONEBYTYPE) 
! = MMSYSERR_NOERROR) return -1; 
Ranch 
// Retrieve the line according to mxc.dwControlID, 
MIXERCONTROLDETAILS_BOOLEAN mxcdMute [8]; 
MIXERCONTROLDETAILS mxcd; 
mxcd.cbStruct = sizeof (MIXERCONTROLDETAILS); 
mxcd.dwControlID = mxc.dwControlID; // Ouo0mxc above 
mxcd.cChannels = 1; 
mxcd.cMultipleItems = mxc.cMultipleItems; // Multiple number of factors 
mxcd.cbDetails = sizeof (* mxcdMute); 
mxcd.paDetails =&mxcdMute; // Store the search results 
if (:: mixerGetControlDetails ((HMIXEROBJ) m_hmx2, 
&mxcd, 
MIXER_OBJECTF_HMIXER | 
MIXER_GETCONTROLDETAILSF_VALUE) 
! = MMSYSERR_NOERROR) return -1; 
Ranch 
// Make corresponding radio selection changes 
int j; 
for (j = 0; j <(int) mxc.cMultipleItems; j ++) 
mxcdMute [j] .fValue = false; 
mxcdMute [dwSource_v] .fValue = true; 
Ranch 
// Reset line control locked by dwControlID 
if (:: mixerSetControlDetails ((HMIXEROBJ) m_hmx2, 
&mxcd, 
MIXER_OBJECTF_HMIXER | 
MIXER_GETCONTROLDETAILSF_VALUE) 
! = MMSYSERR_NOERROR) return -1; 
} // for (i; i <devnum; i ++) 
return TRUE; 
} |   
 
 
 
 |