How to set title for your console application window.

3 05 2008

In huge frameworks, there might be a number of back-end servers running. Since they are servers most of them might be implemented as windows console applications to avoid gui overheads. But when you run the console, the title of the console window will be the path of console.exe.

Since there can be multiple console applications, One of the headache is to identify which console window is the server you are searching for? Usually we print logs in console such as “Image Server Started…” to identify which server it is. It will be nice, if we can set the console window title our own. So that we can easly identify the server application.

You can use the function – SetConsoleTitle(). Its straight forward. Just call the function by passing the preferred console title. See the code snippet below.

int main(int argc, char* argv[])
    // Set the console title of my Image Server.
    SetConsoleTitle( "Image Server." );

    // Let me see the result.
    return 0;

The SetConsoleTitle() is declared in wincon.h. But you just include windows.h which includes everything. 😉

Targeted Audience – Beginners.