quick question

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?
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
thanks! I know system is bad but i wasn't sure since all it was doing is changing the name
can someone explain to me how to use that function because the msdn library isn't very clear with it's example
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!
ok thanks that works perfectly. Thanks Disch for all your help
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
Topic archived. No new replies allowed.