为什么
HANDLE mutexHandle = INVALID_HANDLE_VALUE; WaitForSingleObject(mutexHandle,INFINITE);
块?它不会返回错误消息.检查INVALID_HANDLE的句柄对于互斥锁来说是愚蠢的,因为我需要一个互斥锁来访问互斥锁句柄…
从
@L_403_0@开始:
Fourth,you have to be particularly careful with the
INVALID_HANDLE_VALUE
value: By coincidence,the valueINVALID_HANDLE_VALUE
happens to be numerically equal to the pseudohandle returned byGetCurrentProcess()
. Many kernel functions accept pseudohandles,so if if you mess up and accidentally call,say,WaitForSingleObject
on a FailedINVALID_HANDLE_VALUE
handle,you will actually end up waiting on your own process. This wait will,of course,never complete,because a process is signalled when it exits,so you ended up waiting for yourself.