C++/VB - Custom interface in source filter

Asked By Tomy
10-Apr-07 08:14 AM
Hi

I`ve qestion about implement custom interface in source filter
class myclass : public CSource
{
.
.
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
.
.
};

class CVCamStream :public custom_class, public CSourceStream, public
IAMStreamConfig, public IKsPropertySet
{
public:
.
.
STDMETHODIMP my_custom_function(void)
{
return NOERROR;
}

.
.
};
compilation OK

I tried to implement STDMETHODIMP my_custom_function(void) in myclass

class myclass :public custom_class, public CSource
{
.
.
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
STDMETHODIMP my_custom_function(void)
{
return NOERROR;
}


.
.
};

but It can`t compile properly:

error C2259: 'myclass' : cannot instantiate abstract class
due to following members:
'ULONG IUnknown::AddRef(void)' : is abstract
c:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\include\unknwn.h(117) : see declaration of 'IUnknown::AddRef'
'ULONG IUnknown::Release(void)' : is abstract
c:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\include\unknwn.h(119) : see declaration of 'IUnknown::Release'

I've qestion about location of  my_custom_function(void);. Is it correct
implementation in CVCamStream ?

my custom_interface implementation is in my_custom.h flie

my_custom.h

extern "C" {

DEFINE_GUID(IID_custom_class)
0x5022190a, 0x65d9, 0x4a06, 0xb8, 0x0a, 0x28, 0xb4, 0xe7, 0x8f, 0x44,
0xa6);

DECLARE_INTERFACE_(custom_class, IUnknown)
{
STDMETHOD(my_custom_function) (THIS_
void)PURE;
};
}

I`ve problem with call to this function "my_custom_function()" from windows
application (C++ visual studio 2005 .net)

include "my_custom.h"

IBaseFilter *pVideoInputFilter;
CComQIPtr<custom_class> my_pointer(pVideoInputFilter);// pVideoInputFilter
that has already been created with CoCreateInstance
if (!my_pointer)
{
return hr;
}
my_pointer->my_custom_function();

I can`t compile my windows application. I have compiler error :

P1.cpp
C:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\include\atlcomcli.h(474) : error C2787: 'custom_class' : no GUID
has been associated with this object
AssemblyInfo.cpp
Generating Code...
Build log was saved at "file://d:\filters\new1\P1\P1\Debug\BuildLog.htm"
P1 - 1 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


Please clue me something !
Windows Server
(1)
PVideoInputFilter
(1)
STDMETHODIMP
(1)
NonDelegatingQueryInterface
(1)
IID_custom_class
(1)
QueryInterface
(1)
IUnknown
(1)
DECLARE_IUNKNOWN
(1)
  Michel Roujansky - DirectShow Consultant and Trainer replied...
10-Apr-07 09:59 AM
You are missing the DECLARE_IUNKNOWN macro in myclass. This is why
_AddRef, _Release are seen as not implemented.

Re  "'custom_class' : no GUID ", the code seems OK. Did you include
initguid.h? Try using QueryInterface on your pVideoInputFilter
interface to retrieve the custom_class pointer (using
IID_custom_class).
  Tomy replied...
12-Apr-07 04:34 AM
Hi
All "myclass" looks like:

class myclass : public CSource
{
static CUnknown * WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT *phr);
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
IFilterGraph *GetGraph() {return m_pGraph;}
};


What do you mind DECLARE_IUNKNOWN macro in myclass ?

Yes in my windows application I included initguid.h.
I Tried using QueryInterface on my pVideoInputFilter
interface to retrieve the custom_class pointer (using
IID_custom_class).

include "my_custom.h"
IBaseFilter *pVideoInputFilter;// my source filter
custom_class *custom_class pointer; // The custom pointer on the filter

hr = pVideoInputFilter->QueryInterface(IID_custom_class, (void **)
&custom_class pointer);//  return OK

but call:

hr=custom_class pointer->my_custom_function(); ;
make message : System.AccessViolationException

What is wrong ?
Create New Account
help
few seconds as it normally does under XP. Interestingly enough, it does not happen under Windows 7 on the same box no matter how hard I try. Some say it is Athlon 2, X4 620 CPU, 4 Gigs of DDR2 ram by Team Extreme. Running on Windows XP SP3. - - Programmer's Goldmine collections: http: / / preciseinfo.org Win32 Kernel Discussions Windows NT 3.51 (1) Windows XP (1) Windows 7 (1) Python (1) Linux (1) SystemTimeToFileTime (1) UNIX (1) XP (1) I'd say you can bet it is a driver causing the problem. Most likely, the difference in Windows 7 has nothing to do with Firefox, but a better driver for some piece of able to help further. Good luck, - -pa Yep. That is what I thought first. Except Windows is not trully multi-tasking system and I saw plenty of times the system is that one is a stretch. Because mouse is one of the top priority items in Windows. Well, except I am not sure what the issue is. As far as I can
be different from the default one, or what does that mean? Christian Win32 GDI Discussions Windows XP (1) Windows Server 2003 (1) PDEVMODE (1) Windows 7 (1) Adobe (1) Vista (1) IIS (1) GetDefaultPrinter (1) I recall that in the is installed at a client computer). But when the customer's app runs on their Windows 2003 server, the local printer is automatically installed on the server at login of the remote desktop session, but the same printer cannot be used (CreateDC en-us / library / ms535735.aspx What OS is the client? I'm going to assume Windows XP for now. lpszDriver - You are passing "WINSPOOL", this is correct. lpszDevice - You are passing
remaining in the security properties page. . . But where and what is it really changed in windows and where do we see those configuration files? Since the system used to work well 04 17:09:46 2007.4008406) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008406) : Event consumer provider is 04 17:09:46 2007.4008421) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008421) : Event consumer provider is 04 17:09:46 2007.4008421) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008421) : Event consumer provider is 04 17:09:46 2007.4008421) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008421) : Event consumer provider is 04 17:09:46 2007.4008500) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008500) : Event consumer provider is 04 17:09:46 2007.4008500) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008515) : Event consumer provider is 04 17:09:46 2007.4008515) : Unable to register event source 'Service Control Manager' on server ''. Error code: 6B5 (Tue Sep 04 17:09:46 2007.4008515) : Event consumer provider is
Windows 2003 Server throughput vs. Windows XP C++ / VB We have an odd situation with some of our single-threaded CPU-bound C++ programs. They run between 2 and 4 times faster on Windows XP than on windows Server 2003 on the same Xeon hyperthreading dual processor machine (we borrowed one from our IT two operating systems on it.) Even more odd, if we run a Virtual PC with Windows XP on top of the Windows 2003 Server on the same Xeon machine, the programs run faster too. There is nothing
C++ / VB Hi everyone, I see behavior which violates rules from the well-known article "Windows Features" http: / / msdn.microsoft.com / en-us / library / ms632599(VS.85).aspx I have an allows to move MDI-childs out of the MainFrame. Looks good! Since ChildFrames are popup windows now, they are owned by the Mainframe. On some user action I want to create window is created (say, with the child frame A as owner) - appears the most weird Windows behavior I've ever seen: If the topmost window is active now - a mouse click order, even behind the Mainframe! It's weird and it violates the rule from the "Windows Features": Does anybody know what's wrong with TOPMOST windows in Win32? Thanks a lot! VC MFC Discussions Windows NT 3.51 (1) Windows XP (1) Windows Vista (1) Visual Studio (1) Windows 7 (1) SendMessage (1) ChildFrames (1) PostMessage (1) Secondary