本文整理汇总了C++中CreateEventW函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateEventW函数的具体用法?C++ CreateEventW怎么用?C++ CreateEventW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateEventW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIME_MMTimeStart
/**************************************************************************
* TIME_MMTimeStart
*/
void TIME_MMTimeStart(void)
{
if (!TIME_hMMTimer) {
TIME_TimersList = NULL;
TIME_hWakeEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
TIME_TimeToDie = FALSE;
TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, NULL, 0, NULL);
SetThreadPriority(TIME_hMMTimer, THREAD_PRIORITY_TIME_CRITICAL);
}
}
示例2: blThreadEventCreate
BLResult blThreadEventCreate(BLThreadEvent* self, bool manualReset, bool signaled) noexcept {
HANDLE h = CreateEventW(nullptr, manualReset, signaled, nullptr);
if (BL_UNLIKELY(!h)) {
self->handle = -1;
return blTraceError(blResultFromWinError(GetLastError()));
}
self->handle = (intptr_t)h;
return BL_SUCCESS;
}
示例3: d
Timer::Timer(TelldusCore::EventRef event)
:TelldusCore::Thread(), d(new PrivateData) {
d->event = event;
#ifdef _WINDOWS
d->cond = CreateEventW(NULL, false, false, NULL);
#else
pthread_cond_init(&d->cond, NULL);
pthread_mutex_init(&d->waitMutex, NULL);
#endif
}
示例4: threadId
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
: threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0)
{
resolveTimerAPI();
wakeUpNotifier.setHandle(QT_WA_INLINE(CreateEventW(0, FALSE, FALSE, 0),
CreateEventA(0, FALSE, FALSE, 0)));
if (!wakeUpNotifier.handle())
qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed");
}
示例5: msg
QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine()
: msg(0)
{
HANDLE h = QT_WA_INLINE(CreateEventW(0, false, false, 0),
CreateEventA(0, false, false, 0));
if (h != INVALID_HANDLE_VALUE) {
handles.reserve(MAXIMUM_WAIT_OBJECTS);
handles.append(h);
}
}
示例6: NuiGetSensorCount
/// <summary>
/// Create the first connected Kinect found
/// </summary>
/// <returns>indicates success or failure</returns>
HRESULT CSkeletonBasics::CreateFirstConnected()
{
INuiSensor * pNuiSensor;
int iSensorCount = 0;
HRESULT hr = NuiGetSensorCount(&iSensorCount);
if (FAILED(hr))
{
return hr;
}
// Look at each Kinect sensor
for (int i = 0; i < iSensorCount; ++i)
{
// Create the sensor so we can check status, if we can't create it, move on to the next
hr = NuiCreateSensorByIndex(i, &pNuiSensor);
if (FAILED(hr))
{
continue;
}
// Get the status of the sensor, and if connected, then we can initialize it
hr = pNuiSensor->NuiStatus();
if (S_OK == hr)
{
m_pNuiSensor = pNuiSensor;
break;
}
// This sensor wasn't OK, so release it since we're not using it
pNuiSensor->Release();
}
if (NULL != m_pNuiSensor)
{
// Initialize the Kinect and specify that we'll be using skeleton
hr = m_pNuiSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON);
if (SUCCEEDED(hr))
{
// Create an event that will be signaled when skeleton data is available
m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
// Open a skeleton stream to receive skeleton data
hr = m_pNuiSensor->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, 0);
}
}
if (NULL == m_pNuiSensor || FAILED(hr))
{
SetStatusMessage(L"No ready Kinect found!");
return E_FAIL;
}
return hr;
}
示例7: KsSynchronousDeviceControl
KSDDKAPI
HRESULT
WINAPI
KsSynchronousDeviceControl(
HANDLE Handle,
ULONG IoControl,
PVOID InBuffer,
ULONG InLength,
PVOID OutBuffer,
ULONG OutLength,
PULONG BytesReturned)
{
OVERLAPPED Overlapped;
DWORD Transferred;
/* zero overlapped */
RtlZeroMemory(&Overlapped, sizeof(OVERLAPPED));
/* create notification event */
Overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
if (!Overlapped.hEvent)
{
/* failed */
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
}
if (!DeviceIoControl(Handle, IoControl, InBuffer, InLength, OutBuffer, OutLength, BytesReturned, &Overlapped))
{
/* operation failed */
if (GetLastError() != ERROR_IO_PENDING)
{
/* failed */
CloseHandle(Overlapped.hEvent);
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
}
}
/* get result of pending operation */
if (!GetOverlappedResult(Handle, &Overlapped, &Transferred, TRUE))
{
/* failed */
CloseHandle(Overlapped.hEvent);
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
}
/* store number of bytes transferred */
*BytesReturned = Transferred;
/* close event object */
CloseHandle(Overlapped.hEvent);
/* done */
return NOERROR;
}
示例8: ProcessPageRefreshThread
static DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
{
ULONG OldProcessorUsage = 0;
ULONG OldProcessCount = 0;
WCHAR wszCPU_Usage[255];
WCHAR wszProcesses[255];
LoadStringW(hInst, IDS_STATUS_BAR_CPU_USAGE, wszCPU_Usage, sizeof(wszCPU_Usage)/sizeof(WCHAR));
LoadStringW(hInst, IDS_STATUS_BAR_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR));
/* Create the event */
hProcessPageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
/* If we couldn't create the event then exit the thread */
if (!hProcessPageEvent)
return 0;
while (1) {
DWORD dwWaitVal;
/* Wait on the event */
dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);
/* If the wait failed then the event object must have been */
/* closed and the task manager is exiting so exit this thread */
if (dwWaitVal == WAIT_FAILED)
return 0;
if (dwWaitVal == WAIT_OBJECT_0) {
WCHAR text[256];
/* Reset our event */
ResetEvent(hProcessPageEvent);
if (SendMessageW(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
SendMessageW(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);
if (IsWindowVisible(hProcessPage))
InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
OldProcessorUsage = PerfDataGetProcessorUsage();
wsprintfW(text, wszCPU_Usage, OldProcessorUsage);
SendMessageW(hStatusWnd, SB_SETTEXTW, 1, (LPARAM)text);
}
if (OldProcessCount != PerfDataGetProcessCount()) {
OldProcessCount = PerfDataGetProcessCount();
wsprintfW(text, wszProcesses, OldProcessCount);
SendMessageW(hStatusWnd, SB_SETTEXTW, 0, (LPARAM)text);
}
}
}
return 0;
}
示例9: NazaraError
bool TaskSchedulerImpl::Initialize(std::size_t workerCount)
{
if (IsInitialized())
return true; // Déjà initialisé
#if NAZARA_CORE_SAFE
if (workerCount == 0)
{
NazaraError("Invalid worker count ! (0)");
return false;
}
#endif
s_workerCount = workerCount;
s_doneEvents.reset(new HANDLE[workerCount]);
s_workers.reset(new Worker[workerCount]);
s_workerThreads.reset(new HANDLE[workerCount]);
// L'identifiant de chaque worker doit rester en vie jusqu'à ce que chaque thread soit correctement lancé
std::unique_ptr<std::size_t[]> workerIDs(new std::size_t[workerCount]);
for (std::size_t i = 0; i < workerCount; ++i)
{
// On initialise les évènements, mutex et threads de chaque worker
Worker& worker = s_workers[i];
InitializeCriticalSection(&worker.queueMutex);
worker.wakeEvent = CreateEventW(nullptr, false, false, nullptr);
worker.running = true;
worker.workCount = 0;
s_doneEvents[i] = CreateEventW(nullptr, true, false, nullptr);
// Le thread va se lancer, signaler qu'il est prêt à travailler (s_doneEvents) et attendre d'être réveillé
workerIDs[i] = i;
s_workerThreads[i] = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, &WorkerProc, &workerIDs[i], 0, nullptr));
}
// On attend que les workers se mettent en attente
WaitForMultipleObjects(s_workerCount, &s_doneEvents[0], true, INFINITE);
return true;
}
示例10: NuiCreateSensorByIndex
Kinect::Kinect(void)
{
HRESULT hr = NuiCreateSensorByIndex(0, &m_kinect_handle);
if (SUCCEEDED(hr))
{
m_kinect_handle->NuiInitialize( NUI_INITIALIZE_FLAG_USES_SKELETON);
m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
hr = m_kinect_handle->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, NUI_SKELETON_TRACKING_FLAG_ENABLE_IN_NEAR_RANGE | NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT);
}
}
示例11: service_start
DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *service_argv)
{
DWORD err;
LPWSTR name;
HANDLE process_handle = NULL;
err = scmdatabase_lock_startup(service->db);
if (err != ERROR_SUCCESS)
return err;
if (service->control_pipe != INVALID_HANDLE_VALUE)
{
scmdatabase_unlock_startup(service->db);
return ERROR_SERVICE_ALREADY_RUNNING;
}
service->control_mutex = CreateMutexW(NULL, TRUE, NULL);
if (!service->status_changed_event)
service->status_changed_event = CreateEventW(NULL, FALSE, FALSE, NULL);
name = service_get_pipe_name();
service->control_pipe = CreateNamedPipeW(name, PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE|PIPE_WAIT, 1, 256, 256, 10000, NULL );
HeapFree(GetProcessHeap(), 0, name);
if (service->control_pipe==INVALID_HANDLE_VALUE)
{
WINE_ERR("failed to create pipe for %s, error = %d\n",
wine_dbgstr_w(service->name), GetLastError());
scmdatabase_unlock_startup(service->db);
return GetLastError();
}
err = service_start_process(service, &process_handle);
if (err == ERROR_SUCCESS)
{
if (!service_send_start_message(service, service_argv, service_argc))
err = ERROR_SERVICE_REQUEST_TIMEOUT;
}
if (err == ERROR_SUCCESS)
err = service_wait_for_startup(service, process_handle);
if (process_handle)
CloseHandle(process_handle);
ReleaseMutex(service->control_mutex);
scmdatabase_unlock_startup(service->db);
WINE_TRACE("returning %d\n", err);
return err;
}
示例12: RPCSS_Initialize
BOOL RPCSS_Initialize(void)
{
static unsigned short irot_protseq[] = IROT_PROTSEQ;
static unsigned short irot_endpoint[] = IROT_ENDPOINT;
static unsigned short epm_protseq[] = {'n','c','a','c','n','_','n','p',0};
static unsigned short epm_endpoint[] = {'\\','p','i','p','e','\\','e','p','m','a','p','p','e','r',0};
static unsigned short epm_protseq_lrpc[] = {'n','c','a','l','r','p','c',0};
static unsigned short epm_endpoint_lrpc[] = {'e','p','m','a','p','p','e','r',0};
RPC_STATUS status;
WINE_TRACE("\n");
status = RpcServerRegisterIf(epm_v3_0_s_ifspec, NULL, NULL);
if (status != RPC_S_OK)
return status;
status = RpcServerRegisterIf(Irot_v0_2_s_ifspec, NULL, NULL);
if (status != RPC_S_OK)
{
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
return FALSE;
}
status = RpcServerUseProtseqEpW(epm_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
epm_endpoint, NULL);
if (status != RPC_S_OK)
goto fail;
status = RpcServerUseProtseqEpW(epm_protseq_lrpc, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
epm_endpoint_lrpc, NULL);
if (status != RPC_S_OK)
goto fail;
status = RpcServerUseProtseqEpW(irot_protseq, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
irot_endpoint, NULL);
if (status != RPC_S_OK)
goto fail;
status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE);
if (status != RPC_S_OK)
goto fail;
#ifndef __REACTOS__
exit_event = __wine_make_process_system();
#else
exit_event = CreateEventW(NULL, FALSE, FALSE, NULL); // never fires
#endif
return TRUE;
fail:
RpcServerUnregisterIf(epm_v3_0_s_ifspec, NULL, FALSE);
RpcServerUnregisterIf(Irot_v0_2_s_ifspec, NULL, FALSE);
return FALSE;
}
示例13: MyCreateEventW
HOOKFUNC HANDLE WINAPI MyCreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCWSTR lpName)
{
HANDLE rv = CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName);
debuglog(LCF_SYNCOBJ | LCF_TODO, __FUNCTION__ " returned 0x%X.\n", rv);
EnterCriticalSection(&s_handleCS);
std::set<HANDLE>& handles = s_threadIdHandles[GetCurrentThreadId()];
handles.insert(rv);
//for(unsigned int i = 0; i < handles.size(); i++)
// debugprintf(" . 0x%X . ", handles[i]);
LeaveCriticalSection(&s_handleCS);
return rv;
}
示例14: ReadDirectoryChangesW
/****************************************************************************
* ReadDirectoryChangesW ([email protected])
*
* NOTES
*
* The filter is remember from the first run and ignored on successive runs.
*
* If there's no output buffer on the first run, it's ignored successive runs
* and STATUS_NOTIFY_ENUM_DIRECTORY is returned with an empty buffer.
*
* If a NULL overlapped->hEvent is passed, the directory handle is used
* for signalling.
*/
BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL subtree,
DWORD filter, LPDWORD returned, LPOVERLAPPED overlapped,
LPOVERLAPPED_COMPLETION_ROUTINE completion )
{
OVERLAPPED ov, *pov;
IO_STATUS_BLOCK *ios;
NTSTATUS status;
BOOL ret = TRUE;
LPVOID cvalue = NULL;
TRACE("%p %p %08x %d %08x %p %p %p\n", handle, buffer, len, subtree, filter,
returned, overlapped, completion );
if (!overlapped)
{
memset( &ov, 0, sizeof ov );
ov.hEvent = CreateEventW( NULL, 0, 0, NULL );
pov = &ov;
}
else
{
pov = overlapped;
if(completion) cvalue = completion;
else if (((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
}
ios = (PIO_STATUS_BLOCK) pov;
ios->u.Status = STATUS_PENDING;
status = NtNotifyChangeDirectoryFile( handle, completion && overlapped ? NULL : pov->hEvent,
completion && overlapped ? invoke_completion : NULL,
cvalue, ios, buffer, len, filter, subtree );
if (status == STATUS_PENDING)
{
if (overlapped)
return TRUE;
WaitForSingleObjectEx( ov.hEvent, INFINITE, TRUE );
CloseHandle( ov.hEvent );
if (returned)
*returned = ios->Information;
status = ios->u.Status;
}
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
ret = FALSE;
}
return ret;
}
示例15: init
static int init(struct ao *ao)
{
MP_DBG(ao, "Init wasapi\n");
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
struct wasapi_state *state = ao->priv;
state->log = ao->log;
if(!wasapi_fill_VistaBlob(state))
MP_WARN(ao, "Error loading thread priority functions\n");
state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL);
state->hWake = CreateEventW(NULL, FALSE, FALSE, NULL);
if (!state->hInitDone || !state->hWake) {
MP_ERR(ao, "Error creating events\n");
uninit(ao);
return -1;
}
state->init_ret = E_FAIL;
state->hAudioThread = CreateThread(NULL, 0, &AudioThread, ao, 0, NULL);
if (!state->hAudioThread) {
MP_ERR(ao, "Failed to create audio thread\n");
uninit(ao);
return -1;
}
WaitForSingleObject(state->hInitDone, INFINITE); /* wait on init complete */
SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone));
if (state->init_ret != S_OK) {
if (!ao->probing)
MP_ERR(ao, "Received failure from audio thread\n");
uninit(ao);
return -1;
}
wasapi_setup_proxies(state);
MP_DBG(ao, "Init wasapi done\n");
return 0;
}