Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5934219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:05:01+00:00 2026-05-22T15:05:01+00:00

I just wrote a simple DirectShow Filter (which inherits from CTransformFilter). But I want

  • 0

I just wrote a simple DirectShow Filter (which inherits from CTransformFilter).

But I want to be able to set a variable of my filter dynamically. 
This can be done today using Property Page. 
But what i want is change this property programatically. 

I defined a custom COM interface to set a variable in the filter but can not figure out how to use it -access it…

How to set a DirectShow filter's properties value without open the 
filter's property page ?

Any one has idea?

More Details:

Well

i) Firt i just defined simple interface

DEFINE_GUID(IID_IApplyFilterControl,  X, X, X, X, X, X, X, X, X, X, X);


interface IApplyFilterControl : public IUnknown
{
    STDMETHOD(SetWillApplyFilterX)(bool applyFilter) = 0;
};

ii) Then in my Filter C++ Code i implement this interface

class MyFilter : public CTransformFilter , public IApplyFilterControl 
{
    ....
    STDMETHODIMP SetWillApplyFilter(bool apply)
    {
        CAutoLock lock(&m_csShared);
        willApplyFilter = apply;
        return S_OK;

    }
    ...

}

iii) In my C# Code (using DirectShowNet)

I want to able to access my filter

IBaseFilter myFilter = 
(IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(myFilterGuid));
....
IApplyFilterControl filterControl = (IApplyFilterControl ) myFilter;
.....

filterControl->SetWillApplyFilter(true)

Finally I Fix It

Take the advice of yms and use hints from the link :
Some advices about custom filters

Source: http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/e02aa741-776c-42cf-869f-640747e197e4

i) Your COM Interface

// The GUID that identifies your interface
// {13F23FD9-A90C-480d-A597-F46BA20070AC}

static const GUID IIDTransformFilterControl =

{
      0x13f23fd9, 0xa90c, 0x480d, { 0xa5, 0x97, 0xf4, 0x6b, 0xa2, 0x0, 0x70, 0xac }
};

DECLARE_INTERFACE_(ITransformFilterControl, IUnknown)

{
    STDMETHOD(setGreyscale)(bool enable) = 0;
};

ii) Your transform Filter

class YourTransformFilter : 
public CTransformFilter, public ITransformFilterControl

{
    public:
    STDMETHODIMP    NonDelegatingQueryInterface(REFIID riid, void **ppv);
    STDMETHODIMP    setGreyscale(bool enable);
};

….

STDMETHODIMP  YourTransformFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv)

{
    CheckPointer(ppv, E_POINTER);

    if(riid==IIDTransformFilterControl)   
      return GetInterface((ITransformFilterControl*) this, ppv);

    return CTransformFilter::NonDelegatingQueryInterface(riid, ppv);
}

STDMETHODIMP  YourTransformFilter:: setGreyscale(bool enable)

{
    bGreyscale    = enable;
    return S_OK;
}

iii) Finally In your C# host application Define COM Interface

[ComImport, System.Security.SuppressUnmanagedCodeSecurity, 
Guid("13F23FD9-A90C-480d-A597-F46BA20070AC"), 
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

public interface ITransformControl

{
        [PreserveSig]
        int setGreyscale(bool enable);
}

iv) And Use in your C# code

ITransformFilterControl transformControl = 
     yourFilterInstance as ITransformFilterControl;

if(transformControl!=null)

{
    transformControl->setGreyscale(true);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:05:02+00:00Added an answer on May 22, 2026 at 3:05 pm

    If you defined a COM interface to access your filter, all you need to do now is to declare the same interface (using the same GUIs) in C#/VB.Net or whatever .net language you are using. Then you can do a type cast of your filter to the new interface. Here is a C# example on how to declare such an interface:

    using System.Runtime.InteropServices;
    
    // Declare IMediaControl as a COM interface which 
    // derives from the IDispatch interface. 
    [Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"),
        InterfaceType(ComInterfaceType.InterfaceIsDual)] 
    interface IMediaControl // cannot list any base interfaces here 
    { 
        // Note that the members of IUnknown and Interface are NOT
        // listed here 
        //
        void Run();
    
        void Pause();
    
        void Stop();
    
        void GetState( [In] int msTimeout, [Out] out int pfs);
    
        void RenderFile(
        [In, MarshalAs(UnmanagedType.BStr)] string strFilename);
    
        void AddSourceFilter(
        [In, MarshalAs(UnmanagedType.BStr)] string strFilename, 
        [Out, MarshalAs(UnmanagedType.Interface)] out object ppUnk);
    
        [return : MarshalAs(UnmanagedType.Interface)]
        object FilterCollection();
    
        [return : MarshalAs(UnmanagedType.Interface)]
        object RegFilterCollection();
    
        void StopWhenReady(); 
    }
    

    EDIT:

    About the issue with E_NOINTERFACE during casting, it looks like a threading problem.
    1- Creating your filter with Activator is not a good idea, you should always allow your DS graph to create your filters, try using “enumarate filters” instead.
    2- Verify that the treading model you are using for your filter is “Both”.Read here and here for some more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a simple web service in C# using SharpDevelop (which I just got
I just wrote a very simple Expect script for wrapping around rsync, but it
I'm trying to write a simple program in VC++ which will just initialize the
I just want a simple tool that will help me quickly write scripts/packages that
I just wrote my first OpenMP program that parallelizes a simple for loop. I
I just wrote php daemon for my app and want to implement some output
I wrote this simple program today, but I found that cin.get() refuses to work
Right now I'm getting this exception from a simple JMS client I wrote to
I created c++ dll (using mingw) from code I wrote on linux (gcc), but
I wrote a simple html file with just a javascript function. It worked in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.