[wdmaudiodev] Re: IKsControl

  • From: Matthew van Eerde <mateer@xxxxxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 4 Feb 2010 16:53:39 +0000

The non-deprecated Vista-and-further way to get an IKsControl is to call 
IMMDevice::Activate(...) on an adapter IMMDevice.  Sample here:

Using the IKsControl Interface to Access Audio Properties

What OS are you running on?

From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Mark Walker
Sent: Thursday, February 04, 2010 8:44 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: IKsControl

Tim, yes I'm using the Windows SDK.  I think I need to get a copy of VC++ with 
ATL before I try this any further. Express seems to have a history of weird 
definition and include problems.  I mainly use Express because people I deal 
with use Express and I don't want to be out of sync.

For what it's worth this is my code.  It builds if I kludge it, but it fails at 
pBaseFilter->QueryInterface returning hr = E_NOINTERFACE for all my devices.  
It's not that big a deal in my project at this point, so I'm not too worried 
about it.


    HRESULT hr;
    ICreateDevEnum *pDeviceEnum = NULL;

    hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
        CLSCTX_INPROC_SERVER,IID_ICreateDevEnum, (void **)&pDeviceEnum);

void enumDevices(GUID DEVICE_CLSID,ICreateDevEnum *pDeviceEnum )
        HRESULT hr;
        IMoniker *pDeviceMonik = NULL;
        IEnumMoniker *pEnumCat = NULL;
        VARIANT varName;

        hr = pDeviceEnum->CreateClassEnumerator(DEVICE_CLSID, &pEnumCat, 0);
        if (hr == S_OK)
            ULONG cFetched;
            while (pEnumCat->Next(1, &pDeviceMonik, &cFetched) == S_OK)
                IPropertyBag *pPropBag = NULL;
                hr = pDeviceMonik->BindToStorage(0, 0, IID_IPropertyBag,(void 
                if (SUCCEEDED(hr))
                    hr = pPropBag->Read(L"FriendlyName", &varName, 0);
                      if (SUCCEEDED(hr))
                        IBaseFilter * pBaseFilter;
                        hr = pDeviceMonik->BindToObject(NULL, NULL,  
                        IKsControl *pControl;
                        hr = pBaseFilter->QueryInterface(IID_IKsControl, (void 
**) &pControl);
                else HR_Failed(hr);
        else HR_Failed(hr);


On 2/3/2010 10:30 AM, Tim Roberts wrote:
Mark Walker wrote:
Thanks Tim & Matthew for responding.
In reference to NTDDI_VERSION >= NTDDI_WINXP I'm writing a user mode 
application that us attempting to access special features of an audio driver.  
Is NTDDI_VERSION  relevant for  user mode applications?  The driver I'm trying 
to reach targets XP and above, though.

I tried ksproxy.h as well, but it doesn't build.  I kludged ksproxy.h to get 
rid of some defines and it built, but it still doesn't give me a good pointer 
when I run it.  Do I have to explicitly expose IKsControl to user mode 
applications in my driver?

You should not need to kludge it.  This compiles for me as-is:
#include <windows.h>
#include <initguid.h>
#include <ks.h>
#include <ksmedia.h>
#include <ksproxy.h>
int main() { IKsControl * ptr = NULL;  return 0; }

You are using the SDK and not the DDK, right?

You do not need to expose IKsControl.  Ksproxy will do that for you.  How are 
you acquiring the device?  Are you using CLSID_SystemDeviceEnum to get the 
IBaseFilter instance?


Tim Roberts, timr@xxxxxxxxx<mailto:timr@xxxxxxxxx>

Providenza & Boekelheide, Inc.

Other related posts: