Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can i hook native win32 api code into Qt code?
Forum Updated to NodeBB v4.3 + New Features

Can i hook native win32 api code into Qt code?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.1k 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.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    Hi
    im looking for away to disable the windows key , i didnt find any problematically way in Qt but did found some code in native win32 code
    my question is can i hook this code into Qt somehow
    here is the link to the code:
    "http://www.programmersheaven.com/mb/windows/344596/344659/problem-solved/":http://www.programmersheaven.com/mb/windows/344596/344659/problem-solved/

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      Should be no problem. I do it all the time.

      You can use QLibrary to dynamically load Win32 functions that may be missing from older Win32 versions:

      @typedef HRESULT (WINAPI *SHGetKnownFolderPathFun)(__in const GUID &rfid, __in DWORD dwFlags, __in HANDLE hToken, __out PWSTR *ppszPath);
      typedef HRESULT (WINAPI *SHGetFolderPathFun)(__in HWND hwndOwner, __in int nFolder, __in HANDLE hToken, __in DWORD dwFlags, __out LPWSTR pszPath);

      static SHGetKnownFolderPathFun SHGetKnownFolderPathPtr = NULL;
      static SHGetFolderPathFun SHGetFolderPathPtr = NULL;

      if((!SHGetKnownFolderPathPtr) && (!SHGetFolderPathPtr))
      {
      QLibrary kernel32Lib("shell32.dll");
      if(kernel32Lib.load())
      {
      SHGetKnownFolderPathPtr = (SHGetKnownFolderPathFun) kernel32Lib.resolve("SHGetKnownFolderPath");
      SHGetFolderPathPtr = (SHGetFolderPathFun) kernel32Lib.resolve("SHGetFolderPathW");
      }
      }

      if(SHGetKnownFolderPathPtr)
      {
      WCHAR path = NULL;
      if(SHGetKnownFolderPathPtr(folderGUID, 0x00008000, NULL, &path) == S_OK)
      {
      /
      ... */
      }
      }@

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        wow thanks for the response but your example to messy i can't understand any thing

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          Messy? It's just a small code excerpt showing the basic idea ;)

          The typedef's define the required function pointer types for the functions we want to call.

          If you are not familiar with function pointers, please see:
          http://www.newty.de/fpt/fpt.html

          Next we will use QLibrary to load the DLL that contains the functions, "shell32.dll" in this example.

          Once the library is loaded, we resolve() the desired entry point (e.g. ""SHGetKnownFolderPath") and assign the result to our function pointer variable. If the result is non-NULL, i.e. the entry point was found, we call it...

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0

          • Login

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