Results 1 to 4 of 4
  1. #1
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0

    find process by filename

    i can find a window with
    hw = FindWindow("windowname",NULL);

    but how can i find the window name from the .exe filename?
    say i wanted to find "game.exe"'s window name, how would i do that?

    this is because i use task manager to find the windowname but my program wont pick up the window name from cod4, so maybe if i made it find the window name of iwmp3.exe?

    thx in advance for the help.

  2. #2
    sgtmattbaker's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Posts
    85
    Reputation
    10
    Thanks
    8
    You need to look up the FindWindow function on msdn, FindWindows first parameter is the class name not window name, so flip them around. If it still doesnt work maybe try EnumWindows.

    Heres FindWindow paramaters:
    HWND FindWindow(
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName
    );

  3. #3
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by sgtmattbaker View Post
    You need to look up the FindWindow function on msdn, FindWindows first parameter is the class name not window name, so flip them around. If it still doesnt work maybe try EnumWindows.

    Heres FindWindow paramaters:
    HWND FindWindow(
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName
    );
    i already know how to use that and it wont work for cod4.
    i need a function that will give me the windowname from the filename

  4. #4
    radnomguywfq3's Avatar
    Join Date
    Jan 2007
    Gender
    male
    Location
    J:\E\T\A\M\A\Y.exe
    Posts
    8,858
    Reputation
    381
    Thanks
    1,823
    My Mood
    Sad
    Quote Originally Posted by qsc View Post
    i already know how to use that and it wont work for cod4.
    i need a function that will give me the windowname from the filename
    The image name of a process represents it's file name. If you need to locate a process by using the file on the harddrive, That's not possible, as multiple processes can be created with a single executable file. However, if the program is not hidden from the user. You can take a look at the EnumProcesses API to receive all running process's ID. Store them in an array of Unsigned Longs(or DWORD)'s, then use OpenProcess to get a handle each process, pass the handle to GetModuleFileName to get it's file name and filter for Cod.exe or w\e the target is called. If it's the incorrect handle, close it, otherwise, keep it and do whatever you need with it.

Similar Threads

  1. [Help] Finding memory ranges of self--process
    By yodaliketaco in forum C++/C Programming
    Replies: 2
    Last Post: 07-08-2011, 12:21 PM
  2. why the hell cant i find the process for AVA in my task manager?
    By girthboy in forum Alliance of Valiant Arms (AVA) Hacks & Cheats
    Replies: 9
    Last Post: 01-01-2010, 01:15 AM
  3. [Discussion] MHS- Cant find process for blackshot
    By xbsbug in forum Blackshot Hacks & Cheats
    Replies: 1
    Last Post: 09-12-2009, 06:46 AM
  4. find hidden process's easy
    By Chevalier83 in forum C++/C Programming
    Replies: 2
    Last Post: 07-22-2009, 03:22 PM
  5. my program cant find a process id
    By joost.d in forum WarRock - International Hacks
    Replies: 3
    Last Post: 07-27-2007, 08:22 PM

Tags for this Thread