[MCI 이 페이지와 연결된 기능은 레거시 기능입니다. MediaPlayer로 대체되었습니다. MediaPlayer Windows 10 및 Windows 11에 최적화되었습니다. 가능한 경우 새 코드에서 MCI 대신 MediaPlayer 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
다음 예제에서는 AVI 파일을 재생하는 데 필요한 차원을 찾고, 해당 크기에 해당하는 창을 만들고, MCIAVI 드라이버를 사용하여 창에서 파일을 재생합니다. mciSendCommand 함수를 사용합니다.
HWND hwnd;
MCI_DGV_RECT_PARMS mciRect;
// Get the movie dimensions with MCI_WHERE.
mciSendCommand(wDeviceID, MCI_WHERE, MCI_DGV_WHERE_SOURCE,
(DWORD)(LPSTR)&mciRect);
// Create the playback window. Make it bigger for the border.
// Note that the right and bottom members of RECT structures in MCI
// are unusual; rc.right is set to the rectangle's width, and
// rc.bottom is set to the rectangle's height.
hwndMovie = CreateWindow("mywindow", "Playback",
WS_CHILD|WS_BORDER, 0,0,
mciRect.rc.right+(2*GetSystemMetric(SM_CXBORDER)),
mciRect.rc.bottom+(2*GetSystemMetric(SM_CYBORDER)),
hwndParent, hInstApp, NULL);
if (hwndMovie){
// Window created OK; make it the playback window.
MCI_DGV_WINDOW_PARMS mciWindow;
mciWindow.hWnd = hwndMovie;
mciSendCommand(wDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_HWND,
(DWORD)(LPSTR)&mciWindow);
}