问题描述
我是 Window 和 DirectShow 开发的新手。我正在关注官方文档。
我想测试和使用他们在 https://docs.microsoft.com/en-us/windows/win32/directshow/how-to-play-a-file 中给出的示例代码,但出现错误。
代码是:
#include <dshow.h>
void main(void)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (Failed(hr))
{
printf("ERROR - Could not initialize COM library");
return;
}
// Create the filter graph manager and query for interfaces.
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);
// Build the graph. IMPORTANT: Change this string to a file on your system.
hr = pGraph->RenderFile(L"C:\\Example.avi",NULL);
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE,&evCode);
// Note: Do not use INFINITE in a real application,because it
// can block indefinitely.
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}
错误是:
Warning C4326 return type of 'main' should be 'int' instead of 'void' Project1 C:\Users\alok\source\repos\Project1\Project1\Source.cpp 3
Error LNK2001 unresolved external symbol _IID_IGraphBuilder Project1 C:\Users\alok\source\repos\Project1\Project1\Source.obj 1
Error LNK2001 unresolved external symbol _IID_IMediaControl Project1 C:\Users\alok\source\repos\Project1\Project1\Source.obj 1
Error LNK2001 unresolved external symbol _IID_IMediaEvent Project1 C:\Users\alok\source\repos\Project1\Project1\Source.obj 1
Error LNK2001 unresolved external symbol _CLSID_Filtergraph Project1 C:\Users\alok\source\repos\Project1\Project1\Source.obj 1
Error LNK1120 4 unresolved externals Project1 C:\Users\alok\source\repos\Project1\Debug\Project1.exe 1
IDE 的详细信息:
Microsoft Visual Studio Community 2019
Version 16.4.5
VisualStudio.16.Release/16.4.5+29806.167
Microsoft .NET Framework
Version 4.8.03761
Installed Version: Community
Visual C++ 2019 00435-60000-00000-AA810
Microsoft Visual C++ 2019
ASP.NET and Web Tools 2019 16.4.460.23317
ASP.NET and Web Tools 2019
C# Tools 3.4.1-beta4-19614-01+165046097562cfe65b09c2e9a9d8f7cd88526f2c
C# components used in the IDE. Depending on your project type and settings,a different version of the compiler may be used.
intellicode Extension 1.0
intellicode Visual Studio Extension Detailed Info
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
NuGet Package Manager 5.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet,visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
Visual Basic Tools 3.4.1-beta4-19614-01+165046097562cfe65b09c2e9a9d8f7cd88526f2c
Visual Basic components used in the IDE. Depending on your project type and settings,a different version of the compiler may be used.
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)