Use C++ to produce GC Server process details

  • 2020-06-19 11:16:28
  • OfStack

A lot of people have come to me recently asking for the GC Server source code. When I talked to them about the environmental requirements, many of them were not impressed, and ended up signing up for thousands of Error tests alone. So, I decided to talk today about how to build your own GC Server. (No one has succeeded so far, please act according to your strength. If you succeed, please let me know in the comments section ~)

steps

1. System configuration

This article is for Windows systems only and supports most versions of Win7 and beyond, Win10 being the best.

2. Environment configuration

First, you need an IDE that supports C/C++ (Visual Studio is highly recommended and easier to use later), and then you need to download a graphics library such as WinAPI. Finally, you will need to install the graphics library into your IDE configuration and install both include and lib into the required folder. Needless to say, if you have any questions, please comment in the comments section.

3. Compile the tests

Attention! If any system errors occur under this step, stop immediately! It is recommended to backup the system before starting!

Step 1 - Create the project

In this step, you need to create an C/C++ project in your IDE to make sure that the creation is normal and that Hello world works. (I carefully prepared the Hello World code for your test. ^_^)


using namespace std;
int ()
{
 cout<<"Hello,world!"<<endl;
 return 0;
}

//C
#include <stdio.h>
int ()
{
 printf("Hello,world!n");
 return 0;
}

Step 2 - Graphics library tests

You need include, the header file of the graphics library you brought in earlier, and then set it to 1 like this:


#include <graphics.h>    //  Refers to the graphics library header file 
#include <conio.h>
int ()
{
 initgraph(640, 480);   //  Create a drawing window of size  640x480  pixel 
 setlinecolor(RGB(255, 0, 0)); //  Sets the current line color 
 setfillcolor(RGB(0, 255, 0)); //  Sets the current fill color 
 fillcircle(200, 200, 100);  //  Draw the circle, the center (200, 200) , the radius  100
 system("pause");    //  Press any key to continue, getch(); Can also be 
 closegraph();     //  Turn off the graphics environment 
 return 0;
}

If you can run the above code successfully, congratulations, you can go to the following steps

Step 3 - Button fabrication

Many people are surprised to see what the graphics library does, but I've also been asked how I drew the different colors of the buttons in GC Server. Because, the graphics library does not seem to have the function of drawing buttons

It's as simple as this:

(The code below is the last updated source code fragment of GC Server 8.7. In order to prevent data leakage, we did not adopt the code of the latest version, and did some processing on the basis of the original version, without affecting the understanding of the code)


settextstyle(90, 0, _T(" Regular script "));
setbkcolor(RED);
outtextxy(20, 160, _T(" Welcome to use  GC Server!"));
setbkcolor(BLUE);
settextstyle(38, 0, _T(" Regular script "));
outtextxy(124, 301, _T(" Quick registration "));
rectangle(120, 300, 280, 340);
outtextxy(404, 301, _T(" Program information "));
rectangle(400, 300, 560, 340);
outtextxy(684, 301, _T(" Login immediately "));
rectangle(680, 300, 840, 340);
MOUSEMSG m;
while (true)
{
 m = GetMouseMsg();
 if (m.x >= 120 && m.x <= 280 && m.y >= 300 && m.y <= 340)
 {
  if (m.uMsg == WM_LBUTTONDOWN)
  {
   // Here is the registration code, deleted for safety 
  }
  else
  {
   settextstyle(35, 0, _T(" Regular script "));
   outtextxy(130, 302, _T(" Quick registration "));
  }
 }
 else if (m.x >= 400 && m.x <= 560 && m.y >= 300 && m.y <= 340)
 {
  if (m.uMsg == WM_LBUTTONDOWN)
  {
   // Here is the program information code, deleted for safety 
  }
  else
  {
   settextstyle(35, 0, _T(" Regular script "));
   outtextxy(410, 302, _T(" Program information "));
  }
 }
 else if (m.x >= 680 && m.x <= 840 && m.y >= 300 && m.y <= 340)
 {
  if (m.uMsg == WM_LBUTTONDOWN)
  {
   // Here is the login code, which has been removed for safety 
  }
  else
  {
   settextstyle(35, 0, _T(" Regular script "));
   outtextxy(690, 302, _T(" Login immediately "));
  }
 }
 else
 {
  settextstyle(38, 0, _T(" Regular script "));
  outtextxy(124, 301, _T(" Quick registration "));
  outtextxy(404, 301, _T(" Program information "));
  outtextxy(684, 301, _T(" Login immediately "));
 }
}

Code idea: draw the button first, and then determine the mouse action. If the mouse is clicked again in a specified area and left-clicked, the user has clicked the button.

Of course, you can also do some tricks, such as my previous lock project (Computer Security Lock), which used the mouse gesture code:


MOUSEMSG m2;
int flag1 = 0, flag2 = 0;
settextstyle(20, 0, _T(" Regular script "));
rectangle(600, 500, 650, 530);
outtextxy(605, 505, _T(" determine "));
while (true)
{
 m2 = GetMouseMsg();
 if (m2.x >= 600 && m2.x <= 650 && m2.y >= 500 && m2.y <= 530)
 {
  settextstyle(25, 0, _T("Consolas"));
  if (m2.uMsg == WM_MBUTTONDBLCLK)
  {
   flag1 = 1;
   continue;
  }
  else if (m2.uMsg == WM_LBUTTONDOWN && flag1 == 1)
  {
   flag2 = 1;
   continue;
  }
  else if (m2.uMsg == WM_RBUTTONDOWN && flag2 == 1)
  {
   break;
  }
  else
  {
   settextstyle(22, 0, _T(" Regular script "));
   outtextxy(603, 503, _T(" determine "));
  }
 }
 else
 {
  settextstyle(20, 0, _T(" Regular script "));
  outtextxy(605, 505, _T(" determine "));
 }
}

The above code is to double click the middle mouse wheel (press down), and then left once right once can be.

Step 4 - Add games

You can post directly to GC Coding and I will reply. For now, most of the game code in the current version of GC Server is available to me directly.

Step 5 - Design plug-in change module

You need to open a repo on Github, then you want to use the plug-in package up, when users want to download, only need to use system calls to open the browser to access the specified website, and then prompt the user to download package into the installation directory, and then click a magic button after the program will automatically start parsing user download package, and then add the files to the download directory. The program then changes the file in the installation directory, such as changing 0 to 1, and starts loading the plug-in.

Generally speaking, users prefer plugins with uninstall function. This is also very simple. You only need to add an uninstall button.

Also can add repo 1 README, add 1 instruction in the program, 1 point on the open README website, this is not difficult.

Step 6 - Add 1 part Easter egg

Okay, so this step is actually optional but I think a program that is more interesting should have one Easter egg in it. GC Server for example, one of the most important reasons I recently added name login was to hide eggs. For example, if you type in some magical name, enough to keep it secret...

Step 7 - Completion

Well, if you've followed the previous steps successfully, it's time to generate the exe file. Barring any surprises (which is almost impossible), you'll see the exe files already waiting for you in the project folder. Of course, if there is an error that cannot be resolved, you are welcome to leave a message


Related articles: