-1

I have a path of a process, I would like to get it's window title in C++.

Let's assume that this process has only one window.

So for example my process path is :

C:\Program Files\My Program\program.exe which is a running process's path, and I would like to get it's windows title.

Thanks.

rdanee
  • 109
  • 1
  • 1
  • 9
  • 1
    What have you tried so far and what is an executive? If you mean executable then look into api's such as getprocess() getwindowhandle() – Twifty Jul 17 '13 at 06:45
  • 1
    Who says a process has only one window? – chris Jul 17 '13 at 06:48
  • 2
    And who says that pocess have at least one window? And there's no two process running at the same time? In any case you can try use EnumWindows for enumerate all windows, or use FindWindow if you know title of window. – user1837009 Jul 17 '13 at 06:51
  • Yes, I mean executable. Let's assume the process has only one window, always. So I should enumerate all windows and somehow I should check their's path? – rdanee Jul 17 '13 at 07:16
  • I have updated the question, I hope its better now. – rdanee Jul 17 '13 at 07:54
  • To make your question answer suitable for SO, try one the suggestions in the comments and ask a specific question, one with an error message or some code that does not work like you think it should. The process will reward you more than reputation points ever will. – ixe013 Jul 17 '13 at 15:18

1 Answers1

0

Assuming there is only 1 window in the process, and assuming there is only one copy of the executable running at a time, then you can use EnumWindows() to enumerate top-level windows, calling GetWindowThreadProcessId(), OpenProcess() and GetModuleFileNameEx() on each window to get its owning process's path, and if you find a matching path then you can use GetWindowText() to get that window's title and stop the enumeration.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770