Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access denied when writing to property store #490

Open
pavlexander opened this issue Aug 27, 2024 · 0 comments
Open

access denied when writing to property store #490

pavlexander opened this issue Aug 27, 2024 · 0 comments

Comments

@pavlexander
Copy link

Hey

on windows 11, cscore v1.2.1.2 I am attempting to override the "listen to this device" checkbox property value of the recording device

    private void button1_Click(object sender, EventArgs e)
    {
        // Create the MMDeviceEnumerator COM object to interact with audio devices
        var deviceEnumerator = new MMDeviceEnumerator();

        MMDeviceCollection devices = deviceEnumerator.EnumAudioEndpoints(DataFlow.Capture, DeviceState.Active);
        var deviceID = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}";
        foreach (var deviceI in devices)
        {
            deviceID = deviceI.DeviceID;
            break;
        }

        // GetDevice using the device id
        var device = deviceEnumerator.GetDevice(deviceID);

        // Open the PropertyStore
        var propertyStore = device.PropertyStore;
        
        // Define required GUID and PID
        var checkBoxGuid = new Guid("{24DBB0FC-9311-4B3D-9CF0-18FF155639D4}");
        var checkBoxPid = 1;

        // Go through properties
        foreach (var pro in propertyStore)
        {
            var key = pro.Key;
            if (key.PropertyID != checkBoxPid)
                continue;

            if (key.ID != checkBoxGuid)
                continue;

            var val = pro.Value;
            val.BoolValue = !val.BoolValue;

            /*var val2 = new PropertyVariant();
            val2.DataType = VarEnum.VT_BOOL;
            val2.BoolValue = true;
            val2.BoolValue = !val.BoolValue;*/

            // Update the value
            propertyStore.SetValue(key, val);
            break;
        };
    }

I get the exception

CSCore.Win32.Win32ComException: 'IPropertyStore::SetValue caused an error: 0x80070005, "Access is denied.".'

in any mode (release, debug) and with Admin rights.

is there anything apparent missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant