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. How to judge a handle?

How to judge a handle?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 4 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.
  • X Offline
    X Offline
    xi904
    wrote on last edited by
    #1

    Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi

    R P J 3 Replies Last reply
    0
    • X xi904

      Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi

      R Offline
      R Offline
      Roman Fadeyev
      wrote on last edited by
      #2

      GetHandleInformation()

      P 1 Reply Last reply
      0
      • R Roman Fadeyev

        GetHandleInformation()

        P Offline
        P Offline
        Paul M Watt
        wrote on last edited by
        #3

        Roman Fadeyev wrote: GetHandleInformation() Beware that function only works in Windows NT, it is not supported for Win9x OSs


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        1 Reply Last reply
        0
        • X xi904

          Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi

          P Offline
          P Offline
          Paul M Watt
          wrote on last edited by
          #4

          There are ways, but it depends on the type of handle that you are dealing with. Do you have a window handle, a GDI handle, a file handle, or something else?


          Build a man a fire, and he will be warm for a day
          Light a man on fire, and he will be warm for the rest of his life!

          1 Reply Last reply
          0
          • X xi904

            Hi, I have a windows handle which is returned by third party lib, this handle sometimes is valid, sometimes isn't. I want to know whether there is method or function to judge the validity of a handle? Thanks, Jeff Xi

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #5

            If it's a handle to a window, you can call IsWindow(). For other handles and Win98 compatibility, you could use DuplicateHandle() and check the error returns (don't forget to close the duplicated handle if successful.)

            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