Getting active window in BCB 6.0

Using Borland C++ Builder 6.0
Got this code:

char* oldtitle = "";
char* title= "a";
while(1)
             {

                    Sleep(10);
                    HWND wnd=GetForegroundWindow();
                    ShowMessage("Trying");
                    if(wnd) {
                        char* title;
                        GetWindowText(wnd,title,sizeof(title));
                        ShowMessage("Success");
                        DWORD err = GetLastError();
                        ShowMessage("Error code:" + IntToStr(err));
                        ShowMessage(title);

                    }
                    if (title != oldtitle) {
                       oldtitle = title;
                        DoSomeAction();
                    }



Don't know why but the title is always a null value.
Jammer1224Asked:
Who is Participating?
 
Kent OlsenConnect With a Mentor Data Warehouse Architect / DBACommented:

You've got 'title' defined with two different scopes.  


0
 
Jammer1224Author Commented:
Hurry up. Its urgent!
0
 
Jammer1224Author Commented:
What can i say.
Finders keepers!
Congrats on you 500 points.
Thats all I needed.
0
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.