I am trying to migrate PlayCap from the microsoft SDK from C++ to C++ CLR.
Currently I keep getting LNK2020 and LNK2001 on the directshow classes.
public ref class Form1 : public System::Windows::Forms::Form
{
public:
static IVideoWindow * DC_VW = NULL;
static IMediaControl *DC_MC = NULL;
static IMediaEventEx *DC_ME = NULL;
static IGraphBuilder *DC_GB = NULL;
static ICaptureGraphBuilder2 * DC_CGB2 = NULL;
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Panel^ panel1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(136, 324);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(217, 53);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// panel1
//
this->panel1->Location = System::Drawing::Point(37, 31);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(444, 269);
this->panel1->TabIndex = 1;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(511, 389);
this->Controls->Add(this->panel1);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
HRESULT hr;
IBaseFilter *DC_SF = NULL;
hr = GetInterfaces();
if(FAILED(hr))
{
int x = ::MessageBox(NULL, (LPCWSTR)L"Failed to get interfaces. hr=0x%x", (LPCWSTR)L"OK", MB_OK);
}
hr = DC_CGB2->SetFiltergraph(DC_GB);
if(FAILED(hr))
{
int x = ::MessageBox(0, (LPCWSTR)L"failed to set filter graph hr=0x%x", (LPCWSTR)L"OK", MB_OK);
}
//hr = FindCaptureDevice(&DC_SF);
}
private: HRESULT GetInterfaces(void)
{
HRESULT hr;
void* Temp;
hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **) &Temp);
DC_GB = (IGraphBuilder*)Temp;
if(FAILED(hr))
{
return hr;
}
hr = CoCreateInstance (CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void **)&Temp);
DC_CGB2 = (ICaptureGraphBuilder2*)Temp;
if(FAILED(hr))
return hr;
hr = DC_GB->QueryInterface(IID_IMediaControl, (LPVOID*) &Temp);
DC_MC = (IMediaControl*)Temp;
if(FAILED(hr))
return hr;
hr = DC_GB->QueryInterface(IID_IVideoWindow, (LPVOID*) &Temp);
DC_VW = (IVideoWindow*)Temp;
if(FAILED(hr))
return hr;
hr = DC_GB->QueryInterface(IID_IMediaEventEx, (LPVOID*) &Temp);
DC_ME = (IMediaEventEx*)Temp;
if(FAILED(hr))
return hr;
hr = DC_ME->SetNotifyWindow(panel1->Handle.ToInt64(), WM_APP+1, 0);
return hr;
}
};
That is pretty much the jist of the PlayCap code so far, except i had to move the declarations and make them static.
i keep getting
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000012) IID_IMediaEventEx
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000013) IID_IVideoWindow
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000014) IID_IMediaControl
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000016) CLSID_CaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000017) IID_ICaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000018) CLSID_FilterGraph
1>DirectshowC++.obj : error LNK2020: unresolved token (0A000019) IID_IGraphBuilder
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IMediaEventEx
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IVideoWindow
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IMediaControl
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_ICaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2001: unresolved external symbol CLSID_CaptureGraphBuilder2
1>DirectshowC++.obj : error LNK2001: unresolved external symbol IID_IGraphBuilder
1>DirectshowC++.obj : error LNK2001: unresolved external symbol CLSID_FilterGraph
All of them are in the strmif.h header file, it finds the file and them but idk what is up with the linker errors
You might want to link against strmiids.lib and strmbase.lib.