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. First Chance Exception

First Chance Exception

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

    Hi, Im getting the following error while closing handle using CloseHandle() function. Can anyone please tell how to resolve this issue? First Chance Exception in test.exe(NTDLL.DLL):0xC0000008: Invalid Handle Thanks,

    C A N 3 Replies Last reply
    0
    • P Pryabu

      Hi, Im getting the following error while closing handle using CloseHandle() function. Can anyone please tell how to resolve this issue? First Chance Exception in test.exe(NTDLL.DLL):0xC0000008: Invalid Handle Thanks,

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      The error message is pretty clear no ? You are passing an invalid handle to the CloseHandle function. Use your debugger inspect what might be wrong.

      Cédric Moonen Software developer
      Charting control [v3.0] OpenGL game tutorial in C++

      P 1 Reply Last reply
      0
      • C Cedric Moonen

        The error message is pretty clear no ? You are passing an invalid handle to the CloseHandle function. Use your debugger inspect what might be wrong.

        Cédric Moonen Software developer
        Charting control [v3.0] OpenGL game tutorial in C++

        P Offline
        P Offline
        Pryabu
        wrote on last edited by
        #3

        no.In that folder,im having a image file and Using FindFirstFile function i got handle for that image file. After trying to close that handle the application is getting crashed and it is showing this error. wsprintf(szSearchFolder,"%s\\*.jpg","C:\\test"); hSearch = FindFirstFile (szSearchFolder, &Foldername); if (hSearch == INVALID_HANDLE_VALUE) { return ERR_FAILED; } CloseHandle(hSearch);

        N 1 Reply Last reply
        0
        • P Pryabu

          Hi, Im getting the following error while closing handle using CloseHandle() function. Can anyone please tell how to resolve this issue? First Chance Exception in test.exe(NTDLL.DLL):0xC0000008: Invalid Handle Thanks,

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          As Cedric said, you're passing an invalid handle to the function. Just because the value of the handle isn't INVALID_HANDLE_VALUE it doesn't mean the handle is valid. For example you might... - be using a handle someone else has already closed - you're using something uninitialised that contains some rubbish off the stack - you're overwriting the variable containing the HANDLE value with a wild pointer write - be doing something really perverse like HANDLE h( reinterpret_cast( std::rand() ) ); So there's loads of ways a HANDLE can be invalid and not have a value of INVALID_HANDLE_VALUE. Cheers, Ash

          P 1 Reply Last reply
          0
          • P Pryabu

            Hi, Im getting the following error while closing handle using CloseHandle() function. Can anyone please tell how to resolve this issue? First Chance Exception in test.exe(NTDLL.DLL):0xC0000008: Invalid Handle Thanks,

            N Offline
            N Offline
            Niklas L
            wrote on last edited by
            #5

            How about using FindClose()[^] as the documentation suggests instead of CloseHandle()?

            home

            1 Reply Last reply
            0
            • A Aescleal

              As Cedric said, you're passing an invalid handle to the function. Just because the value of the handle isn't INVALID_HANDLE_VALUE it doesn't mean the handle is valid. For example you might... - be using a handle someone else has already closed - you're using something uninitialised that contains some rubbish off the stack - you're overwriting the variable containing the HANDLE value with a wild pointer write - be doing something really perverse like HANDLE h( reinterpret_cast( std::rand() ) ); So there's loads of ways a HANDLE can be invalid and not have a value of INVALID_HANDLE_VALUE. Cheers, Ash

              P Offline
              P Offline
              Pryabu
              wrote on last edited by
              #6

              I have intialized the handle value to NULL in the declaration. HANDLE hSearch = NULL;

              1 Reply Last reply
              0
              • P Pryabu

                no.In that folder,im having a image file and Using FindFirstFile function i got handle for that image file. After trying to close that handle the application is getting crashed and it is showing this error. wsprintf(szSearchFolder,"%s\\*.jpg","C:\\test"); hSearch = FindFirstFile (szSearchFolder, &Foldername); if (hSearch == INVALID_HANDLE_VALUE) { return ERR_FAILED; } CloseHandle(hSearch);

                N Offline
                N Offline
                Naveen
                wrote on last edited by
                #7

                Karthika85 wrote:

                CloseHandle(hSearch);

                This is wrong. You should use FindClose() function to close the handle retured by FindFirstFile()

                nave [My Articles] [My Blog]

                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