problems implementing IAMWstDecoder COM interface in dotnet

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Henrik K (hkninmsdn_at_newsgroup.nospam)
Date: 03/16/05


Date: Wed, 16 Mar 2005 04:27:05 -0800

I'm currently trying to implement a interface to a directx teletext
filter in
dotnet.
The filter has a interface which I would like to use. The only thing I
have
is the following header file from the directx SDK:

DECLARE_INTERFACE_(IAMWstDecoder, IUnknown)
{
public:
//
// Decoder options to be used by apps
//

// What is the decoder's level
STDMETHOD(GetDecoderLevel)(THIS_ AM_WST_LEVEL *lpLevel) PURE ;

// STDMETHOD(SetDecoderLevel)(THIS_ AM_WST_LEVEL Level) PURE ;

// Which of the services is being currently used
STDMETHOD(GetCurrentService)(THIS_ AM_WST_SERVICE *lpService) PURE ;
// STDMETHOD(SetCurrentService)(THIS_ AM_WST_SERVICE Service) PURE ;

// Query/Set the service state (On/Off)
// supported state values are AM_WSTState_On and AM_WSTState_Off
STDMETHOD(GetServiceState)(THIS_ AM_WST_STATE *lpState) PURE ;
STDMETHOD(SetServiceState)(THIS_ AM_WST_STATE State) PURE ;

//
// Output options to be used by downstream filters
//

// What size, bitdepth etc should the output video be
STDMETHOD(GetOutputFormat)(THIS_ LPBITMAPINFOHEADER lpbmih) PURE ;
// GetOutputFormat() method, if successful, returns
// 1. S_FALSE if no output format has so far been defined by
downstream
filters
// 2. S_OK if an output format has already been defined by downstream
filters
STDMETHOD(SetOutputFormat)(THIS_ LPBITMAPINFO lpbmi) PURE ;

// Specify physical color to be used in colorkeying the background
// for overlay mixing
STDMETHOD(GetBackgroundColor)(THIS_ DWORD *pdwPhysColor) PURE ;
STDMETHOD(SetBackgroundColor)(THIS_ DWORD dwPhysColor) PURE ;

// Specify if whole output bitmap should be redrawn for each sample
STDMETHOD(GetRedrawAlways)(THIS_ LPBOOL lpbOption) PURE ;
STDMETHOD(SetRedrawAlways)(THIS_ BOOL bOption) PURE ;

// Specify if the caption text background should be opaque/transparent
STDMETHOD(GetDrawBackgroundMode)(THIS_ AM_WST_DRAWBGMODE *lpMode) PURE
;
STDMETHOD(SetDrawBackgroundMode)(THIS_ AM_WST_DRAWBGMODE Mode) PURE ;
// supported mode values are AM_WST_DrawBGMode_Opaque and
// AM_WST_DrawBGMode_Transparent

STDMETHOD(SetAnswerMode)(THIS_ BOOL bAnswer) PURE ;
STDMETHOD(GetAnswerMode)(THIS_ BOOL* pbAnswer) PURE ;

STDMETHOD(SetHoldPage)(THIS_ BOOL bHoldPage) PURE ;
STDMETHOD(GetHoldPage)(THIS_ BOOL* pbHoldPage) PURE ;

STDMETHOD(GetCurrentPage)(THIS_ PAM_WST_PAGE pWstPage) PURE;
STDMETHOD(SetCurrentPage)(THIS_ AM_WST_PAGE WstPage) PURE;

} ;

I've translated this to C# and it looks like follows:

[ComVisible(true), ComImport,
Guid("70bc06e0-5666-11d3-a184-00105aef9f33"),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
public interface IAMWstDecoder
{

int GetDecoderLevel([Out] out AM_WST_LEVEL lpLevel);

int setDecoderLevel([In] AM_WST_LEVEL lpLevel);

int GetCurrentService([Out] out AM_WST_SERVICE lpService);
int setCurrentService([In] AM_WST_SERVICE lpService);

int GetServiceState([Out] out AM_WST_STATE lpState);
int setServiceState([In] AM_WST_STATE State);

int GetOutputFormat([Out] out BITMAPINFOHEADER lpbmih);
        int SetOutputFormat([In] LPBITMAPINFO lpbmi);

int GetBackgroundColor([Out] out long pdwPhysColor);
int SetBackgroundColor([In] long dwPhysColor);

int GetRedrawAlways([Out] out bool lpbOption);
int SetRedrawAlways([In] bool bOption);

int GetDrawBackgroundMode([Out]out AM_WST_DRAWBGMODE lpMode);
int SetDrawBackgroundMode([In] AM_WST_DRAWBGMODE Mode);

int SetAnswerMode([In] bool bAnswer);
int getAnswerMode([Out] out bool Answer);

int SetHoldPage([In] bool bHoldPage);
int getHoldPage([Out] out bool HoldPage);

int GetCurrentPage([Out] out AM_WST_PAGE pWstPage);
int setCurrentPage([In] AM_WST_PAGE WstPage);

}

my problem is when I try to cast my filter to the interface:

           graphBuilder.FindFilterByName("WST Decoder", WSTfilter)
exception->WST = CType(WSTfilter, DShowNET.IAMWstDecoder)

 I get the
following exception:

System.InvalidCastException: Specified cast is not valid.

I don't know if this is the right group to ask this kind of question
since
I've implemented other interfaces before which were in a IDL file, and
this interface is defined in a .h file so I don't know what I've done
wrong

Thanks in advance



Relevant Pages

  • problems implementing IAMWstDecoder COM interface in dotnet
    ... The filter has a interface which I would like to use. ... STDMETHODPURE; ... STDMETHOD(THIS_ BOOL bOption) PURE; ... int setServiceState; ...
    (microsoft.public.dotnet.framework.interop)
  • Getting values from EZrgb24
    ... I am trying to get values out of the EZrgb24 COM object but i am having ... I have clearted a new part of the interface called ... PURE; ... STDMETHODIMP CEZrgb24::coordinates(int x, int y) ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Visual C++ 2005 Radio Buttons
    ... The radio control cannot be set into int. ... There is only bool exist in ... the interface. ... and post back here with a link to your bug report and I'll verify it. ...
    (microsoft.public.vc.mfc)
  • Re: First step to developing COM
    ... PRINTER* pPrinter = NULL; ... Now a much better way would be to force a common interface for printers as ... class EPSILON2: public PRINTER_INTERFACE ... STDMETHOD_PURE; ...
    (microsoft.public.vc.language)
  • Re: First step to developing COM
    ... PRINTER* pPrinter = NULL; ... Now a much better way would be to force a common interface for printers as ... class EPSILON2: public PRINTER_INTERFACE ... STDMETHOD_PURE; ...
    (microsoft.public.vc.language)