C++ directshow dll help
-
Hi I have been fighting with this for days moving from random error to random error. I am trying to write what is effectively a software driver for a decklink blackmagic capture card using the directshow api. The code I have here is basically the sample code from the MSDN website to get all the video devices on the system but I just seem to get errors everytime I try to compile this!
#pragma once
#include "stdafx.h"#define DllExport __declspec(dllexport)
#pragma comment(lib,"Strmiids.lib")//Includes the directshow libraryclass VideoCapture
{
//constructor
public:
VideoCapture(void);
void getNames();
void getDevice();
void createFilter();public:
~VideoCapture(void);};
// test.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "VideoCapture.h"
#include "dshow.h"
#include "Atlbase.h"
#include "Atlcom.h"#ifdef _MANAGED
#pragma managed(push, off)
#endifBOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}#ifdef _MANAGED
#pragma managed(pop)
#endifVideoCapture::VideoCapture(void)
{
}VideoCapture::~VideoCapture(void)
{
}
ICreateDevEnum *pDevEnum;
IEnumMoniker *pEnum =NULL;
HWND hList;
IMoniker *pMoniker = NULL;
IFilterGraph *m_pGraph=NULL;
VARIANT varName;
IPropertyBag *pPropBag = NULL;
HRESULT hr;\_\_declspec(dllexport) void \_\_cdecl getDevice() { hr = CoCreateInstance(CLSID\_SystemDeviceEnum, NULL, CLSCTX\_INPROC\_SERVER, IID\_ICreateDevEnum, reinterpret\_cast<void\*\*>(&pDevEnum)); if (SUCCEEDED(hr)) { // Create an enumerator for the video capture category. hr = pDevEnum->CreateClassEnumerator( CLSID\_VideoInputDeviceCategory, &pEnum, 0); }
}
\_\_declspec(dllexport) void \_\_cdecl getNames() { while (pEnum->Next(1, &pMoniker, NULL) == S\_OK) { hr = pMoniker->BindToStorage(0, 0, IID\_IPropertyBag, (void\*\*)(&pPropBag)); if (FAILED(hr)) { pMoniker->Release(); continue; // Skip this one, maybe the next one will work. } // Find the description or friendly name. VariantInit(&varName); hr = pPropBag->Read(L"Description", &varName, 0); if (FAILED(hr)) { hr = pPropBag->Read(L"FriendlyName", &varName, 0); } if (SUCCEEDED(hr)) { // Add it to the application's li
-
Hi I have been fighting with this for days moving from random error to random error. I am trying to write what is effectively a software driver for a decklink blackmagic capture card using the directshow api. The code I have here is basically the sample code from the MSDN website to get all the video devices on the system but I just seem to get errors everytime I try to compile this!
#pragma once
#include "stdafx.h"#define DllExport __declspec(dllexport)
#pragma comment(lib,"Strmiids.lib")//Includes the directshow libraryclass VideoCapture
{
//constructor
public:
VideoCapture(void);
void getNames();
void getDevice();
void createFilter();public:
~VideoCapture(void);};
// test.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "VideoCapture.h"
#include "dshow.h"
#include "Atlbase.h"
#include "Atlcom.h"#ifdef _MANAGED
#pragma managed(push, off)
#endifBOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}#ifdef _MANAGED
#pragma managed(pop)
#endifVideoCapture::VideoCapture(void)
{
}VideoCapture::~VideoCapture(void)
{
}
ICreateDevEnum *pDevEnum;
IEnumMoniker *pEnum =NULL;
HWND hList;
IMoniker *pMoniker = NULL;
IFilterGraph *m_pGraph=NULL;
VARIANT varName;
IPropertyBag *pPropBag = NULL;
HRESULT hr;\_\_declspec(dllexport) void \_\_cdecl getDevice() { hr = CoCreateInstance(CLSID\_SystemDeviceEnum, NULL, CLSCTX\_INPROC\_SERVER, IID\_ICreateDevEnum, reinterpret\_cast<void\*\*>(&pDevEnum)); if (SUCCEEDED(hr)) { // Create an enumerator for the video capture category. hr = pDevEnum->CreateClassEnumerator( CLSID\_VideoInputDeviceCategory, &pEnum, 0); }
}
\_\_declspec(dllexport) void \_\_cdecl getNames() { while (pEnum->Next(1, &pMoniker, NULL) == S\_OK) { hr = pMoniker->BindToStorage(0, 0, IID\_IPropertyBag, (void\*\*)(&pPropBag)); if (FAILED(hr)) { pMoniker->Release(); continue; // Skip this one, maybe the next one will work. } // Find the description or friendly name. VariantInit(&varName); hr = pPropBag->Read(L"Description", &varName, 0); if (FAILED(hr)) { hr = pPropBag->Read(L"FriendlyName", &varName, 0); } if (SUCCEEDED(hr)) { // Add it to the application's li
What's in your stdafx.h file? You also shouldn't be including stdafx.h in your VideoCapture.h file if stdafx.h is used for a pre-compiled header. Mark