none
make C++ program .exe run silently (or in background) in visual studio code RRS feed

  • Question

  • First of all I am new in MSDN Community, so, I want to ask a question. My problem is I following udemy course to make a keylogger in C++ but my question is how to make the builded .exe to work in background or silently? I know how to make it in CodeBlocks for example I just need to add flags to the compiler flags like: -mwindows and thats it. The debugged .exe file wont popup. But, I want to learn how to make it in Visual Studio Code too. So, here is my code:

    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
    
        MSG Msg;
        while(GetMessage(&Msg, NULL, 0, 0))
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
    
        return 0;
    }


    Do I need to make changed in the task.json and launch.json so my builded .exe will work silently or ? Here is my task.json and launch.json

    task.json:

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build",
                "type": "shell",
                "command": "g++ -g main.cpp -o main",
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "problemMatcher":"$gcc"
            }
        ]
    }

    and here is my launch.json:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
    
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "preLaunchTask": "build",
                "program": "${workspaceFolder}/main.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "miDebuggerPath": "C:/MinGW/bin/gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }

    Please give me any tips and thanks.


    Wednesday, October 31, 2018 5:47 PM