Thread: Name my program

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    22

    Name my program

    Hi, i have just finished my first basic program (with a little help)

    i want to know if there is a way to name my program, and not just the file path coming up when i run it

    help appreiciated

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    You need to describe in a little more detail exactly what you want to do. What do you want the user to do, and what do you want the user to see? Since you're new, you aren't speaking C++ yet.

  3. #3
    *this
    Join Date
    Mar 2005
    Posts
    498
    I think he is referring to the window title name. There must be some windows function (assuming your using windows) that changes the window title. I know how to do this while registering a windows app but never tried for console.

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Try:
    Code:
    #include <windows.h>
    
    ...
    
    char newTitle[] = "This is my new console window title.";
    
    HWND consoleWnd = GetConsoleWindow();   //Get a handle to the console window
    if(!consoleWnd)  //Check for error getting handle
    {
       //Fix any error
    }
    
    BOOL result = SetWindowText(consoleWnd, newTitle);   //Set the title using this handle
    if(!result)  //Check for error setting title
    {
       //Fix any error
    }
    If you don't care about error checking, you can skip the two if's and also get rid of the "BOOL result = ".
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    6
    I think you can just do this
    Code:
        #include <windows.h>
        SetConsoleTitle("Hey look, a title!");

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Neat, didn't know there was a function for that. Will remember this
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    22
    Thanks everybody, that was what i was after, and has done the trick nicely.

    cheers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM