System command
1, first introduce some system commands
Windows+tab//Toggle Window
Windows+r//Bring up the command window
Command:
Enter Calc to turn on your computer
Enter CMD to open the command window
Enter MSPaint to open paint
System is a function used to run external programs
Format system ("command statement");
You need to add a header file to the code before #include <stdio.h>
(1) Shutdown command
Shutdown-s//Shutdown
Shutdown-a//Cancel shutdown
Shutdown-s-T 60//Timer shutdown 60 seconds after the shutdown time can be self-modifying
SHUTDOWN-R//Logoff computer
At 20:00 shutdown-s//During eight o'clock in the afternoon full timer time can be changed
Slidetshutdown//win10 Available
(2) Color
color+ Color
0-9 a-f
Color/? cmd command view color settings default console foreground and background color
0 = Black 8 = Gray
1 = Blue 9 = light Blue
2 = green A = Light Green
3 = light green B = Light Green
4 = Red C = Light Red
5 = Purple D = Lavender
6 = Yellow E = Light Yellow
7 = White F = Bright White
Color//color+ two digits in front of the back of the background color of the representation font
(3) Pause pauses will display press any key to continue
(4) CLS Clear screen
(5) Generate EXE file
Generate EXE files when you are sure that the code is not a problem
1, change the debug to release 2, the project Property code generation change Run library MT
Find the EXE under the Release folder.
(6) Related solutions
Solution-One solution can have multiple projects a project a program needs to run that project to set which project is the startup item
(7) Related code, project
1. Send code. c/.cpp File
2. Project-----Send the entire project folder
(8) About RC file
RC files are rescourse files (resource files)
(9)
F5 Start Debugging--Mister into an EXE run with error will prompt and build failed
Ctrl+f5 Direct start do not debug if there is error vs will direct error
*************************************************************************************************************** *********
Formally start creating projects, writing Programs
Create a new project first
Select the WIN32 console application
own one of its project names
The address is random, but it will be useful after you write it down.
Click OK
Then click Next
Select an empty Project
Remove the precompiled header and Security development lifecycle
Then click Finish
When you are done, click Solution Explorer on the left
Select the header file right-click
Click Add New Item
Then select the C + + file
Change the name to. C file
Then click Add
Start writing code below
Code
Press F5 to execute after the code is written.
Results
Now we're going to edit it into an EXE file.
First change debug (debug mode) to release (release mode)
Then open Solution Explorer
Select the system command, right-click the properties
Find C + + in properties
Select Code Generation
Select Run Library
Change to MT
Click OK
Then click Regenerate Solution
Then select the System command right-click
Click Open file in File Explorer
Select upper Level
Open the release file
This is the exe file we generated.
Just open it and you can run it.
And now we look at this icon is not nice then we can add a
Add the following methods
Search for ICO on Baidu
Feel free to open a link
Upload a picture yourself to generate an ICO file
Put it in the source code directory (in fact, just remember the address can be, all the same)
Then open Solution Explorer
Select Resource File
Right-click
Add to
Resources
Select icon to click Import
Find our previously generated ICO file to add in
The picture feels empty, no tube
And then rebuild the scenario, you can.
That's the final effect.
The main lessons of this study are:
1: Header file #include <stdlib.h> for System (""); The use of functions
2: Some system commands
3: Generate EXE file in VS
4: Add an icon to the EXE file
In fact, the person can write a shut down the computer EXE program, make good to students or friends, they open a run, the computer directly shut down (of course, this is not a good try, be careful to be friends killed Hee ~)
Well, this time vs study is here.
Please look forward to the next update ~
2018.05.12 23:48:52
C + + Learning (ii) Visual Studio writes the system statement to generate an executable file