title: using DirectShow in Winforms
body: <p>i could run the <a href="http://msdn.microsoft.com/en-us/library/ms783787.aspx" rel="nofollow noreferrer">How To Play a File</a> code sample in c++ win32 console application, but when i try to implement it by winforms i get these Link errors:</p>
  <p>Error 2 error LNK2020: unresolved token (0A000016) IID_IMediaEvent</p>
  <p>Error 3 error LNK2020: unresolved token (0A000017) IID_IMediaControl</p>
  <p>and some more link errors .....</p>
  <p>here is the code of the form:</p>
  <pre><code>#include &lt;dshow.h&gt;
  #pragma comment(lib, &quot;Strmiids.lib&quot;)
  
  namespace Form1 {
  
      using namespace System;
      using namespace System::ComponentModel;
      using namespace System::Collections;
      using namespace System::Windows::Forms;
      using namespace System::Data;
      using namespace System::Drawing;
  
      /// &lt;summary&gt;
      /// Summary for Form1
      /// &lt;/summary&gt;
      public ref class Form1 : public System::Windows::Forms::Form
      {
      public:
          Form1(void)
          {
              InitializeComponent();
              //
              //TODO: Add the constructor code here
              //
          }
  
      protected:
          /// &lt;summary&gt;
          /// Clean up any resources being used.
          /// &lt;/summary&gt;
          ~Form1()
          {
              if (components)
              {
                  delete components;
              }
          }
  
      private:
          /// &lt;summary&gt;
          /// Required designer variable.
          /// &lt;/summary&gt;
          System::ComponentModel::Container ^components;
  
  #pragma region Windows Form Designer generated code
          /// &lt;summary&gt;
          /// Required method for Designer support - do not modify
          /// the contents of this method with the code editor.
          /// &lt;/summary&gt;
          void InitializeComponent(void)
          {
              this-&gt;SuspendLayout();
              // 
              // Form1
              // 
              this-&gt;AutoScaleDimensions = System::Drawing::SizeF(6, 13);
              this-&gt;AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
              this-&gt;ClientSize = System::Drawing::Size(284, 262);
              this-&gt;Name = L&quot;Form1&quot;;
              this-&gt;Text = L&quot;Form1&quot;;
              this-&gt;Load += gcnew System::EventHandler(this, &amp;Form1::Form1_Load);
              this-&gt;ResumeLayout(false);
  
          }
  #pragma endregion
  private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
  {
   IGraphBuilder *pGraph = NULL;
      IMediaControl *pControl = NULL;
      IMediaEvent   *pEvent = NULL;
  
      // Initialize the COM library.
      HRESULT hr = CoInitialize(NULL);
  
      // Create the filter graph manager and query for interfaces.
      hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                          IID_IGraphBuilder, (void **)&amp;pGraph);
  
      hr = pGraph-&gt;QueryInterface(IID_IMediaControl, (void **)&amp;pControl);
      hr = pGraph-&gt;QueryInterface(IID_IMediaEvent, (void **)&amp;pEvent);
  
      // Build the graph. IMPORTANT: Change this string to a file on your system.
      hr = pGraph-&gt;RenderFile(L&quot;C:\\Example.avi&quot;, NULL);
      if (SUCCEEDED(hr))
      {
          // Run the graph.
          hr = pControl-&gt;Run();
          if (SUCCEEDED(hr))
          {
              // Wait for completion.
              long evCode;
              pEvent-&gt;WaitForCompletion(INFINITE, &amp;evCode);
  
              // Note: Do not use INFINITE in a real application, because it
              // can block indefinitely.
          }
      }
      pControl-&gt;Release();
      pEvent-&gt;Release();
      pGraph-&gt;Release();
      CoUninitialize();
  }
  };
  }
  </code></pre>
  <p>How can i setup the build environment in winforms to do the DirectShow programming?
  im using windows SDK v7.1 And vc++ 2010</p>