Error: [ilink32 Error] Unresolved external '_PKEY_Device_FriendlyName referenced from
[ilink32 Error] Error: Unable to perform the link
The code is as follows:
#include
#include
#include
#include
#include
Bool MixerWrap: : SetSpeakerValue_W7 (float fVolume)//set the speaker volume
{
IMMDeviceEnumerator * pEnumerator;
IMMDeviceCollection * pCollection=NULL;
IMMDevice * pDevice=NULL;
IPropertyStore * pProperties=NULL;
IAudioEndpointVolume * pVolumeAPI=NULL;
IAudioAutoGainControl * pAutoGain=NULL;
GUID m_guidMyContext;
UINT deviceCount=0;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
Retrieves the hr=CoCreateInstance (__uuidof (MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof (IMMDeviceEnumerator), (void * *) & amp; PEnumerator);
If (hr!=S_OK)
{
Printf (" CoCreateInstance Failed!/n ");
return 0;
}
Hr=pEnumerator - & gt; ECapture EnumAudioEndpoints (/* */eRender, DEVICE_STATE_ACTIVE, & amp; PCollection);
//hr=pEnumerator - & gt; EnumAudioEndpoints (eRender DEVICE_STATEMASK_ALL, & amp; PCollection);
If (hr!=S_OK)
{
Printf (" EnumAudioEndpoints Failed!/n ");
Goto releasepEnumerator;
}
Hr=pCollection - & gt; GetCount (& amp; DeviceCount);
If (hr!=S_OK)
{
Printf (" GetCount Failed!/n ");
Goto releasepCollection;
}
For (UINT dev=0; Dev
PDevice=NULL;
Hr=pCollection - & gt; The Item (dev, & amp; PDevice);
If (hr==S_OK)
{
Hr=pDevice - & gt; OpenPropertyStore (STGM_READ, & amp; PProperties);
If (hr==S_OK)
{
PROPVARIANT varName;
PropVariantInit (& amp; VarName);
Hr=pProperties - & gt; GetValue (PKEY_Device_FriendlyName, & amp; VarName);
If (hr==S_OK)
{
//: : MessageBox (NULL, varName pwszVal, _T (" message "), MB_OK | MB_ICONINFORMATION);
//if (WCSSTR (varName pwszVal, _T (" speaker "))!=NULL)
{
//hr=pDevice - & gt; Activate (__uuidof (IAudioAutoGainControl), CLSCTX_ALL, NULL, (void * *) (& amp; PAutoGain));
Hr=pDevice - & gt; Activate (__uuidof (IAudioEndpointVolume), CLSCTX_ALL, NULL, (void * *) (& amp; PVolumeAPI));
If (hr==S_OK)
{
UINT chanelCount=0;
Hr=pVolumeAPI - & gt; GetChannelCount (& amp; ChanelCount);
For (int I=0; i
If ((int) fVolume & lt; 0)
FVolume=0;
If ((int) fVolume & gt; MAX_VOL)
FVolume=MAX_VOL;
PVolumeAPI - & gt; SetMasterVolumeLevelScalar ((float) fVolume/MAX_VOL, & amp; M_guidMyContext);
}
SAFE_RELEASE (pVolumeAPI);
}
}
}
SAFE_RELEASE (pProperties);
}
SAFE_RELEASE (pDevice);
}
}
ReleasepCollection:
SAFE_RELEASE (pCollection);
ReleasepEnumerator:
SAFE_RELEASE (pEnumerator);
return 0;
}
CodePudding user response:
Need to uuid. Lib join the project, such as:# pragma would "uuid. Lib"
Attention to $(BDSLIB) \ $(PLATFORM), the release, the PSDK directory is added to the engineering properties of the Library in the path
CodePudding user response:
$(BDSLIB) \ $(PLATFORM), the release, the PSDKThe road king is invalid, you need to install?
CodePudding user response:
Try again for this:$(BDSLIB) \ win32 \ release \ PSDK
In addition, I want to say is: engineering options shown in a path is the path of the gray (suspected illegal) are not necessarily invalid, sometimes is a small BUG, IDE
CodePudding user response:
Add $(BDSLIB) \ win32 \ release \ PSDK is valid, but the error as before (in the above function called when an error),//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#include
#include
#include
#include
#include
#include
#include
# pragma hdrstop
# include "Unit1. H"
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma package (smart_init)
# pragma resource "*. DFM
"# define EXIT_ON_ERROR (hres) if (FAILED (hres)) {goto the Exit; }
# define SAFE_RELEASE (punk) if ((punk)!=NULL) {(punk) - & gt; Release (); (punk)=NULL; }
TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Bool TForm1: : SetSpeakerValue_W7 (float fVolume)//set the speaker volume
{
IMMDeviceEnumerator * pEnumerator;
IMMDeviceCollection * pCollection=NULL;
IMMDevice * pDevice=NULL;
IPropertyStore * pProperties=NULL;
IAudioEndpointVolume * pVolumeAPI=NULL;
IAudioAutoGainControl * pAutoGain=NULL;
GUID m_guidMyContext;
UINT deviceCount=0;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull