Windows フォームアプリケーションを作成する。
ボタンをひとつ貼り付けてクリックハンドラにコードを貼り付ける
#pragma once
#include <dshow.h>
namespace aviPleayetForm {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Form1 の概要
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクター コードを追加します
//
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(13, 228);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 263);
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) {
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
// COM ライブラリを初期化する。
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return;
}
// フィルタ グラフ マネージャを作成し、インターフェイスを問い合わせる。
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// グラフを作成する。 重要 : この文字列をシステム上のファイルに置き換える。
hr = pGraph->RenderFile(L"E:\\sampleMovie\\avi_divx5_mp3.avi", NULL);
if (SUCCEEDED(hr))
{
// グラフを実行する。
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// 完了するまで待機する。
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// 注 : 実際のアプリケーションでは INFINITE を使用しないこと。
// 無期限にブロックする場合がある。
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
}
};
}
プロジェクトの変更
「プロジェクト(P)」→「***のプロパティ(P)」→「構成プロパティ」→「リンカ」→「入力」で 「追加の依存ファイル」を追加
「親またはプロジェクトの規定値から継承」 をチェック
「プロジェクト(P)」→「***のプロパティ(P)」→「構成プロパティ」→「全般」で 共通ランタイム サポートを変更
純粋MSIL共通言語ランタイム(/clr:pure) ⇒ 共通言語ランタイム(/clr)

0 件のコメント:
コメントを投稿