When you call
CreateMutex[
^] function in both processes, specify the same name (last parameter,
lpName). This function first tries to find a mutex with specified name, and if such mutex exists, returns its handle; otherwise, it creates new mutex. So, the first process to call CreateMutex(, , "MyMutex") shall try to find "MyMutex", fail to do that and then create mutex "MyMutex". Call from the second process discovers existing object and returns its handle (you can check that mutex is opened, not newly created, by calling
GetLastError() function, it should return ERROR_ALREADY_EXISTS code).
One more note: when you select mutex name, decide whether you want this mutex to be accessible across user sessions or not. When more than one user is logged in on the same computer simultaneously, kernel object's names from one user session won't be visible in another session unless they start with "Global\" prefix (see more about kernel object namespaces
here[
^])