Solved

How I can delete window title from my application?

Posted on 2009-07-05
7
238 Views
Last Modified: 2012-05-07
Hello,
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.
Regards,
Justin Uberti
0
Comment
Question by:juberti
7 Comments
 
LVL 4

Expert Comment

by:macksm
ID: 24779910
Give some spaces in the title property. It will appear as if no title is there.
0
 
LVL 2

Accepted Solution

by:
Erbureth earned 500 total points
ID: 24779911
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
0
 

Author Comment

by:juberti
ID: 24780019
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 :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:juberti
ID: 24780024
macksm, ty for your reply too but it wasn't the thing i was seeking
0
 
LVL 86

Expert Comment

by:jkr
ID: 24780025
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;

 

BOOL CALLBACK FindHwndFromPID( HWND hwnd, LPARAM lParam);

 

 

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);

}

 

BOOL CALLBACK FindHwndFromPID( HWND hwnd, LPARAM lParam)

{

    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

0
 

Author Comment

by:juberti
ID: 24780064
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?
0
 

Author Comment

by:juberti
ID: 24780161
Ah my bad sorry, i checked handle of injection it finds explorer.exe and injects ty now the thing does the job i wanted.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now