⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tv.cpp

📁 【内容简介】 本书由一流的权威撰写
💻 CPP
字号:
#include <windows.h>
#include <iostream.h>
#include "../MyVcr/MyVcr.h"
#include "../MyVcr/MyVcr_i.c"
#include "../ComponentVcr/ComponentVCR.h"
#include "../ComponentVcr/ComponentVCR_i.c"

void UseCVideo(IComponentVideo* pSVideo);

void DumpError(HRESULT hr)
{
	LPTSTR pszErrorDesc = NULL;

	DWORD dwCount  = ::FormatMessage(
		FORMAT_MESSAGE_ALLOCATE_BUFFER |
			FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		hr,
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
		reinterpret_cast<LPTSTR>(&pszErrorDesc),
		0,
		NULL);

	if (0 == dwCount) {
		cout << "Unknown HRESULT: " << hex << hr << endl;
		return;
	}

	cout << pszErrorDesc << " (0X" << hex << hr << ")" << endl;
	LocalFree(pszErrorDesc);
}
	
int main(int argc, char* argv[])
{
	::CoInitialize(NULL);
	IComponentVideo* pCVideo = NULL;
	HRESULT hr = ::CoCreateInstance(CLSID_Vcr, NULL, CLSCTX_ALL, IID_IComponentVideo,
		reinterpret_cast<void**>(&pCVideo));
	if (FAILED(hr)) {
		DumpError(hr);
		::CoUninitialize();
		return 1;
	}

	UseCVideo(pCVideo);

	pCVideo->Release();

	::CoUninitialize();
	return 0;
}

void UseCVideo(IComponentVideo* pCVideo)
{
	long val;
	HRESULT hr;
	for(int i=0; i<10; i++) {
		hr = pCVideo->GetCVideoSignalValue(&val);
		if (FAILED(hr)) {
			DumpError(hr);
			continue;
		}
		cout << "Round: " << i << " - Value: " << val << endl;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -