这是什么错误?答对者马上给分! IVideoWindow 的GUID 没有被初始化,maybe 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DWORD_PTR 是那里定义的啊? 还是检查一下程序吧.我给一个例子:#include <windows.h>#include <dshow.h>#define CLASSNAME "VideoWindow"IGraphBuilder *pGraph = NULL;IMediaControl *pMediaControl = NULL;IVideoWindow *pVidWin;// = NULL;HWND g_hwnd;void PlayFile(void){ // Create the filter graph manager. CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGraph); pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl); pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin); // Build the graph. pGraph->RenderFile(L"G:\\share\\clock.mpg", NULL); //Set the video window. pVidWin->put_Owner((OAHWND)g_hwnd); pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT grc; GetClientRect(g_hwnd, &grc); pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph. pMediaControl->Run();}void CleanUp(void){ pVidWin->put_Visible(OAFALSE); pVidWin->put_Owner(NULL); pMediaControl->Release(); pVidWin->Release(); pGraph->Release();}// Message handler.long FAR PASCAL WindowProc( HWND hwnd, UINT msg, UINT wParam, LONG lParam){ switch (msg) { case WM_DESTROY: CleanUp(); PostQuitMessage(0); break; default: return (DefWindowProc(hwnd, msg, wParam, lParam)); } return(NULL);}// Main.int PASCAL WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow ){ MSG msg; WNDCLASS wc; CoInitialize(NULL); ZeroMemory(&wc, sizeof wc); wc.lpfnWndProc = WindowProc; wc.hInstance = hInst; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); wc.lpszMenuName = NULL; wc.lpszClassName = CLASSNAME; RegisterClass( &wc ); g_hwnd = CreateWindow( CLASSNAME, "DirectShow Sample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL); ShowWindow( g_hwnd, nCmdShow ); UpdateWindow( g_hwnd ); PlayFile(); while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } CoUninitialize(); return msg.wParam;} GetDibits使用异常 我自己的UDP程序在有线的时候可以,但是无线的时候不行,怎么回事 问个VC6 IDE的问题! 我想扩展CFileDialog老预览图象文件?大家指点一下,给点思路 (在线等待!)怎样判断一个双精度类型是否有小数点 关于Combo Box的问题? 急问:程序退出时发生异常!! 模板类的使用问题 求解一种线程同步方式 请问用什么api函数可以对快捷方式操作,比如创建快捷方式,删除快捷方式,查找快捷方式等! Help!About Codec 请问VC中如何将某一子窗口的close按钮置灰?多谢!
我给一个例子:
#include <windows.h>
#include <dshow.h>#define CLASSNAME "VideoWindow"IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IVideoWindow *pVidWin;// = NULL;
HWND g_hwnd;void PlayFile(void)
{
// Create the filter graph manager.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGraph);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin); // Build the graph.
pGraph->RenderFile(L"G:\\share\\clock.mpg", NULL); //Set the video window.
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT grc;
GetClientRect(g_hwnd, &grc);
pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph.
pMediaControl->Run();
}void CleanUp(void)
{
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
pMediaControl->Release();
pVidWin->Release();
pGraph->Release();
}// Message handler.
long FAR PASCAL WindowProc( HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{
switch (msg)
{
case WM_DESTROY:
CleanUp();
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
return(NULL);
}// Main.
int PASCAL WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine,
int nCmdShow )
{
MSG msg;
WNDCLASS wc; CoInitialize(NULL); ZeroMemory(&wc, sizeof wc);
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInst;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = CLASSNAME;
RegisterClass( &wc ); g_hwnd = CreateWindow(
CLASSNAME,
"DirectShow Sample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInst,
NULL); ShowWindow( g_hwnd, nCmdShow );
UpdateWindow( g_hwnd );
PlayFile(); while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
} CoUninitialize();
return msg.wParam;
}