"Object-Oriented Programming Technology" Experiment 1 SDUWH

Content source network collection, for reference only

"Object-Oriented Programming Technology" Experiment 1 (Third Year Undergraduate)

Experiment topic: master the development environment, create the first Windows program, understand the basic concepts of compiling, running and debugging

Overall purpose: Familiar with the environment of Visual Studio (Visual Studio 6.0 to Visual Studio 2022, an environment with Visual C++ installed), create a project and complete the writing, compiling and running of the first windows program based on the Easywin sample program. Practice command-line program building.

Experimental content and process:

  1. Configure the Visual Studio environment and find the executable program (exe file) required to start the Visual Studio environment;
  2. Create your own working directory;
  3. Create a Win32 Application empty project/project in your own working directory;
  4. Copy Easywin.c to the project directory and add it to the project, compile;
  5. Correct the link error of the PlaySound function, understand compiling and linking; (increase the multimedia library used by the program link, the specific method is: in the linker (or link ) settings, select "Input" or "Input" of the project, and then add the multimedia function library "winmm.lib" at the end of the "Object/library modules" edit box, and then you can link through. Modify the wave used by the PlaySound function file name, the corresponding audio can be played when the program starts);
  6. Modify strings in program files to change the display;
  7. Modify the relevant notes, read the code at the same time, and initially grasp the composition of the Windows application program.
  8. Trace debugging exercise: set breakpoints appropriately , view variable values

Program construction in command line mode:

  1. Find the location of devenv.exe or msdev.exe according to the version of Visual Studio, set it to be located in (Visual Studio 2019: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\" directory;
  2. Open the Command (command window), switch to the project directory (use the cd command), if the project is in the test directory of the D disk, use the following command:
                  D:
                  cd \test
  3. Enter the following command to view the help of the command line parameters (note that each parameter is separated by a space ): "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\devenv.exe" /? ( think Think about it, why use quotation marks? What will happen if you don’t use them?) Focus on the instructions related to Build Make Rebuild

Example of building Visual Studio 2019 and rebuilding the entire solution (multiple projects) :

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv" c1.sln /Build

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv" c1.sln /Rebuild

The commands and command line parameters used in different development environments will be different. Please find the information by yourself to complete the command writing, so as to realize the command line construction (compilation, connection) of the program.

Additional: You can choose to build only one project in the solution, so what about the command line?

object-oriented programming

Experiment 1 Experiment Report

1. Experimental requirements

  1. Configure the Visual Studio environment and find the executable program (exe file) required to start the Visual Studio environment;
  2. Create your own working directory;
  3. Create a Win32 Application empty project/project in your own working directory;
  4. Copy Easywin.c to the project directory and add it to the project, compile;
  5. Correct the link error of the PlaySound function, understand compiling and linking; (increase the multimedia library used by the program link, the specific method is: in the linker (or link ) settings, select "Input" or "Input" of the project, and then add the multimedia function library "winmm.lib" at the end of the "Object/library modules" edit box, and then you can link through. Modify the wave used by the PlaySound function file name, the corresponding audio can be played when the program starts);
  6. Modify strings in program files to change the display;
  7. Modify the relevant notes, read the code at the same time, and initially grasp the composition of the Windows application program.
  8. Trace debugging exercise: set breakpoints appropriately , view variable values

Find the location of devenv.exe or msdev.exe according to the version of Visual Studio, and set it to (Visual Studio 2022: "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\Common7\IDE\" directory;

Practice compiling and linking using the command line.

  1. Open Command (command window), switch to the project directory (use the cd command)
  2. Enter the following command to view the help of the command line parameters (note that each parameter is separated by a space): "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe " /?

Build for Visual Studio 2019 and rebuild the whole solution:

"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe " Easywin1.sln /Build

"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" Easywin1.sln /Rebuild

2. Experimental process and results

2.1 Create a project

1. Create your own working directory;

2. Create a Win32 Application empty project/project in your own working directory;

3. Copy Easywin.c to the project directory and add it to the project, compile;

 

 

2.2 Program flow and data model analysis

  1. Correct the link error of the PlaySound function, understand compiling and linking; (increase the multimedia library used by the program link, the specific method is: in the linker (or link ) settings, select "Input" or "Input" of the project, and then add the multimedia function library "winmm.lib" at the end of the "Object/library modules" edit box, and then you can link through. Modify the wave used by the PlaySound function file name, the corresponding audio can be played when the program starts);

Error message:

You can run the program by adding winmm.lib

 

  1. Modify strings in program files to change the display;

Change the display content by modifying the text in TEXT

 

 

 3. Modify the relevant notes, read the code at the same time, and initially grasp the composition of Windows applications.

2.3 Program construction in command line mode:

Find the location of devenv.exe or msdev.exe according to the version of Visual Studio, set it to be located in (Visual Studio 2019: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\" directory;

3. Open the Command (command window), switch to the project directory (use the cd command)

4. Enter the following command to view the help of the command line parameters (note that each parameter is separated by a space): "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe " /?

Build for Visual Studio 2019 and rebuild the whole solution:

"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe " Easywin1.sln /Build

First enter the project directory, use the cd command

 

 "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" Easywin1.sln /Rebuild

 

3. Experiment summary

Through this experiment, I initially mastered the relevant knowledge of the development environment, created the first Windows program, and initially understood the basic concepts of compiling, running, and debugging. Familiar with the environment of Visual Studio2022, create a project and complete the writing, compiling and running of the first windows program based on the Easywin sample program. At the same time, the command line program construction was practiced.

 

Guess you like

Origin blog.csdn.net/qq_22471349/article/details/130981749