HANDLE hMutex; // Create a mutex with no initial owner.hMutex = CreateMutex(
NULL, // no security attributes
FALSE, // initially not owned
"MutexToProjectSet"); // name of mutexif (hMutex == NULL)
{
// Check for error.
}
BOOL FunctionToWriteToSet(HANDLE hMutex)
{
DWORD dwWaitResult; // Request ownership of mutex.
dwWaitResult = WaitForSingleObject(
hMutex, // handle to mutex
5000L); // five-second time-out interval
switch (dwWaitResult)
{
// The thread got mutex ownership.
case WAIT_OBJECT_0:
__try {
// Write to the set.
} __finally {
// Release ownership of the mutex object.
if (! ReleaseMutex(hMutex)) {
// Deal with error.
} break;
} // Cannot get mutex ownership due to time-out.
case WAIT_TIMEOUT:
return FALSE; // Got ownership of the abandoned mutex object.
case WAIT_ABANDONED:
return FALSE;
} return TRUE;
}
NULL, // no security attributes
FALSE, // initially not owned
"MutexToProjectSet"); // name of mutexif (hMutex == NULL)
{
// Check for error.
}
BOOL FunctionToWriteToSet(HANDLE hMutex)
{
DWORD dwWaitResult; // Request ownership of mutex.
dwWaitResult = WaitForSingleObject(
hMutex, // handle to mutex
5000L); // five-second time-out interval
switch (dwWaitResult)
{
// The thread got mutex ownership.
case WAIT_OBJECT_0:
__try {
// Write to the set.
} __finally {
// Release ownership of the mutex object.
if (! ReleaseMutex(hMutex)) {
// Deal with error.
} break;
} // Cannot get mutex ownership due to time-out.
case WAIT_TIMEOUT:
return FALSE; // Got ownership of the abandoned mutex object.
case WAIT_ABANDONED:
return FALSE;
} return TRUE;
}
解决方案 »
- 这中界面效果这样做行么
- 《新手求救》如何treectrl同时选择多个节点??
- 求救,线程
- 再加一问:我给formview的sdi程序添加滑杆条(CSliderCtrl)后发现她总是要相应键盘的home end 及箭头等能否把滑杆条对箭头的响应封掉?
- ★★★★★数据表中的+++记录复制+++问题????(答上者加满分!)
- 这三个东东到底有多大的区别?对高手来说应该SO EASY!
- 如何使用代理服务器的Socket5协议,我想做个在局域网通过代理聊天的程序?
- 关于Socket的问题。
- 请教串口通讯中接收数据前的延时设置
- 特别简单的问题!!!
- ADO问题,大侠请进!29分全送了(本人所有的积蓄)
- 为什么我只能给51分?
我要存放含有一个整数和一个字符串的结构,整数有重复
该用什么类 CList,CArray还是CMap
看看MSDN中 Collections 的例子吧, 它最适合你的应用了。