>> But what sort of error could be returned from either GetLastError() or ERROR_ALREADY_EXISTS for a program that hasn't even started running!?
Surely the program is running since we are talking about the return value of GetLastError()
. (I don't quite get what you are saying there, sorry)
But, looking at the MSDN documentation, in case the named mutex has already been created;
If the mutex is a named mutex and the object existed before this function call, the return value is a handle (i.e. NOT NULL) to the existing object, GetLastError returns ERROR_ALREADY_EXISTS, bInitialOwner is ignored, and the calling thread is not granted ownership.
That should tell you what to check and how to interprete what GetLastError()
returns.