当前位置:首页 > CloseHandle()报错: 0xC0000008: An invalid handle was specified 的解决方法

CloseHandle()报错: 0xC0000008: An invalid handle was specified 的解决方法

点击次数:7997  更新日期:2014-08-06

调用CloseHandle(hBitmap)时报错: 0xC0000008: An invalid handle was specified

改为FindClose(hBitmap); 就可以了


这是msdn上关于CloseHandle的注释:

If the application is running under a debugger, the function will throw an exception if it receives either a handle value that is not valid or a pseudo-handle value. This can happen if you close a handle twice, or if you call CloseHandle on a handle returned by the FindFirstFile function instead of calling the FindClose  function.


如果你是使用 CloseHandle 来关闭一个用FindFirstFile这个方法返回的Handle,就应该使用FindClose 这个方法来替代