Thomas Weidenmueller wrote:
Joseph Galbraith wrote:
If CreateMutex() returns NULL, it failed for some other reason (than that the mutex already existed, since CreateMutex doesn't fail in this case.)
Quote from the PSDK: "If lpName matches the name of an existing event, semaphore, waitable timer, job, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same name space."
Ahh... I see the confusion; I'll counter with another quote from the platform SDK:
Return Values
If the function succeeds, the return value is a handle to the mutex object. If the named mutex object existed before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS. Otherwise, the caller created the mutex.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
If you read your quote carefully, you'll notice that it is refering to existing events, semaphores, waitable timers, jobs, or file-mapping objets... mutex is notably absent from the list. The key is the last sentance: "This occurs because these objects [the ones listed] share the same name space [as mutex objects.]
I do see now where the confusion comes from though; at first I was just going to respond that the two pieces of platform SDK documentation were in conflict, and the one I quoted is the behavior observed experimentally... then I read carefully.
Thanks,
Joseph