您现在的位置是:首页 >生活 > 2023-08-04 08:57:10 来源:
vs2008怎么运行程序(vs2008视频教程)
大家好,我是小华,我来为大家解答以上问题。vs2008怎么运行程序,vs2008视频教程很多人还不知道,现在让我们一起来看看吧!
1、这是简化代码,我这有完整的,如果要和我说下 #include class PlayCore { public: PlayCore(void); virtual ~PlayCore(void); bool SetFile(wchar_t * file_name); bool Play(); bool Stop(); bool Pause(); private: bool _IsLoadFile; IGraphBuilder *pGraph; IMediaControl *pControl; IMediaEvent *pEvent; }; PlayCore::PlayCore(void) { this->_IsLoadFile = false; // Initialize the COM library. HRESULT hr = CoInitialize(NULL); if(FAILED(hr)) { #ifdef _CONSOLE printf("error - Could not initialize COM library"); #else MessageBox(NULL,L"error - Could not initialize COM library",L"Error",MB_OK); #endif } //Create the filter graph manager and query for inter interfaces. hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder,(void **)&pGraph); if(FAILED(hr)) { #ifdef _CONSOLE printf("error - Could not create the Filter Graph Manager."); #else MessageBox(NULL,L"error - Conld not create the Filter Graph Manager.",L"Error",MB_OK); #endif } hr = pGraph->QueryInterface(IID_IMediaControl,(void **)&pControl); hr = pGraph->QueryInterface(IID_IMediaEvent,(void **)&pEvent); } PlayCore::~PlayCore(void) { this->pControl->Release(); this->pEvent->Release(); this->pGraph->Release(); CoUninitialize(); } bool PlayCore::SetFile(wchar_t *file_name) { //Build the graph. HRESULT hr = pGraph->RenderFile(file_name,NULL); if(SUCCEEDED(hr)) { this->_IsLoadFile = true; return true; } return false; } bool PlayCore::Play() { if(! this->_IsLoadFile) return false; //Run the graph. HRESULT hr = pControl->Run(); if(SUCCEEDED(hr)) { //Wait for completion. long evCode; pEvent->WaitForCompletion(1000,&evCode); //Note: Do not use INFINITE in a real application, //because it can block indefinitely. } } bool PlayCore::Pause() { pControl->Pause(); return true; } bool PlayCore::Stop() { pControl->Stop(); return true; }。
本文到此讲解完毕了,希望对大家有帮助。