Windows 7上的命名事件 [英] Named Events on Windows 7
本文介绍了Windows 7上的命名事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿朋友
有人在Windows 7中使用过命名事件吗?
在命名事件中挣扎,只能在XP上运行,而不能在Windows 7上运行.
Hey Friends
Has anybody used Named Events in Windows 7 ?
Struggling with Named Events, Works on XP , but not on Windows 7.
SharedEvent = CreateEvent(NULL, FALSE, FALSE, "ProblemWithWin7Events");
if (SharedEvent == NULL)
{
AfxMessageBox("Cannot create named event!");
}
AfxBeginThread(ThreadProc,this);
并在线程中等待事件发信号
and in Thread Waiting for the Event to Signal
DWORD WaitStatus;
for(int vl_iIndex = 1; vl_iIndex <=1000;vl_iIndex ++)
{
WaitStatus = WaitForSingleObject(SharedEvent, INFINITE);
if (WaitStatus != WAIT_OBJECT_0)
{
TRACE("%d WaitForSingleObject Failed\n",vl_iIndex );
}
else
{
TRACE("%d WaitForSingleObject Works\n",vl_iIndex );
}
}
还创建了一个按钮来通知事件
Also created a Button to Signal the Event
void CTestApplicationForEventsDlg::OnBnClickedSignalEvent()
{
HANDLE vl_hEvent = OpenEvent(SYNCHRONIZE ,FALSE,"ProblemWithWin7Events");
if(vl_hEvent ==NULL)
{
AfxMessageBox("Could not Open Event");
return;
}
::SetEvent(vl_hEvent);
}
知道我在做什么错吗?
关于
Any idea of what i am doing wrong ?
Regards
推荐答案
是否可以尝试使用EVENT_ALL_ACCESS而不是SYNCHRONIZE,如下所示?
Can you try using EVENT_ALL_ACCESS instead of SYNCHRONIZE as shown below??
HANDLE vl_hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE,"ProblemWithWin7Events");
是的,更改OpenEvent参数(访问参数,第一个参数)解决了该问题,非常感谢大家在这里为我提供帮助.
yeah changing OpenEvent Parameter (Access Parameter , the First Parameter) solved the problem, thanks a lot all of you for helping me out here.
HANDLE vl_hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE,"ProblemWithWin7Events");
这篇关于Windows 7上的命名事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文