quick question

Feb 27, 2010 at 3:36pm
I know using system("anything") is bad but I was wondering if it could be harmful at all using system("TITLE Program title") since all it does is change the name at the top of the command prompt. IF it is bad is there an alternative?
Feb 27, 2010 at 3:41pm
It's bad for all the same reasons mentioned here:

http://cplusplus.com/forum/articles/11153/


If this is a WinAPI GUI program (IE: not a console program) you can use SetWindowText:

http://msdn.microsoft.com/en-us/library/ms633546(VS.85).aspx

If this is a console program, I have no idea, but there's probably a similar SetConsoleTitle function or something in WinAPI somewhere. I'm too lazy to check. (I hate the console)


EDIT:

Damn I'm good:

http://msdn.microsoft.com/en-us/library/ms686050(VS.85).aspx

That was a total guess
Last edited on Feb 27, 2010 at 3:42pm
Feb 27, 2010 at 3:49pm
thanks! I know system is bad but i wasn't sure since all it was doing is changing the name
Feb 27, 2010 at 4:02pm
can someone explain to me how to use that function because the msdn library isn't very clear with it's example
Feb 27, 2010 at 4:14pm
1
2
3
4
5
6
7
8
#include <windows.h>

int main()
{
  SetConsoleTitle( _T("Your Title Here") );

  return 0;
}


The 'TCHAR' and '_T' stuff is WinAPI's way of dealing with Unicode.

See here:

http://cplusplus.com/forum/articles/16820/

If you're not interested in being unicode friendly, you can use SetConsoleTitleA:

 
SetConsoleTitleA( "Your Title Here" );


But you should embrace the Unicode!
Feb 27, 2010 at 4:19pm
ok thanks that works perfectly. Thanks Disch for all your help
Feb 28, 2010 at 3:47am
I decided I would try the unicode way but using SetConsoleTitle( _T("Your Title Here") ); doesn't seem to work. I get error C3861: '_T': identifier not found. Do I need another header file besides windows.h?
edit:nevermind i fixed it by including tchar.h
Last edited on Feb 28, 2010 at 3:07pm
Topic archived. No new replies allowed.