Thread: SetConsoleTitle()

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    38

    SetConsoleTitle()

    Hi having problems changing title of console.I have included windows.h and have called the function in main but keep getting
    Code:
    error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [5]' to 'LPCWSTR'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    heres where i call it in main
    Code:
    SetConsoleTitle("NEWNAME");
    in any of the online examples I have found this is the way it was done.Tried looking at the error code on MSDN but tbh I didnt understand the examples.

    Thanks

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Cathalo View Post
    Hi having problems changing title of console.I have included windows.h and have called the function in main but keep getting
    Code:
    error C2664: 'SetConsoleTitleW' : cannot convert parameter 1 from 'const char [5]' to 'LPCWSTR'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    heres where i call it in main
    Code:
    SetConsoleTitle("NEWNAME");
    in any of the online examples I have found this is the way it was done.Tried looking at the error code on MSDN but tbh I didnt understand the examples.

    Thanks
    You need to do one of two things:

    1. modify your project settings to use non-unicode libraries.
    2. wrap your string in _T() to convert const char* types to const wchar_t* types.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    38
    Thanks.Wrapped the string with _T.Still didnt work.Came across some code that had SetConsoleTitle in it.

    It seemed to use a precompiled headers that u can setup when your creating the project in MS visual.I have to include<tchar.h> for the solution to work.

    but it works and I dont care how!!

  4. #4
    Student legit's Avatar
    Join Date
    Aug 2008
    Location
    UK -> Newcastle
    Posts
    156
    Quote Originally Posted by Cathalo View Post
    but it works and I dont care how!!
    That's a bad thing...
    MSDN <- Programmers Haven!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Regaurding SetConsoleTitle() and whitespace.
    By Tronic in forum Windows Programming
    Replies: 4
    Last Post: 03-26-2004, 09:02 PM