這些程式碼我看不太懂
不知道有哪些好心的大大可以幫我解惑
也幫我註解一下....
#pragma comment (lib, "comctl32.lib")
#pragma comment (lib, "dxguid.lib")
#pragma comment (lib, "strmiids.lib")
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include <commctrl.h>
#include <dshow.h>
#include <cstdio>
extern"C" WINBASEAPI HWND WINAPI GetConsoleWindow();
#define MsgBox(s) MessageBox (0,s,0,MB_OK)
WCHAR e_str;
void cdecl MsgBox_ (wchar_t* fmt, ...)
{swprintf_s (e_str, 256, fmt, (char*)(&fmt+1)); MsgBox(e_str);}
namespace FileDlg
{
WCHAR title = L"*.*";
WCHAR filter =
L"AVI File (*.avi)\0*.avi\0"
L"MPEG File (*.mpg)\0*.mpg\0"
L"Mp3 File (*.mp3)\0*.mp3\0"
L"Wave File (*.wav)\0*.wav\0"
L"All Files (*.*)\0*.*\0\0";
WCHAR file_name, init_dir, exe_path={0}, *fname;
OPENFILENAME ofn = {
sizeof(OPENFILENAME), 0, 0, (LPCWSTR)filter,0,0,1, title,
512, file_name, 512, init_dir, 0, 6, 0,1, L"", 0,0,0
};
LPWSTR open (HWND hwnd)
{
ofn.hwndOwner = hwnd;
ofn.lpstrTitle = L"開檔";
ofn.lpstrFilter = filter;
ofn.Flags = 6;
ofn.lpstrFile = 0; //若開檔後仍為0表示按了
if (!GetOpenFileName (&ofn)) {
if(*ofn.lpstrFile)
MsgBox_ (L"Fail to open: %d", CommDlgExtendedError());
return 0;
}
return fname = ofn.lpstrFile; //取個短名字
}
}
#define DO(b) if (FAILED(b)) \
{MsgBox_(L"fail in %s line %d",__FILE__,__LINE__);}
struct Player
{
bool bPlaying;
long evCode;
LONGLONG pos, duration;
IGraphBuilder* pGraph;
IMediaControl* pCtrl;
IVideoWindow* pVideo;
IMediaSeeking* pSeek;
void init()
{
bPlaying = false;
DO (CoCreateInstance (CLSID_FilterGraph, 0, CLSCTX_INPROC,
IID_IGraphBuilder, (void**) &pGraph));
DO (pGraph->QueryInterface (IID_IMediaControl, (void**) &pCtrl));
DO (pGraph->QueryInterface (IID_IVideoWindow, (void**) &pVideo));
DO (pGraph->QueryInterface (IID_IMediaSeeking, (void**) &pSeek));
}
void free ..
訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容