One: C # plays music
string " /sound/msg.wav " // Application.startuppath: The program EXE location, you can also directly write a path to music New ////player. Playlooping (); // play the player. Play ();
Two: C # call EXE
Logout of a program as an example: Click to log out after the program opened, and then close the program
if (process==null) { string path = Application.startuppath; // This path is the absolute path to the EXE program you are calling. New System.Diagnostics.Process (); // Create a new process Process. Startinfo.filename = assembly.getexecutingassembly (). Manifestmodule.fullyqualifiedname; // gets the file name of its own EXE or DLL Process. Startinfo.workingdirectory = path; Process. Start (); } this. Close ();
Three: Program Display clock
Write code in a time control that is set to 1000ms
Private void Statetime_tick (object sender, EventArgs e) { // Show status bar " Soul-Heart Home improvement budget software " + DateTime.Now.ToString ("yyyy mm month DD Day HH:mm:ss"); }
Four: Set the transparency of the custom control
PublicUserControl1 () {InitializeComponent (); //set style to support transparent background color This. SetStyle (Controlstyles.supportstransparentbackcolor,true); This. BackColor = Color.FromArgb ( -, $, $, $); } protected Override voidOnPaint (PaintEventArgs e) {Base. OnPaint (e); E.graphics.drawstring ("",NewFont ("Tahoma",8.25f), Brushes.Red,NewPointF ( -, -)); }
C # plays music, invokes programs