2

In visual community 2015 I have a c++ project. In the cpp file top I have

#include "stdafx.h"
#include "VideoCaptureFilterSample.h"
#include "VideoCaptureFilterSampleDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

I also set when entering the project properties > VC++ Directories I added this directory in include: C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses

The problem is when I type in my code this:

hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER,
        IID_PPV_ARGS(&pGrabberF));

The CLSID_SampleGrabber not defined.

What I tried so far ? Downloaded directx sdk 9 and 6 and Microsoft sdk 7.1 and searched in google for qedit.h but I didn't find the file. Can't figure out how to define the CLSID_SampleGrabber

2 Answers2

3

CLSID_SampleGrabber was removed from Windows SDK long ago, you need as old as version 6.1 Windows SDK to find the declaration. The implementation was removed from Windows operating system only recently (Windows Server 2012?).

You can get it back to your project following this example:

#pragma region Re-Adding Removed from Windows SDK qedit.h

struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
ISampleGrabberCB : IUnknown

...

struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37"))
SampleGrabber;
    // [ default ] interface ISampleGrabber

...

CComPtr<IBaseFilter> pSgBaseFilter;
ATLENSURE_SUCCEEDED(pSgBaseFilter.CoCreateInstance(__uuidof(SampleGrabber)));

Linking amstrmid.lib is a good hint, but you almost never need CLSID_SampleGrabber alone, you also need ISampleGrabber and friends as well, and the library still hosting (as a side effect) the GUIDs don't get you that.

See also:

Roman R.
  • 68,205
  • 6
  • 94
  • 158
1

Declare it as follows: extern "C" { extern GUID CLSID_SampleGrabber; }

Then be sure to link to amstrmid.lib. You can grep the symbol out of the libs directories, in case you need others.

I didn't test this completely as I didn't have the dshow sample files handy, but when I debugged it, it had resolved to c1f400a0-3f08-11d3-9f0b-006008039e37 or something like that; you can now find a lot more about it if you google for the first part of that GUID: sometimes with magic guids all you need is a tiny hook and then you can dig up the rest easily.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
zeromus
  • 1,648
  • 13
  • 14
  • @Roman R 's is probably the better answer, but I swear, I had that GUID right the first time. It doesn't really matter, but mine was different for some reason. – zeromus Apr 14 '16 at 05:01
  • Your CLSID was about right, I just updated it to be exactly correct. And everything else is in good standing too. – Roman R. Apr 14 '16 at 05:14
  • Weird, I just found 4 different clsids from 4 different amstrmid.lib including 2 newer ones than version 6.1 windows SDK. But I've got yours in my registry. I think armstrmid.lib is garbage for this purpose and I should delete my answer, what do you think? – zeromus Apr 14 '16 at 05:29
  • Technically your answer is correct - GUIDs are still there in this .lib, even though my guess would be that they are left unintentionally or there was another reason why it was difficult or not desired to remove them. The "normal" declarations corresponding to qedit.dll and qedit.h are taken away intentionally. So, use of this .lib is okay, but as I said normally developer also needs other declarations as well. – Roman R. Apr 14 '16 at 05:35