How I can delete window title from my application?

I'm new to C++ and programming, I've background for php and perl but started to write some C++ codes. I'm trying to make a window title become untitle i mean window icon should stay there but window name must be deleted.
I need it to because I'm injecting a dll to one of old game and need to delete its window title.
Justin Uberti
Who is Participating?
ErburethConnect With a Mentor Commented:
If you are using plain Windows API, you need to obtain handle of the window you want to edit, then you can call SetWindowText, which is in user32.dll (you can use #include <Windows.h>)
here is the function prototype

BOOL SetWindowText (
  HWND hWnd; // handle of a window
  LPCTSTR lpString // new text in a window

See MSDN for more info
Give some spaces in the title property. It will appear as if no title is there.
jubertiAuthor Commented:
Erbureth , thanks i done it after looking it.
Now my only problem is getting parentwindows hwnd i can make it if parent windows title is static thanks for your help and if you know how can i get parent window's hwnd ill be appreciated.
I tried getparentwindow but couldnt succeeded :)
Become a Leader in Data Analytics

Gain the power to turn raw data into better business decisions and outcomes in your industry. Transform your career future by earning your MS in Data Analytics. WGU’s MSDA program curriculum features IT certifications from Oracle and SAS.  

jubertiAuthor Commented:
macksm, ty for your reply too but it wasn't the thing i was seeking
In order to set/erase any window's text, you first need the window handle. Since you are injecting a DLL, you don't have that one, but only a process handle, ut that's a start. You could basically do the following:
HWND  g_hwnd;
int  g_nFound;
HWND GetHwndFromPID ( DWORD dwProcessId)
 g_hwnd = NULL;
 g_nFound = 0;
 EnumWindows (  FindHwndFromPID,    ( LPARAM) dwProcessId));
 if ( g_hwnd)  // we found one...
      return ( g_hwnd);
 // nothing found :-(
 return (NULL);
    DWORD   dwPID2Find  =   ( DWORD) lParam;
    DWORD   dwPID       =   0;
    if  (   GetWindowThreadProcessId    (   hwnd,   &dwPID))
            if  (   dwPID   ==  dwPID2Find)
                    g_hwnd  =   hwnd;
                    return  (   FALSE);
    return  (   TRUE);
// ...
// ...
// in your DLL:
HWND hWnd = GetHwndFromPID(GetCurrentProcessId());
SetWindowTexy(hWnd,_T("")); // or just "" if compiling ANSI

Open in new window

jubertiAuthor Commented:
Hello jkr, ty for your example, i do nearly same for static window title name with putting NULL with your example i can do it for parent window title.
Now the main purpose of i'm doing it i need to hide that window from enumwindows but as i noticed now if user searchs for null window title he can attach its program to mine. Now i think i need to seek another thing for doing this.
Between is there a way for completely removing title/window from enumwindows or hiding it?
jubertiAuthor Commented:
Ah my bad sorry, i checked handle of injection it finds explorer.exe and injects ty now the thing does the job i wanted.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.