Thread: Finding a 'Microsoft Windows' window

  1. #1
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163

    Question Finding a 'Microsoft Windows' window

    I have a program which grabs information from a program and then places it into a database. Currently I am trying to upgrade the legacy code, unfortunately some of this is beyond my skill level

    The old code injects a DLL into a running window, which worked fine until the program it was hooking into upgraded. Now the name of the program changes and it also opens a new window which I think confuses the DLL.

    The old code is as follows -
    Code:
    DWORD idProcess; 
    HWND hWnd  = ::FindWindow(NULL, "Practice");
    GetWindowThreadProcessId ( hWnd, &idProcess );
    Now the title of the program at the top of the window can be "Practice makes perfect", or "Practice, we all need it" e.t.c The only thing they have in common is that they all start with the word "Practice", so I tried the following line of code
    Code:
    HWND hWnd  = ::FindWindow(NULL, "Practice*");
    which doesn't work

    My questions are -
    A) How do I find out what the name of a window is for DLL injection purposes?
    B) Does (NULL, "Practice*") actually work or should it be something else?
    C) How can I get it working if the window changes it's name or is it that once the DLL is hooked it doesn't matter?
    My site to register for all my other websites!
    'Clifton Bazaar'

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What you need to do is enumerate all windows and apply a regex string search on its title.
    FindWindow isn't smart enough.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    Thanks for the reply - do you have a link to a somewhere so I can learn this?
    My site to register for all my other websites!
    'Clifton Bazaar'

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. edit box affecting displaying of text?
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2005, 03:28 PM
  3. no errors but still errors
    By Megatron in forum Windows Programming
    Replies: 7
    Last Post: 01-12-2003, 11:21 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM