Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error C3861: 'GetCurrentThreadID': identifier not found

error C3861: 'GetCurrentThreadID': identifier not found

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiotoolshelpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • 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.
  • G Offline
    G Offline
    glyfyx
    wrote on last edited by
    #1

    In a Win32 app I am able to set global keyboard hooks, but not a local hook. I've coded the call as required for a local hook but it complains that GetCurrentThreadID can't be found. But I see that winbase.h (invoked by windows.h) contains the following declaration of GetCurrentThreadId: WINBASEAPI DWORD WINAPI GetCurrentThreadId( VOID ); The following call setting a global hook works fine: HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, hinstExe, 0); The identical pgm with the following call setting a LOCAL hook fails: HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, NULL, GetCurrentThreadID()); The error it gives is: error C3861: 'GetCurrentThreadID': identifier not found, even with argument-dependent lookup I've seen docs saying that GetCurrentThreadID is deprecated, but there's no alternative given. Surely there must be some way a thread can find out its own thread id, but I haven't been able to find out how. I'm using VS 2003 tools. Any ideas anyone? Many thanks in advance! glyfyx

    M 2 Replies Last reply
    0
    • G glyfyx

      In a Win32 app I am able to set global keyboard hooks, but not a local hook. I've coded the call as required for a local hook but it complains that GetCurrentThreadID can't be found. But I see that winbase.h (invoked by windows.h) contains the following declaration of GetCurrentThreadId: WINBASEAPI DWORD WINAPI GetCurrentThreadId( VOID ); The following call setting a global hook works fine: HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, hinstExe, 0); The identical pgm with the following call setting a LOCAL hook fails: HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, NULL, GetCurrentThreadID()); The error it gives is: error C3861: 'GetCurrentThreadID': identifier not found, even with argument-dependent lookup I've seen docs saying that GetCurrentThreadID is deprecated, but there's no alternative given. Surely there must be some way a thread can find out its own thread id, but I haven't been able to find out how. I'm using VS 2003 tools. Any ideas anyone? Many thanks in advance! glyfyx

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Try changing ID to Id. Mark

      "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

      1 Reply Last reply
      0
      • G glyfyx

        In a Win32 app I am able to set global keyboard hooks, but not a local hook. I've coded the call as required for a local hook but it complains that GetCurrentThreadID can't be found. But I see that winbase.h (invoked by windows.h) contains the following declaration of GetCurrentThreadId: WINBASEAPI DWORD WINAPI GetCurrentThreadId( VOID ); The following call setting a global hook works fine: HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, hinstExe, 0); The identical pgm with the following call setting a LOCAL hook fails: HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, NULL, GetCurrentThreadID()); The error it gives is: error C3861: 'GetCurrentThreadID': identifier not found, even with argument-dependent lookup I've seen docs saying that GetCurrentThreadID is deprecated, but there's no alternative given. Surely there must be some way a thread can find out its own thread id, but I haven't been able to find out how. I'm using VS 2003 tools. Any ideas anyone? Many thanks in advance! glyfyx

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        glyfyx wrote:

        I've seen docs saying that GetCurrentThreadID is deprecated

        As of Platform SDK R2, it's not marked deprecated. And, it's GetCurrentThreadId ;)

        "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

        G 1 Reply Last reply
        0
        • M Mark Salsbery

          glyfyx wrote:

          I've seen docs saying that GetCurrentThreadID is deprecated

          As of Platform SDK R2, it's not marked deprecated. And, it's GetCurrentThreadId ;)

          "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

          G Offline
          G Offline
          glyfyx
          wrote on last edited by
          #4

          Thanks Mark - very much!! That's what I get for spending the last several years doing VB! I won't do that again - even once is too often! Thanks again.. glyfyx

          M 1 Reply Last reply
          0
          • G glyfyx

            Thanks Mark - very much!! That's what I get for spending the last several years doing VB! I won't do that again - even once is too often! Thanks again.. glyfyx

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            glyfyx wrote:

            I won't do that again

            I wish I could say the same. That's my #1 typo! :) It'll always be ID to me, apparently.

            "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

            G 1 Reply Last reply
            0
            • M Mark Salsbery

              glyfyx wrote:

              I won't do that again

              I wish I could say the same. That's my #1 typo! :) It'll always be ID to me, apparently.

              "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

              G Offline
              G Offline
              glyfyx
              wrote on last edited by
              #6

              For the sake of closure on this thread, if you exactly follow Microsoft's rules to set a LOCAL low-level keyboard hook don't expect it to run because Microsoft forbids its execution. According to Microsoft the following will result in a setting a LOCAL hook: HHOOK hhkLowLevelKybd = SetWindowsHookEx( WH_KEYBOARD_LL, HookProc, NULL, GetCurrentThreadId()); However, it fails execution, returning NULL. I took the trouble to rerun it in order to get extended error information and got this surprising formatted error message in a MessageBox: "SetWindowsHookEx failed with error 1429: This hook procedure can only be set globally." Do I laugh or cry?

              M 1 Reply Last reply
              0
              • G glyfyx

                For the sake of closure on this thread, if you exactly follow Microsoft's rules to set a LOCAL low-level keyboard hook don't expect it to run because Microsoft forbids its execution. According to Microsoft the following will result in a setting a LOCAL hook: HHOOK hhkLowLevelKybd = SetWindowsHookEx( WH_KEYBOARD_LL, HookProc, NULL, GetCurrentThreadId()); However, it fails execution, returning NULL. I took the trouble to rerun it in order to get extended error information and got this surprising formatted error message in a MessageBox: "SetWindowsHookEx failed with error 1429: This hook procedure can only be set globally." Do I laugh or cry?

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                glyfyx wrote:

                "SetWindowsHookEx failed with error 1429: This hook procedure can only be set globally."

                That is documented under SetWindowsHookEx in the SDK. Low-level keyboard hooks key events before they are dispatched to a given thread message queue so it makes sense.

                glyfyx wrote:

                Do I laugh or cry?

                I try to cry first, then laugh. If it happens the other way around I'm in trouble :) Mark

                "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups