0
,我有以下功能我打電話打印出枚舉音頻端點的端點和友好名稱:的Windows核心音頻錯誤
void EPPrint(void)
{
HRESULT hr;
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDeviceCollection *pCollection = NULL;
IMMDevice *pEp = NULL;
IPropertyStore *pProps =NULL;
UINT count;
PWSTR strID;
PROPVARIANT pv;
hr = CoCreateInstance(CLSID_MMDeviceEnumerator ,NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&pEnumerator);
hr = pEnumerator -> EnumAudioEndpoints(eRender,DEVICE_STATE_ACTIVE,&pCollection);
hr = pCollection ->GetCount(&count);
if(count==0)
{
}
for (ULONG i =0; i<count; ++i)
{
hr= pCollection->Item(i,&pEp);
hr = pEp ->GetId(&strID);
hr = pEp ->OpenPropertyStore(STGM_READ,&pProps);
PropVariantInit(&pv);
hr = pProps ->GetValue(PKEY_Device_FriendlyName, &pv);
printf("Enpoint %d: \"%S\" (%S)\n",i,pv.pwszVal, strID);
}
}
但是我得到它打破了程序運行時錯誤Unhandled exception at 0x008e104a in EPAudioControl.exe: 0xC0000005: Access violation reading location 0x00000000.
在hr = pEnumeartor -> ...
行。
該程序是否需要某種特殊的Windows權限才能正常運行?