How to hide the console window of a C program?

Viewed 14592

I've been looking around but I couldn't find the solution to my problem, even with some supposedly solved problems that resemble mine.

I want to hide the console window when my C program runs.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#define _WIN32_WINNT 0x0500

int main(){   
    HWND hWnd = GetConsoleWindow();
    ShowWindow( hWnd, SW_MINIMIZE );  //won't hide the window without SW_MINIMIZE
    ShowWindow( hWnd, SW_HIDE );
}

This is what I tried but the compiler gives me

initialization makes pointer from integer without a cast

and the fatal one which actually stops the compiling:

undefined reference to 'GetConsoleWindow'

PS: I've checked wincon.h and the GetConsoleWindow() function is defined.

1 Answers
Related