In daily development, we often encounter the need for screen recording. Such requirements can be implemented in C # through the SDK of Expression Encoder. First you need to download the expression Encoder SDK to implement the code:
PrivateScreencapturejob job =NULL; PublicMainWindow () {InitializeComponent (); Job=NewScreencapturejob (); Job. Capturemousecursor=false; } Private voidBtnplay_click (Objectsender, RoutedEventArgs e) {btnpause.isenabled=true; Btnstop.isenabled=true; Btnplay.isenabled=false; if(Job. Status = =recordstatus.notstarted) {job. Capturerectangle=Screen.PrimaryScreen.WorkingArea; Job. OutputPath="d:/screencapture"; } job. Start (); } Private voidBtnpause_click (Objectsender, RoutedEventArgs e) {btnplay.isenabled=true; Btnpause.isenabled=false; Job. Pause (); } Private voidBtnstop_click (Objectsender, RoutedEventArgs e) {btnplay.isenabled=true; Btnpause.isenabled=false; Btnstop.isenabled=false; Job. Stop (); } Private voidOnClosing (Objectsender, System.ComponentModel.CancelEventArgs e) { if(Job. Status = =recordstatus.running) {messageboxresult result=System.Windows.MessageBox.Show ("capturing in Progress. Is sure you want to Quit?","capturing", Messageboxbutton.yesno); if(Result = =messageboxresult.no) {e.cancel=true; return; } job. Stop (); Job. Dispose (); } }
Reference Document: http://msdn.microsoft.com/en-us/library/gg602440 (v=expression.40). aspx
Code download.
If you have questions about this example, you are welcome to point it out in the comments, and if you have other implementations, you are welcome to share it with me. Thank you!
C # implements screen recording with Microsoft Expression encoder