Void cxunleiplaydlg: oncapstart () // start recording {cstring STR; cfiledialog filedlg (false, _ T ("Avi"), null, ofn_hidereadonly | ofn_overwriteprompt, _ T ("video file | *. avi | "), this); If (filedlg. domodal () = idok) {STR = filedlg. getpathname ();} If (Str. isempty () {MessageBox (_ T ("select or input file"); return;} icapturegraphbuilder2 * pbuilder = NULL; pgraph = NULL; pmediacontrol = NULL; ibasefilter * pmux = NULL; ibasefilter * pwriter = NULL; ibasefil Ter * pcompress = NULL; ifilesinkfilter2 * psink; // enumeration of video devices * pdevenum = NULL; cocreateinstance (clsid_systemdeviceenum, null, empty, empty, (void **) & pdevenum ); ienummoniker * pclassenum = NULL; pdevenum-> createclassenumerator (separator, & pclassenum, 0); ulong cfetched; If (pclassenum-> next (1, & pmoniker, & cfetched) ==s_ OK) {pmoniker-> bindtoobject (0, 0, II D_ibasefilter, (void **) & psrc); pmoniker-> release ();} pclassenum-> release (); // lists the video compression devices pdevenum-> createclassenumerator (timer, & pclassenum, 0); While (pclassenum-> next (1, & pmoniker, & cfetched) = s_ OK) {ipropertybag * pprop = NULL; pmoniker-> bindtostorage (0, 0, iid_ipropertybag, (void **) & pprop); variant varname; varname. vt = vt_bstr; pprop-> Read (L "friendlyname", & varname, 0); cstring St R = varname. bstrval; If (Str. Find (_ T ("Microsoft Video 1"), 0 )! =-1) {pmoniker-> bindtoobject (0, 0, iid_ibasefilter, (void **) & pcompress); pmoniker-> release (); break ;} variantclear (& varname);} pclassenum-> release (); If (pcompress = NULL) {MessageBox (_ T ("No Microsoft Video 1 compressors found! "), _ T (" prompt "), mb_iconasterisk); return;} cocreateinstance (Region, 0, clsctx_inproc_server, region, (void **) & pbuilder); cocreateinstance (clsid_filtergraph, null, clsctx_inproc_server, callback, (void **) & pgraph); pbuilder-> setfiltergraph (pgraph); pgraph-> QueryInterface (iid_imediacontrol, (void **) & pmediacontrol ); pgraph-> addfilter (psrc, l "Avi"); pgraph-> addfilter (pcompress, l "com"); cocreateinstance (clsid_avidest, null, clsctx_all, iid_ibasefilter, (void **) & pmux); pgraph-> addfilter (pmux, l "MUX"); cocreateinstance (clsid_filewriter, null, clsctx_all, iid_ibasefilter, (void **) & pwriter); pgraph-> addfilter (pwriter, l "Writer"); pwriter-> QueryInterface (iid_ifilesinkfilter2, (void **) & psink); psink-> setfilename (Str. allocsysstring (), null); // compressed input/output pins * pamcompress; ipin * compression, * pcomin; pcomin = findpin (pcompress, pindir_input); pcomout = findpin (pcompress, pindir_output); pcomout-> QueryInterface (response, (void **) & pamcompress); hresult HRET; HRET = pamcompress-> put_keyframerate (8); ipin * poutpin = findpin (psrc, pindir_output); // psrc output pin ipin * Pinpin, * pout; // pmux input/output pin Pinpin = findpin (pmux, pindir_input); pout = findpin (pmux, pindir_output); ipin * pinpin1 = findpin (pwriter, pindir_input); // pwriter Input Pin // connection pin hresult result; Result = pgraph-> connectdirect (poutpin, pcomin, null); Result = pgraph-> connectdirect (ipin *) pcomout, Pinpin, null); Result = pgraph-> connectdirect (pout, pinpin1, null ); pmediacontrol-> Run (); pamcompress-> release (); m_isrecorded = true ;}