Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ directshow dll help

C++ directshow dll help

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpjsonquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boyindie
    wrote on last edited by
    #1

    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 library

    class 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)
    #endif

    BOOL APIENTRY DllMain( HMODULE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
    )
    {
    return TRUE;
    }

    #ifdef _MANAGED
    #pragma managed(pop)
    #endif

    VideoCapture::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
    
    M 1 Reply Last reply
    0
    • B boyindie

      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 library

      class 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)
      #endif

      BOOL APIENTRY DllMain( HMODULE hModule,
      DWORD ul_reason_for_call,
      LPVOID lpReserved
      )
      {
      return TRUE;
      }

      #ifdef _MANAGED
      #pragma managed(pop)
      #endif

      VideoCapture::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
      
      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups