Hiding Command Prompt

This is a discussion on Hiding Command Prompt within the C++ Programming forums, part of the General Programming Boards category; Hi, I just created my own type of start up folder for all of my rendering programs. (ie: rhino Bryce ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    6

    Hiding Command Prompt

    Hi, I just created my own type of start up folder for all of my rendering programs. (ie: rhino Bryce autocad . .etc.) Now to fine tune my program i wanted to know a way to hide or make the command prompt that runs the program not appear. Any help on what command to do this would help. Thank You

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Sure. You start the whole thing as a Win32 project, not a Win32 console project.
    For command line, you pass /subsystem:windows instead of /subsystem:console to the MS linker.

    And when you've done that, you need to use WinMain as the startup function instead of main.

    Other Windows compilers have something equivalent.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    6
    Im really new to programming so im a lil confused this is what i have so far. It opens the programs and so does command prompt, could u show me where I have to type the subsystem and winmain? TY
    Code:
     #include <cstdlib>
    
    int main()  \\im guessing this is where i type in the win main
    {
        system("acad2003.exe");
        system("rhino1.exe.exe");
        system("bryce01.exe.exe");
    
        return 0;
    }

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Your code would look like this:
    Code:
    #include <windows.h>
    
    int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
      // ShellExecute essentially does the same as system, but you don't need yet another header for it.
      ShellExecute(0, 0, "acad2003.exe", 0, 0, SW_SHOW);
      ShellExecute(0, 0, "rhino1.exe", 0, 0, SW_SHOW);
      ShellExecute(0, 0, "bryce01.exe", 0, 0, SW_SHOW);
    
      return 0;
    }
    As for the subsystem setting, that's a project/compiler option. What compiler are you using?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    6
    Im using Dev-C++ and i found the option to do the windows application instead of console project. THanks for yur help. You and all you programming gurus are the best. I dont know why programmers as a whole get a bad rep. THX again!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to use complex.h classes, some keyword is hiding it
    By indigo0086 in forum C++ Programming
    Replies: 4
    Last Post: 02-05-2008, 10:10 PM
  2. Hiding the password
    By NoFearXD in forum C++ Programming
    Replies: 7
    Last Post: 06-30-2007, 07:20 AM
  3. help hiding text
    By mmongoose in forum C++ Programming
    Replies: 10
    Last Post: 07-17-2005, 12:40 AM
  4. Hiding a folder
    By nextstep in forum Windows Programming
    Replies: 16
    Last Post: 03-20-2005, 02:07 PM
  5. Hiding the console.
    By knave in forum C++ Programming
    Replies: 3
    Last Post: 07-10-2003, 12:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21