本文整理汇总了C++中OpenEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ OpenEvent函数的具体用法?C++ OpenEvent怎么用?C++ OpenEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OpenEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KillPdump
/*****************************************************************************
FUNCTION : KillPdump
PURPOSE :
PARAMETERS :
RETURNS :
*****************************************************************************/
static void KillPdump(void)
{
HANDLE hEvent;
HANDLE hExitDoneEvent;
/*
Get a handle on the pdump finished event
*/
if ((hExitDoneEvent=OpenEvent(EVENT_MODIFY_STATE, IMG_FALSE, PDUMP_EXITDONE_EVENT_NAME)) == NULL)
{
printf("Failed to open pdump exit done event, are you sure pdump is running?\n");
return;
}
/*
Gen a kill pdump event
*/
if ((hEvent=OpenEvent(EVENT_MODIFY_STATE, IMG_FALSE, PDUMP_EXIT_EVENT_NAME)) == NULL)
{
printf("Failed to open pdump exit event, are you sure pdump is running?\n");
return;
}
if (SetEvent(hEvent) == IMG_FALSE)
{
printf("Failed to set pdump exit event!\n");
return;
}
printf("Waiting for pdump to exit.....\n");
WaitForSingleObject(hExitDoneEvent, INFINITE);
CloseHandle(hEvent);
CloseHandle(hExitDoneEvent);
return;
}
示例2: StopIPCD
void
StopIPCD()
{
HANDLE hServerStopEvent=NULL;
#ifdef TERMINAL_SERVICE
char *evtname;
#endif /* TERMINAL_SERVICE */
#ifdef TERMINAL_SERVICE
if( osvi.dwMajorVersion >= 5 ) /* Windows 2000 */
evtname = "Global\\IPCDSTOP";
else
evtname = "IPCDSTOP";
#endif /* TERMINAL_SERVICE */
#ifdef TERMINAL_SERVICE
hServerStopEvent=OpenEvent( EVENT_ALL_ACCESS, FALSE, evtname );
#else
hServerStopEvent=OpenEvent( EVENT_ALL_ACCESS, FALSE, "IPCDSTOP" );
#endif /* TERMINAL_SERVICE */ksh
if (hServerStopEvent == NULL)
{
sprintf(tbuf, "IPC DAEMON is inactive ...\n");
MessageBox(NULL, tbuf, "IPC DAEMON", MB_OK);
return;
}
SetEvent(hServerStopEvent);
CloseHandle(hServerStopEvent);
}
示例3: InitFernel
BOOL InitFernel (void)
{
// The fernel32 dll for the File I/O Profiler creates private data that
// can't be seen by ohter processec (eg. apf32dmp). Hence, the two
// processes need to communicate through shared memory (so that apf32dmp
// can pass the name of the file to keep the dumped data to the fernel32
// dll) and events (so that apf32dmp can signal the fernel32 dll that a
// dump or a clear of the collected data should take place
// Here we create the shared memory section and open the handles to
// the Dump and Clear data events.
//
// Note: A Dump/Clear will make all processes profiled with the
// fernel32 dll dump/clear their data
hDumpFileMapping = OpenFileMapping ( FILE_MAP_WRITE, FALSE,
L"FileProfDumpFileName" );
wszDumpFile = (LPWSTR) MapViewOfFile ( hDumpFileMapping, FILE_MAP_WRITE,
0, 0, MAXFILENAMELEN );
hDumpEvent = OpenEvent ( EVENT_MODIFY_STATE, FALSE,
L"FileProfDumpEvent" );
hClearEvent = OpenEvent ( EVENT_MODIFY_STATE, FALSE,
L"FileProfClearEvent" );
return ( (hDumpFileMapping!=(HANDLE) NULL) && (wszDumpFile!=(LPWSTR) NULL) &&
(hDumpEvent!=(HANDLE) NULL) && (hClearEvent!=(HANDLE) NULL) );
}
示例4: CSerialPort
CScheduler::CScheduler(int pno)
: CSerialPort(pno)
{
char name[32];
spac_shm * shm = (spac_shm *)&ports[m_iPortNo-1];
SECURITY_DESCRIPTOR sd, *pSD;
SECURITY_ATTRIBUTES sa,*_sa;
this->m_iPortNo = m_iPortNo;
pSD = &sd;
if (pSD == NULL){
utils_error("Error creating security descriptor.\n");
return;
}
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)){
utils_error("Error initializing security descriptor.\n");
return;
}
// Add a NULL DACL to the security descriptor..
// see MSDN Knowledge base Q106387 for detail
if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE)){
utils_error("Error setting security descriptor.\n");
return;
}
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = TRUE;
_sa=&sa;
sprintf(name,"rtkm_spac_event_0_%d",m_iPortNo);
m_hEvents[0]=CreateEvent(_sa, 0, 0, name);
if(!m_hEvents[0]){
m_hEvents[0]=OpenEvent(EVENT_ALL_ACCESS,0,name);
}
sprintf(name,"rtkm_spac_event_1_%d",m_iPortNo);
m_hEvents[1]=CreateEvent(_sa, 0, 0, name);
if(!m_hEvents[1]){
m_hEvents[1]=OpenEvent(EVENT_ALL_ACCESS,0,name);
}
shm->is_open=false;
if(!m_hEvents[0] || !m_hEvents[1]){
utils_error(
">> COM%d, Error creating event, code %d.\n",
m_iPortNo,
GetLastError()
);
m_hEvents[0]? CloseHandle(m_hEvents[0]) : 0;
m_hEvents[1]? CloseHandle(m_hEvents[1]) : 0;
return;
}
ports[m_iPortNo-1].port_no=m_iPortNo;
}
示例5: CreateWow64Events
BOOL CreateWow64Events(DWORD pid, HANDLE *hParent, HANDLE *hChild,
BOOL bOpenExisting) {
SECURITY_ATTRIBUTES sa;
char parentname[256],childname[256];
*hParent = *hChild = NULL;
// make darn sure they're not inherited
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor =0;
sa.bInheritHandle = FALSE;
//
#pragma warning(disable:4995)
// This event tells the child to hold for gForkData to be copied
wsprintfA(parentname, "Local\\%d-%s",pid, TCSH_WOW64_PARENT_EVENT_NAME);
wsprintfA(childname, "Local\\%d-%s",pid, TCSH_WOW64_CHILD_EVENT_NAME );
#pragma warning(default:4995)
*hParent = OpenEvent(EVENT_ALL_ACCESS,FALSE, parentname);
if(*hParent) {
if (bOpenExisting == FALSE) { // didn't expect to be a child process
CloseHandle(*hParent);
*hParent = NULL;
return FALSE;
}
*hChild = OpenEvent(EVENT_ALL_ACCESS,FALSE, childname);
if (!*hChild) {
CloseHandle(*hParent);
*hParent = NULL;
return FALSE;
}
return TRUE;
}
else { //event does not exist
if (bOpenExisting == TRUE)
return FALSE;
}
*hParent = CreateEvent(&sa,FALSE,FALSE,parentname);
if (!*hParent)
return FALSE;
*hChild = CreateEvent(&sa,FALSE,FALSE,childname);
if (!*hChild){
CloseHandle(*hParent);
*hParent = NULL;
return FALSE;
}
return TRUE;
}
示例6: MonitorThread
DWORD __stdcall MonitorThread(VOID* Parameter)
{
HANDLE processEvent;
HANDLE d3dImageEvent;
VOID *handles[2];
processEvent = OpenEvent(L"Global\\" PUSH_PROCESS_EVENT_NAME);
d3dImageEvent = OpenEvent(L"Global\\" PUSH_IMAGE_EVENT_NAME);
handles[0] = processEvent;
handles[1] = d3dImageEvent;
while (processEvent)
{
NTSTATUS result;
HANDLE threadHandle;
result = NtWaitForMultipleObjects(2, &handles[0], WaitAny, FALSE, NULL);
if (processEvent && handles[result - STATUS_WAIT_0] == processEvent)
{
NtCreateThreadEx(
&threadHandle,
THREAD_ALL_ACCESS,
NULL,
NtCurrentProcess(),
&RetrieveProcessEvent,
NULL,
NoThreadFlags,
0, 0, 0,
NULL
);
}
else if (handles[result - STATUS_WAIT_0] == d3dImageEvent)
{
NtCreateThreadEx(
&threadHandle,
THREAD_ALL_ACCESS,
NULL,
NtCurrentProcess(),
&RetrieveImageEvent,
NULL,
NoThreadFlags,
0, 0, 0,
NULL
);
}
}
return 0;
}
示例7: InitMemCard
/* in : val 0 or 1 (コントローラとの併用 : 1) */
void InitMemCard(long val)
{
InitCARD(val); /* 通常 val=1 : コントローラと併用 */
StartCARD();
_bu_init();
ChangeClearPAD(0);
EnterCriticalSection();
ev0 = OpenEvent(SwCARD, EvSpIOE, EvMdNOINTR, NULL);
ev1 = OpenEvent(SwCARD, EvSpERROR, EvMdNOINTR, NULL);
ev2 = OpenEvent(SwCARD, EvSpTIMOUT, EvMdNOINTR, NULL);
ev3 = OpenEvent(SwCARD, EvSpNEW, EvMdNOINTR, NULL);
ev10 = OpenEvent(HwCARD, EvSpIOE, EvMdNOINTR, NULL);
ev11 = OpenEvent(HwCARD, EvSpERROR, EvMdNOINTR, NULL);
ev12 = OpenEvent(HwCARD, EvSpTIMOUT, EvMdNOINTR, NULL);
ev13 = OpenEvent(HwCARD, EvSpNEW, EvMdNOINTR, NULL);
ExitCriticalSection();
EnableEvent(ev0);
EnableEvent(ev1);
EnableEvent(ev2);
EnableEvent(ev3);
EnableEvent(ev10);
EnableEvent(ev11);
EnableEvent(ev12);
EnableEvent(ev13);
}
示例8: main
int main()
{
HANDLE isWait=OpenEvent(EVENT_MODIFY_STATE, FALSE, "test");
SetEvent(isWait);
getchar();
return 0;
}
示例9: OpenFileMapping
bool APIDataReceiver::startup() {
if(!memMapFileHandle)
{
memMapFileHandle = OpenFileMapping( FILE_MAP_READ, FALSE, IRSDK_MEMMAPFILENAME);
lastTickCount = std::numeric_limits<int>::max();
}
if(memMapFileHandle)
{
if(!sharedMem)
{
sharedMem = static_cast<const char*>(MapViewOfFile(memMapFileHandle, FILE_MAP_READ, 0, 0, 0));
header = reinterpret_cast<const irsdk_header*>(sharedMem);
lastTickCount = std::numeric_limits<int>::max();
}
if(sharedMem)
{
if(!dataValidEventHandle)
{
dataValidEventHandle = OpenEvent(SYNCHRONIZE, false, IRSDK_DATAVALIDEVENTNAME);
lastTickCount = std::numeric_limits<int>::max();
}
if(dataValidEventHandle)
{
initialized = true;
return true;
}
}
}
initialized = false;
return false;
}
示例10: OpenEvent
bool
CMSWindowsKeyState::fakeCtrlAltDel()
{
if (!m_is95Family) {
// to fake ctrl+alt+del on the NT family we broadcast a suitable
// hotkey to all windows on the winlogon desktop. however, the
// current thread must be on that desktop to do the broadcast
// and we can't switch just any thread because some own windows
// or hooks. so start a new thread to do the real work.
HANDLE hEvtSendSas = OpenEvent( EVENT_MODIFY_STATE, FALSE, "Global\\SendSAS" );
if ( hEvtSendSas ) {
LOG((CLOG_DEBUG "found the SendSAS event - signaling my launcher to simulate ctrl+alt+del"));
SetEvent( hEvtSendSas );
CloseHandle( hEvtSendSas );
}
else {
CThread cad(new CFunctionJob(&CMSWindowsKeyState::ctrlAltDelThread));
cad.wait();
}
}
else {
// simulate ctrl+alt+del
fakeKeyDown(kKeyDelete, KeyModifierControl | KeyModifierAlt,
virtualKeyToButton(VK_DELETE));
}
return true;
}
示例11: resetSyncAborted
bool resetSyncAborted()
{
HANDLE syncAbortEvent = NULL;
bool ret = false;
syncAbortEvent = OpenEvent(EVENT_ALL_ACCESS,
FALSE,
TEXT("Global\\AbortSyncEvent"));
if (syncAbortEvent == NULL) {
DWORD err = GetLastError();
// if event wasn't created don't log any error:
if (err != ERROR_FILE_NOT_FOUND) {
LOG.error("%s: error opening sync abort event: %d", __FUNCTION__, err);
}
return ret;
}
if (! ResetEvent(syncAbortEvent) ) {
LOG.error("%s: error resetting cancelled sync event handle", __FUNCTION__);
ret = false;
}
CloseHandle(syncAbortEvent);
return ret;
}
示例12: xampp_stop
void xampp_stop(char *pidfile,char *eventformat)
{
HANDLE shutdownEvent;
char shutdownEventName[32];
FILE *fp;
long pid;
fp=fopen(pidfile,"r");
if(!fp)
{
printf("Can't find %s.\n", pidfile);
}
else
{
fscanf(fp,"%d", &pid);
fclose(fp);
sprintf_s(shutdownEventName, sizeof(shutdownEventName), eventformat, pid);
shutdownEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, shutdownEventName);
if (shutdownEvent != NULL)
{
SetEvent(shutdownEvent);
}
else
{
printf("Can't find process #%d.\n", pid);
}
}
}
示例13: OCAC_PWrkStop
static int OCAC_PWrkStop(OCACProc *pProc)
{
HANDLE hCREvt;
BOOL bResult;
int nProcExit = CA_PROC_EXIT_OK;
hCREvt = OpenEvent(EVENT_ALL_ACCESS,TRUE, OCASS_EVT_NAME_SHELL_WRK);
if (NULL == hCREvt)
{
nProcExit = CA_PROC_EXIT_FATAL;
OCAC_Panic(CA_SRC_MARK,
TEXT("Can't open event %s. system error %u"),
OCASS_EVT_NAME_SPY_RUN, GetLastError());
goto EXIT;
}
bResult = SetEvent(hCREvt);
CloseHandle(hCREvt);
if (!bResult)
{
nProcExit = CA_PROC_EXIT_FATAL;
OCAC_Panic(CA_SRC_MARK,
TEXT("Set event %s failed. system error %u"),
OCASS_EVT_NAME_SPY_RUN, GetLastError());
goto EXIT;
}
OCAC_PrintMsgLine(TEXT("Send shutdown event successed"));
EXIT:
return nProcExit;
}
示例14: ngx_os_signal_process
ngx_int_t
ngx_os_signal_process(ngx_cycle_t *cycle, char *sig, ngx_int_t pid)
{
HANDLE ev;
ngx_int_t rc;
char evn[NGX_PROCESS_SYNC_NAME];
ngx_sprintf((u_char *) evn, "Global\\ngx_%s_%ul%Z", sig, pid);
ev = OpenEvent(EVENT_MODIFY_STATE, 0, evn);
if (ev == NULL) {
ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno,
"OpenEvent(\"%s\") failed", evn);
return 1;
}
if (SetEvent(ev) == 0) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"SetEvent(\"%s\") failed", evn);
rc = 1;
} else {
rc = 0;
}
ngx_close_handle(ev);
return rc;
}
示例15: _snprintf
DWORD CMySql::StopExe()
{
DWORD dwRetour = ERROR_SUCCESS;
HANDLE hEventShutdown = NULL;
char szShutdownEvent[31] = {0};
_snprintf(szShutdownEvent, sizeof(szShutdownEvent)-1, "MySQLShutdown%u", GetProcID());
CUtils::Log("MySqlSutdown event = %s", szShutdownEvent);
if ((hEventShutdown=OpenEvent(EVENT_MODIFY_STATE, 0, szShutdownEvent)) != NULL)
{
SetEvent(hEventShutdown);
CloseHandle(hEventShutdown);
}
else
{
dwRetour = GetLastError();
CUtils::Log("MySqlSutdown event open fail = %d", dwRetour);
// if (dwRetour==ERROR_FILE_NOT_FOUND || )
{
char szToExecute[MAX_PATH+50] = {0};
_snprintf(szToExecute, sizeof(szToExecute)-1, "%sbin\\mysqladmin.exe -u root shutdown", (LPCTSTR) m_sMySqlPath);
dwRetour = WinExec(szToExecute, SW_HIDE);
if (dwRetour > 31)
dwRetour = ERROR_SUCCESS;
}
}
return dwRetour;
}