如何在vc ++中使用samplegrabber?未定义samplegrabber [英] How do i use samplegrabber in vc++ ? The samplegrabber is not defined

查看:101
本文介绍了如何在vc ++中使用samplegrabber?未定义samplegrabber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在视觉社区2015中,我有一个c ++项目.在cpp文件顶部,我有

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

我在输入项目属性时也进行了设置> VC ++目录,我在以下目录中添加了此目录:C:\ Program Files%28x86%29 \ Microsoft SDKs \ Windows \ v7.1 \ Samples \ multimedia \ directshow \ baseclasses

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));

未定义CLSID_SampleGrabber.

The CLSID_SampleGrabber not defined.

到目前为止,我尝试了什么?下载了DirectX SDK 9和6和Microsoft SDK 7.1,并在Google中搜索了qedit.h,但我没有找到该文件.无法弄清楚如何定义CLSID_SampleGrabber

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

推荐答案

CLSID_SampleGrabber 早已从Windows SDK中删除,您需要与

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?).

您可以按照此示例:

#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)));

链接amstrmid.lib是一个很好的提示,但是几乎不需要单独使用 CLSID_SampleGrabber ,也需要 ISampleGrabber 和朋友,并且该库仍在托管(如副作用)GUID不能帮助您.

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.

另请参阅:

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆