01-CreateMutexspa
做用是找出當前系統是否已經存在指定進程的實例。若是沒有則建立一個互斥體code
例如:blog
1 int main() 2 { 3 HANDLE m_hMutex = CreateMutex(NULL, FALSE, TEXT("jerry")); 4 if (GetLastError() == ERROR_ALREADY_EXISTS) 5 { 6 return 0; 7 } 8 else 9 { 10 printf("The instance does not exist!"); 11 } 12 13 getchar(); 14 return 0; 15 }