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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SetWindowsHookEx failed

SetWindowsHookEx failed

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
8 Posts 3 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.
  • M Offline
    M Offline
    Member 14105155
    wrote on last edited by
    #1

    Look, guys, I have a code that worked properly under Windows XP 32 bit. hHookMsg = SetWindowsHookEx(WH_JOURNALPLAYBACK, hkprc, hInst, 0). But under Windows 7 64 bit this call failed and I got System Error Message "Acces denied" I tried this: hHookMsg = SetWindowsHookEx(WH_JOURNALPLAYBACK, hkprc, hInst, GetCurrentThreadId()) and this hHookMsg = SetWindowsHookEx(WH_JOURNALPLAYBACK, hkprc, (HINSTANCE)NULL, GetCurrentThreadId()) and got "This hook can be set only globally". Any ideas how to resolve the situation?

    L 1 Reply Last reply
    0
    • M Member 14105155

      Look, guys, I have a code that worked properly under Windows XP 32 bit. hHookMsg = SetWindowsHookEx(WH_JOURNALPLAYBACK, hkprc, hInst, 0). But under Windows 7 64 bit this call failed and I got System Error Message "Acces denied" I tried this: hHookMsg = SetWindowsHookEx(WH_JOURNALPLAYBACK, hkprc, hInst, GetCurrentThreadId()) and this hHookMsg = SetWindowsHookEx(WH_JOURNALPLAYBACK, hkprc, (HINSTANCE)NULL, GetCurrentThreadId()) and got "This hook can be set only globally". Any ideas how to resolve the situation?

      L Offline
      L Offline
      leon de boer
      wrote on last edited by
      #2

      They have put security around that sort of thing and you probably have to be running as administrator and it's likely going to throw a UAC to user to confirm it is okay. Goto MSDN and look at the documentation.

      In vino veritas

      M 1 Reply Last reply
      0
      • L leon de boer

        They have put security around that sort of thing and you probably have to be running as administrator and it's likely going to throw a UAC to user to confirm it is okay. Goto MSDN and look at the documentation.

        In vino veritas

        M Offline
        M Offline
        Member 14105155
        wrote on last edited by
        #3

        Sure. I do not need this option- it was intended to demonstrate how my prog works to another users. And they do no not like (and for a reason) when some soft wants administrative privileges.

        L 1 Reply Last reply
        0
        • M Member 14105155

          Sure. I do not need this option- it was intended to demonstrate how my prog works to another users. And they do no not like (and for a reason) when some soft wants administrative privileges.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Member 14105155 wrote:

          And they do no not like (and for a reason) when some soft wants administrative privileges.

          Well they are going to have to get used to it. Windows 10 (7 is out of support in a few days) uses this extensively in order to protect the users' systems from malicious software.

          M 1 Reply Last reply
          0
          • L Lost User

            Member 14105155 wrote:

            And they do no not like (and for a reason) when some soft wants administrative privileges.

            Well they are going to have to get used to it. Windows 10 (7 is out of support in a few days) uses this extensively in order to protect the users' systems from malicious software.

            M Offline
            M Offline
            Member 14105155
            wrote on last edited by
            #5

            Well, this is the reason to write soft that works without such privileges.

            L 1 Reply Last reply
            0
            • M Member 14105155

              Well, this is the reason to write soft that works without such privileges.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You do not have a choice. The operating system sets the rules, and your software must work within those rules.

              M 1 Reply Last reply
              0
              • L Lost User

                You do not have a choice. The operating system sets the rules, and your software must work within those rules.

                M Offline
                M Offline
                Member 14105155
                wrote on last edited by
                #7

                I do have. A program can ask a user if he let it run with privileges, but users dislike such soft. Therefore, the choice exists, but it is very poor one.

                L 1 Reply Last reply
                0
                • M Member 14105155

                  I do have. A program can ask a user if he let it run with privileges, but users dislike such soft. Therefore, the choice exists, but it is very poor one.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Member 14105155 wrote:

                  Therefore, the choice exists, but it is very poor one.

                  On the contrary it is a very good one, as it allows the user to control which programs are allowed to make significant changes to their system.

                  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