Original Post
ok i have tis code :
void playMovie()
{
OPENFILENAME ofn;
static char szFile[1024];
static char szFileTitle[1024];
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = "Movie Files\0*.avi;*.mpeg;*.mpg;*.asf;*.divx;*.dat\0\0";
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
GetOpenFileName(&ofn);
IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IVideoWindow *pVidWin = NULL;
IMediaEvent *pEvent;
CoInitialize(NULL);
// 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);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// Build the graph.
HRESULT a=pGraph->RenderFile(LPCWSTR(ofn.lpstrFile), NULL);
//Set the video window.
pVidWin->put_WindowStyle(WS_BORDER|WS_SIZEBOX);
pVidWin->put_WindowStyle(WS_POPUPWINDOW|WS_BORDER|WS_SIZEBOX);
pVidWin->SetWindowPosition(0, 0, 640,480);
// Run the graph.
pMediaControl->Run();
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Clean up.
pVidWin->put_Owner(NULL);
pMediaControl->Release();
pEvent->Release();
pGraph->Release();
pVidWin->Release();
}
When i call it it opens the open file window...i open a file , but direct show doesn`t play it . I discovered that the problem is at
HRESULT a=pGraph->RenderFile(LPCWSTR(ofn.lpstrFile), NULL);
Actualy the hresult error code tells me that the file cannot be found. I concluded that it`s something wrong with the conversion.
How must i convert the LPSTR field ofn.lpstrFile to LPCWSTR for the function to work??
Popa Razvan Dragos