Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
CMutex(false、 "blah")を使用する複数のMFCアプリがあります。ここで、 "blah"を使用すると、ミューテックスがプロセスの境界を越えて機能します。
これらのアプリの1つは、MFCなしで書き直されました(代わりにQtを使用)。Win32呼び出しを使用してCMutexをシミュレートするにはどうすればよいですか?(QtのQMutexはプロセス間ではありません。)私はMFCアプリを変更したくないです。
プロセス間ミューテックスの場合、次の呼び出しが必要です。
CreateMutex WaitForSingleObject ReleaseMutex CloseHandle
CreateMutex
WaitForSingleObject
ReleaseMutex
CloseHandle
これらは、CMutexがラッパーである基礎となるWin32API呼び出しです。
インプロセスのみのミューテックスの場合は、次の呼び出しを使用することもできます。これはより高速です。
InitializeCriticalSection EnterCriticalSection LeaveCriticalSection DeleteCriticalSection
InitializeCriticalSection
EnterCriticalSection
LeaveCriticalSection
DeleteCriticalSection
次の関数はおそらくあなたが望むものでしょう。それらはすべて MSDN で文書化されています。
CreateMutex(...) WaitForSingleObject(...) ReleaseMutex(...)