How should I use WMPEqualizerSettingsCtrlClass in C#?

935 views Asked by At

I use the following code:

WMPEqualizerSettingsCtrl eq = null;
eq.enhancedAudio = true;

But I get an error:

Object reference not set to an instance of an object.

1

There are 1 answers

2
Cody Gray - on strike On

Yes, you've set the eq object equal to null when declaring it. That is what produces the exception: you can't set the properties of an object that doesn't exist!

If you want to create an instance of the WMPEqualizerSettingsCtrl class, just use new:

WMPEqualizerSettingsCtrl eq = new WMPEqualizerSettingsCtrl();
eq.enhancedAudio = true;   // now eq exists, so it won't throw an exception!

I don't know exactly what the WMPEqualizerSettingsCtrl class is, but you might need to pass some parameters to the constructor. Those provide the class with additional information about exactly how you want it to be created.