Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Get window title

Get window title

Scheduled Pinned Locked Moved C++ Gurus
7 Posts 2 Posters 6.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monkey666
    wrote on 1 Aug 2011, 15:00 last edited by
    #1

    I have the window process handle and id, how would I get the window title?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on 1 Aug 2011, 15:07 last edited by
      #2

      For Windows?
      See getWindowText function in WinAPI reference

      --
      Vasiliy

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Monkey666
        wrote on 1 Aug 2011, 15:22 last edited by
        #3

        Ok I have and I've found this and added in to my code so like:

        @
        char buffer[65536];
        ProcInfo *p = new ProcInfo();
        HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS,FALSE,entry.th32ProcessID);
        int txtlen=GetWindowTextLengthW(hProc);
        GetWindowText(hProc, buffer, txtlen);
        @

        Error is on line 4:

        invalid conversion from 'void*' to 'HWND__*'

        Someone told me I would find it easy learning C++ already knowing C# pretty well, but most of this just doesn't seem to make any sense :/

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsorokin
          wrote on 1 Aug 2011, 15:33 last edited by
          #4

          Try
          @int txtlen=GetWindowTextLengthW((HWND__*)hProc);@

          Hehe, It almost not touch c++ and c# differences.

          Just Welcome to world without GC and safe-type conversions. :D
          Welcome to world of WinAPI :)

          --
          Vasiliy

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Monkey666
            wrote on 1 Aug 2011, 19:32 last edited by
            #5

            Hey bro, I added what you explained above to what I posted but it just returns a single random letter each time, any ideas why it's not getting the window title?

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vsorokin
              wrote on 1 Aug 2011, 20:45 last edited by
              #6

              Oh... I'm was mistake too. I hate winapi :)

              I did google very long and...
              NOT simple ways get HWND from HANDLE

              But I find difficult way, may be you can repeat this for your program.
              http://www.codeguru.com/forum/showpost.php?p=1213838&postcount=3

              It's really stupid crazy method. But I'm not found anymore.

              So, now I understand why Win developer hate C++ - winapi is unbelievable crap.

              Hey, go to Linux - go to dark side - we still have cookies. :D

              --
              Vasiliy

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Monkey666
                wrote on 1 Aug 2011, 20:55 last edited by
                #7

                I'll check it out bro, thanks for the help :) And Linux {No Thanks!} lol, my applications are designed for windows users which I generally develop in C#, however I am trying to 'up my game' with C++, but I fear I have let myself in for a world of hurt.

                1 Reply Last reply
                0

                7/7

                1 Aug 2011, 20:55

                • Login

                • Login or register to search.
                7 out of 7
                • First post
                  7/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved