However, I get an empty PropertyVariantStructure back although "GetValue" on the device is successful. Anyone has an idea?
Code: Select all
EnableExplicit
#DEVICE_STATE_ACTIVE = 1
#DEVICE_STATE_DISABLED = 2
#DEVICE_STATE_NOTPRESENT = 4
#DEVICE_STATE_UNPLUGGED = 8
#DEVICE_STATEMASK_ALL = $F
Enumeration
#eRender
#eCapture
#eAll
#EDataFlow_enum_count
EndEnumeration
Structure PROPVARIANT_CLIPDATA
cbSize.l
ulClipFmt.l
*pClipData.BYTE
EndStructure
Structure PROPVARIANT_BSTRBLOB
cbSize.l
*pData.BYTE
EndStructure
Structure PROPVARIANT_BLOB
cbSize.l
*pBlobData.BYTE
EndStructure
Structure PROPVARIANT_VERSIONEDSTREAM
guidVersion.GUID
*pStream.IStream
EndStructure
Structure PROPVARIANT_CAC
cElems.l
*pElems.BYTE
EndStructure
Structure PROPVARIANT_CAUB
cElems.l
*pElems.BYTE
EndStructure
Structure PROPVARIANT_CAI
cElems.l
*pElems.WORD
EndStructure
Structure PROPVARIANT_CAUI
cElems.l
*pElems.WORD
EndStructure
Structure PROPVARIANT_CAL
cElems.l
*pElems.LONG
EndStructure
Structure PROPVARIANT_CAUL
cElems.l
*pElems.LONG
EndStructure
Structure PROPVARIANT_CAFLT
cElems.l
*pElems.FLOAT
EndStructure
Structure PROPVARIANT_CADBL
cElems.l
*pElems.DOUBLE
EndStructure
Structure PROPVARIANT_CACY
cElems.l
*pElems.QUAD
EndStructure
Structure PROPVARIANT_CADATE
cElems.l
*pElems.DOUBLE
EndStructure
Structure PROPVARIANT_CABSTR
cElems.l
*pElems.INTEGER
EndStructure
Structure PROPVARIANT_CABSTRBLOB
cElems.l
*pElems.PROPVARIANT_BSTRBLOB
EndStructure
Structure PROPVARIANT_CABOOL
cElems.l
*pElems.WORD
EndStructure
Structure PROPVARIANT_CASCODE
cElems.l
*pElems.LONG
EndStructure
Structure PROPVARIANT_CAPROPVARIANT
cElems.l
*pElems.PROPVARIANT
EndStructure
Structure PROPVARIANT_CAH
cElems.l
*pElems.QUAD
EndStructure
Structure PROPVARIANT_CAUH
cElems.l
*pElems.QUAD
EndStructure
Structure PROPVARIANT_CALPSTR
cElems.l
*pElems.INTEGER
EndStructure
Structure PROPVARIANT_CALPWSTR
cElems.l
*pElems.INTEGER
EndStructure
Structure PROPVARIANT_CAFILETIME
cElems.l
*pElems.FILETIME
EndStructure
Structure PROPVARIANT_CACLIPDATA
cElems.l
*pElems.PROPVARIANT_CLIPDATA
EndStructure
Structure PROPVARIANT_CACLSID
cElems.l
*pElems.CLSID
EndStructure
Structure tag_inner_PROPVARIANT Align #PB_Structure_AlignC
vt.w
wReserved1.w
wReserved2.w
wReserved3.w
StructureUnion
cVal.b
bVal.b
iVal.w
uiVal.w
lVal.l
ulVal.l
intVal.l
uintVal.l
hVal.q
uhVal.q
fltVal.f
dblVal.d
boolVal.w
scode.l
cyVal.q
date.d
filetime.FILETIME
*puuid.CLSID
*pclipdata.PROPVARIANT_CLIPDATA
bstrVal.i
bstrblobVal.PROPVARIANT_BSTRBLOB
blob.PROPVARIANT_BLOB
*pszVal
*pwszVal
*punkVal.IUnknown
*pdispVal.IDispatch
*pStream.IStream
*pStorage.IStorage
*pVersionedStream.PROPVARIANT_VERSIONEDSTREAM
*parray.SAFEARRAY
cac.PROPVARIANT_CAC
caub.PROPVARIANT_CAUB
cai.PROPVARIANT_CAI
caui.PROPVARIANT_CAUI
cal.PROPVARIANT_CAL
caul.PROPVARIANT_CAUL
cah.PROPVARIANT_CAH
cauh.PROPVARIANT_CAUH
caflt.PROPVARIANT_CAFLT
cadbl.PROPVARIANT_CADBL
cabool.PROPVARIANT_CABOOL
cascode.PROPVARIANT_CASCODE
cacy.PROPVARIANT_CACY
cadate.PROPVARIANT_CADATE
cafiletime.PROPVARIANT_CAFILETIME
cauuid.PROPVARIANT_CACLSID
caclipdata.PROPVARIANT_CACLIPDATA
cabstr.PROPVARIANT_CABSTR
cabstrblob.PROPVARIANT_CABSTRBLOB
calpstr.PROPVARIANT_CALPSTR
calpwstr.PROPVARIANT_CALPWSTR
capropvar.PROPVARIANT_CAPROPVARIANT
*pcVal.BYTE
*pbVal.BYTE
*piVal.WORD
*puiVal.WORD
*plVal.LONG
*pulVal.LONG
*pintVal.LONG
*puintVal.LONG
*pfltVal.FLOAT
*pdblVal.DOUBLE
*pboolVal.WORD
*pdecVal.VARIANT_DECIMAL
*pscode.LONG
*pcyVal.QUAD
*pdate.DOUBLE
*pbstrVal.INTEGER
*ppunkVal.INTEGER
*ppdispVal.INTEGER
*pparray.INTEGER
*pvarVal.PROPVARIANT
EndStructureUnion
EndStructure
Structure PROPVARIANT
StructureUnion
p.tag_inner_PROPVARIANT
decVal.i
EndStructureUnion
EndStructure
Interface IMMDeviceEnumerator Extends IUnknown
EnumAudioEndpoints(dataFlow.i, dwStateMask.l, *pDevices)
GetDefaultAudioEndpoint(Flow.l, role.l, IMMDevice.i)
GetDevice(*wstrId, *pDevice)
RegisterEndpointNotificationCallback()
UnregisterEndpointNotificationCallback()
EndInterface
Interface IAudioEndpointVolume Extends IUnknown
RegisterControlChangeNotify()
UnregisterControlChangeNotify()
GetChannelCount()
SetMasterVolumeLevel()
SetMasterVolumeLevelScalar()
GetMasterVolumeLevel()
GetMasterVolumeLevelScalar()
SetChannelVolumeLevel()
SetChannelVolumeLevelScalar()
GetChannelVolumeLevel()
GetChannelVolumeLevelScalar()
SetMute(bMute.i, *guidEventContext)
GetMute(*pbMute)
GetVolumeStepInfo()
VolumeStepUp(*context)
VolumeStepDown(*context)
QueryHardwareSupport()
GetVolumeRange()
EndInterface
Interface IMMDeviceCollection Extends IUnknown
GetCount(*cDevices)
Item(nDevice.i, *pDevice)
EndInterface
Interface IMMDevice Extends IUnknown
Activate(iid, dwClsCtx.l, *pActivationParams, *ppInterface)
OpenPropertyStore(stgmAccess.l, *pProperties)
GetId()
GetState()
EndInterface
Interface IPropertyStore Extends IUnknown
GetCount(*cProps)
GetAt(iProp.l, *key)
GetValue(key, *v)
SetValue(key, propvar)
Commit()
EndInterface
DataSection
IAudioEndpointVolume:
Data.l $5CDF2C82
Data.w $841E,$4546
Data.b $97,$22,$0C,$F7,$40,$78,$22,$9A
MMDeviceEnumerator:
Data.l $BCDE0395
Data.w $E52F,$467C
Data.b $8E,$3D,$C4,$57,$92,$91,$69,$2E
IMMDeviceEnumerator:
Data.l $A95664D2
Data.w $9614, $4F35
Data.b $A7,$46,$DE,$8D,$B6,$36,$17,$E6
;https://doxygen.reactos.org/d2/d1f/mmdeviceapi_8idl_source.html
IMMDeviceCollection:
Data.l $0bd7a1be
Data.w $7a1a,$44db
Data.b $83,$97,$cc,$53,$92,$38,$7b,$5e
;https://doxygen.reactos.org/d8/dbf/propsys_8idl_source.html
IPropertyStore:
Data.l $886d8eeb
Data.w $8cf2,$4446
Data.b $8d,$02,$cd,$ba,$1d,$bd,$cf,$99
PKEY_Device_FriendlyName:
Data.l $a45c254e
Data.w $df1c,$4efd
Data.b $80,$20,$67,$d1,$46,$a8,$50,$e0
EndDataSection
Define deviceEnumerator.IMMDeviceEnumerator
Define deviceCollection.IMMDeviceCollection
Define device.IMMDevice
Define endpointVolume.IAudioEndpointVolume
Define *props.IPropertyStore
Define MuteState.i, Count.i, i.i
Define v.propvariant
CoInitialize_(#Null)
CoCreateInstance_(?MMDeviceEnumerator, 0, 1, ?IMMDeviceEnumerator, @deviceEnumerator)
If deviceEnumerator
deviceEnumerator\EnumAudioEndpoints(#eCapture, #DEVICE_STATE_ACTIVE, @deviceCollection)
If deviceCollection
deviceCollection\GetCount(@Count)
Debug Count
For i = 0 To Count - 1
deviceCollection\Item(i, @device)
If device
device\OpenPropertyStore(#STGM_READ, @*props)
If *props
*props\GetValue(?PKEY_Device_FriendlyName, @v)
Debug v\p\bstrVal
Debug PeekS(v\p\bstrVal)
EndIf
device\Release()
EndIf
Next i
deviceCollection\Release()
EndIf
;deviceEnumerator\GetDefaultAudioEndpoint(0, 0, @device)
deviceEnumerator\Release()
If device
device\Activate(?IAudioEndpointVolume, 1, 0, @endpointVolume)
device\Release()
If endpointVolume
endpointVolume\GetMute(@MuteState)
Debug MuteState
If MessageRequester("Mute", "Mute On?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
endpointVolume\SetMute(#True, #Null)
endpointVolume\GetMute(@MuteState)
Debug MuteState
If MessageRequester("Mute", "Mute Off?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
endpointVolume\SetMute(#False, #Null)
endpointVolume\GetMute(@MuteState)
Debug MuteState
EndIf
EndIf
endpointVolume\Release()
EndIf
EndIf
EndIf
CoUninitialize_()