Thread: Windows API

  1. #1
    Newbie Crilston's Avatar
    Join Date
    Jun 2005
    Montreal, Canada

    Windows API

    Do I have to create a window in a Windows API application (with WinMain)? What if my application runs in the background (a server)?

  2. #2
    Join Date
    Nov 2002
    Warwick, UK
    You can use the WinAPI functions while running the program in a standard console, that is, you don't need to make a window. If you want to run in background, you can use handles and then the ShowWindow() function to hide the console.

    You could have simply tried it, of course And this would have been better posted under Windows Programming, if I'm not mistaken.

  3. #3
    Registered User
    Join Date
    Jun 2004
    windows application run on several windows subsystems: console, windows, posix, whatever

    to run a application with main you have to specify subsystem console (it's the default to most compilers). To work with a gui, specify windows. With a gui, you can call AllocConsole() to create a console for your process.
    with a console app... itīs a bit harder to get rid of the console. I donīt know why

    where's a small example - of course this syntax for pragma coment is Ms specific. I don't know the gcc version. Never tried it

    A console app
    #pragma comment(linker, "/SUBSYSTEM:CONSOLE")
    #include <iostream>
    int main(){
        std::cout<<"Hllo world!"<<std::endl;
        return 0;
    a gui app
    #pragma comment(linker, "/SUBSYSTEM:WINDOWS")
    #include <windows.h>
    int WinMain(HINSTANCE hc, HINSTANCE hp, LPSTR cmdln, int guicmd){
        MessageBox(GetDesktopHandle(),"hello world","hello world",0);
        return 0;
    any process can run without any console or window.
    Of course to kill it you have to go to Task Manager

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. win32 api MDI windows
    By TheNewOne in forum Windows Programming
    Replies: 5
    Last Post: 03-20-2009, 09:11 PM
  2. Use windows API functions in a GTK+ program?
    By Jake.c in forum Windows Programming
    Replies: 19
    Last Post: 01-23-2009, 06:40 AM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  4. Windows messenger API
    By GanglyLamb in forum Windows Programming
    Replies: 0
    Last Post: 07-10-2005, 02:52 AM
  5. Future of Windows API programming ?
    By Dev in forum Windows Programming
    Replies: 7
    Last Post: 04-22-2003, 11:21 PM