• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HANDLE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中HANDLE函数的典型用法代码示例。如果您正苦于以下问题:C++ HANDLE函数的具体用法?C++ HANDLE怎么用?C++ HANDLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了HANDLE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: WriteThreadProc

DWORD WINAPI WriteThreadProc(LPVOID lpParameter) 
{
	HANDLE hFile = HANDLE(lpParameter);
	do 
	{
		WriteBuffer* write_buffer = NULL;
		bool exit = false;
		EnterCriticalSection(&g_write_queue_cs);
		if (g_write_queue.size() > 0) 
		{
			write_buffer = g_write_queue.front();
			g_write_queue.pop();
			g_total_bytes_written += write_buffer->useful_data_size_;
		}
		else if (g_done)
		{
			exit = true;
		} 
		SetEvent(g_write_queue_accepts_more_data_event);
		LeaveCriticalSection(&g_write_queue_cs);

		if (write_buffer) 
		{
			/* DWORD bytes_written = 0;
			::WriteFile(hFile, write_buffer->ptr_, write_buffer->useful_data_size_, 
				&bytes_written, NULL); */
			delete write_buffer;
		} 
		else if (exit) {
			break;
		} else {
			// Wait for new(s).
			WaitForSingleObject(g_write_queue_has_more_data_event, INFINITE);
		}

	} while (true);

	return 1;
}
开发者ID:nikolain,项目名称:high-performance-string-float-random,代码行数:39,代码来源:cout_test_5.cpp


示例2: pnm_load

pnm
pnm_load(char *path)
{
    FILE *input = L_r_open(path);
    pnm self = NULL;

    HANDLE(any, self = L_load(input));
    fclose(input);

    if (EXCEPTION_RAISED(any))
    {
	if (self != NULL)
	    memory_free(self);

	if (EXCEPTION_RAISED(get_int))
	    RAISE(error, "Truncated pnm file");

	if (EXCEPTION_RAISED(any))
	    RAISE_AGAIN();
    }
    return self;
}
开发者ID:Alkinn,项目名称:traitement-images,代码行数:22,代码来源:pnm.c


示例3: on_timer_callback

static void
on_timer_callback(uv_timer_t *handle)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    Timer *self;
    PyObject *result;

    ASSERT(handle);
    self = PYUV_CONTAINER_OF(handle, Timer, timer_h);

    /* Object could go out of scope in the callback, increase refcount to avoid it */
    Py_INCREF(self);

    result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
    if (result == NULL) {
        handle_uncaught_exception(HANDLE(self)->loop);
    }
    Py_XDECREF(result);

    Py_DECREF(self);
    PyGILState_Release(gstate);
}
开发者ID:iyedb,项目名称:pyuv,代码行数:22,代码来源:timer.c


示例4: on_pipe_read2

static void
on_pipe_read2(uv_pipe_t* handle, int nread, uv_buf_t buf, uv_handle_type pending)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    uv_err_t err;
    Stream *self;
    PyObject *result, *data, *py_errorno, *py_pending;
    ASSERT(handle);

    self = (Stream *)handle->data;
    ASSERT(self);
    /* Object could go out of scope in the callback, increase refcount to avoid it */
    Py_INCREF(self);

    py_pending = PyInt_FromLong((long)pending);

    if (nread >= 0) {
        data = PyBytes_FromStringAndSize(buf.base, nread);
        py_errorno = Py_None;
        Py_INCREF(Py_None);
    } else {
        data = Py_None;
        Py_INCREF(Py_None);
        err = uv_last_error(UV_HANDLE_LOOP(self));
        py_errorno = PyInt_FromLong((long)err.code);
    }

    result = PyObject_CallFunctionObjArgs(self->on_read_cb, self, data, py_pending, py_errorno, NULL);
    if (result == NULL) {
        handle_uncaught_exception(HANDLE(self)->loop);
    }
    Py_XDECREF(result);
    Py_DECREF(data);
    Py_DECREF(py_pending);
    Py_DECREF(py_errorno);

    Py_DECREF(self);
    PyGILState_Release(gstate);
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:39,代码来源:pipe.c


示例5: sizeof

bool   SockPool::InitalWriteQueue(HANDLE WriteQueue, PM &pWriteQueue)
{
	pWriteQueue = (PM)MapViewOfFile(WriteQueue, FILE_MAP_WRITE, 0, 0, sizeof(Manager));///<映射写队列控制块到本地
	if (pWriteQueue == NULL)
		return PrintLog(_T("写控制块映射失败"), false);
	pWriteQueue->hid = 0;   ///<初始化写控制块参数
	pWriteQueue->cid = 0;
	pWriteQueue->writer = _getpid();
	pWriteQueue->Cur = NULL;

	HANDLE EmptyNode = CreateFileMapping(HANDLE(0xFFFFFFFF), NULL, PAGE_READWRITE, 0, sizeof(Node), NULL);///<创建一个空节点
	PN pNode = (PN)MapViewOfFile(EmptyNode, FILE_MAP_WRITE, 0, 0, sizeof(Node));///<映射节点到本地
	memset(pNode, 0, sizeof(Node));
	UnmapViewOfFile(pNode);

	DuplicateHandle(SH, EmptyNode, SH, &pWriteQueue->Tail, NULL, true, DUPLICATE_SAME_ACCESS); ///<空节点加入链表
	DuplicateHandle(SH, EmptyNode, SH, &pWriteQueue->Head, NULL, true, DUPLICATE_SAME_ACCESS);
	CloseHandle(EmptyNode);
	if (!(pWriteQueue->Tail || pWriteQueue->Head))
		return PrintLog(_T("控制管理块初始化失败"), false);
	return true;
}
开发者ID:foxspy,项目名称:network_project,代码行数:22,代码来源:SockPool.cpp


示例6: x4_ike_select_prime

x4s_buf x4_ike_select_prime(uint16 v)
{
  x4s_buf r = { 0 };

  #define HANDLE(bits) \
    case x4c_ike_a1g_modp_##bits : \
      x4_buf_attach(&r,x4v_ike_modp##bits,sizeof(x4v_ike_modp##bits)); \
      break;

  switch (v)
  {
  HANDLE(768);
  HANDLE(1024);
  HANDLE(1536);
  HANDLE(2048);
  HANDLE(3072);
  HANDLE(4096);
  HANDLE(6144);
  HANDLE(8192);
  }
  return r;

  #undef HANDLE
}
开发者ID:apankrat,项目名称:libike,代码行数:24,代码来源:utils.c


示例7: iq_add_handlers

void
iq_add_handlers(void)
{
    xmpp_conn_t * const conn = connection_get_conn();
    xmpp_ctx_t * const ctx = connection_get_ctx();

    HANDLE(NULL,                STANZA_TYPE_ERROR,  _error_handler);

    HANDLE(XMPP_NS_DISCO_INFO,  STANZA_TYPE_GET,    _disco_info_get_handler);
    HANDLE(XMPP_NS_DISCO_INFO,  STANZA_TYPE_RESULT, _disco_info_result_handler);

    HANDLE(XMPP_NS_DISCO_ITEMS, STANZA_TYPE_GET,    _disco_items_get_handler);
    HANDLE(XMPP_NS_DISCO_ITEMS, STANZA_TYPE_RESULT, _disco_items_result_handler);

    HANDLE(STANZA_NS_VERSION,   STANZA_TYPE_GET,    _version_get_handler);
    HANDLE(STANZA_NS_VERSION,   STANZA_TYPE_RESULT, _version_result_handler);

    HANDLE(STANZA_NS_PING,      STANZA_TYPE_GET,    _ping_get_handler);

    if (prefs_get_autoping() != 0) {
        int millis = prefs_get_autoping() * 1000;
        xmpp_timed_handler_add(conn, _ping_timed_handler, millis, ctx);
    }
}
开发者ID:NYAMNYAM3,项目名称:profanity,代码行数:24,代码来源:iq.c


示例8: CloseHandle

void CFile::open(const STRING &fileName, CONST UINT mode)
{
	if (m_hFile != HFILE_ERROR)
	{
		CloseHandle(HANDLE(m_hFile));
	}
	m_filename = fileName;

	DWORD access = GENERIC_READ;
	if (mode & OF_WRITE) access |= GENERIC_WRITE;

	DWORD creation = (mode & OF_CREATE) ? CREATE_ALWAYS : OPEN_EXISTING;

	m_hFile = (HFILE)CreateFile(resolve(fileName).c_str(),
		access,
		FILE_SHARE_READ,
		NULL,
		creation,
		FILE_ATTRIBUTE_NORMAL,
		NULL);        

	memset(&m_ptr, 0, sizeof(m_ptr));
}
开发者ID:shao113,项目名称:trans3,代码行数:23,代码来源:CFile.cpp


示例9: memcpy

/**
* @author ACM2012
* @param [in] pNode新创建的节点句柄,SockMark套接字唯一标示符
* @note    函数的主要功能是将类中缓存的接收到的数据打包到新创建的节点
*/
bool   SockPool::SockDataToNode(PN pNode, unsigned int SockMark)///<将数据打包成节点形式
{
	bool tmpflag = true;
	transstruct *psockstruct = SockMark2SockStruct[SockMark];
	memcpy(pNode->dstip, psockstruct->dstip, 20);///<填充字段
	memcpy(pNode->srcip, psockstruct->srcip, 20);
	pNode->dstport = psockstruct->dstport;
	pNode->srcport = psockstruct->srcport;
	pNode->DataLen = psockstruct->datalength;
	pNode->FuncID = psockstruct->function;
	CString myid;
	myid.Format(_T("%d"), pNode->FuncID);
	//AfxMessageBox(myid);
	if (pNode->FuncID == SOCKSEND || pNode->FuncID == SOCKSENDTO)
		pNode->Data = CreateFileMapping(HANDLE(0xFFFFFFFF), NULL, PAGE_READWRITE, 0, pNode->DataLen, NULL);
	if (pNode->FuncID == SOCKCLOSE)
		tmpflag = false;
	void  *pData = (void *)MapViewOfFile(pNode->Data, FILE_MAP_WRITE, 0, 0, pNode->DataLen);
	if (psockstruct->data!=NULL)
	    memcpy(pData, psockstruct->data, pNode->DataLen);///<拷贝数据
	UnmapViewOfFile(pData);
	return tmpflag;
}
开发者ID:foxspy,项目名称:network_project,代码行数:28,代码来源:SockPool.cpp


示例10: csort

void csort(int *array, int size)
{
	/* int tmp[RANGE + 1] = {0}; */
	pthread_t *workers[WORKER_THREADS];
	args_t *args[WORKER_THREADS];
	int chunk_size = size / WORKER_THREADS;
	int end = 0;
	int i;
	
	/* initialize the tmp array */
	for(i = 0; i < RANGE + 1; i++){
		sem_init(&tmp[i], 0, 0);
	}

	/* partition the work */
	for(i = 0; i < WORKER_THREADS; i ++){
		end = i == WORKER_THREADS - 1 ? size : (i + 1) * chunk_size;
		args[i] = make_args(&array, i * chunk_size, end);
		workers[i] = malloc(sizeof(pthread_t));
		HANDLE(pthread_create(workers[i], NULL, populate_tmp_p, args[i]));
	}

	/* wait for everything to finish */
	for(i = 0; i < WORKER_THREADS; i++){
		pthread_join(*workers[i], NULL);
	}

	/* writeback, sequentially */
	unroll_tmp(&array, RANGE);

	/* free everything */
//	for(i = 0; i < WORKER_THREADS; i++){
//		free_args(args[i]);
		/* pthread_destroy(workers[i]); */
//	}

}
开发者ID:pscollins,项目名称:cmsc222-optimization,代码行数:37,代码来源:csort-new-par.c


示例11: WriteThreadProc

DWORD WINAPI WriteThreadProc(LPVOID lpParameter) 
{
	HANDLE hFile = HANDLE(lpParameter);
	do 
	{
		WriteBuffer* write_buffer = NULL;
		bool exit = false;
		EnterCriticalSection(&g_write_queue_cs);
		if (g_write_queue.size() > 0) 
		{
			write_buffer = g_write_queue.front();
			g_write_queue.pop();
		}
		else if (g_done)
		{
			exit = true;
		} 
		LeaveCriticalSection(&g_write_queue_cs);

		if (write_buffer) 
		{
			DWORD bytes_written = 0;
			::WriteFile(hFile, write_buffer->ptr_, write_buffer->useful_data_size_, 
				&bytes_written, NULL);
			delete write_buffer;
		} 
		else if (exit) {
			break;
		} else {
			::Sleep(0);
		}

	} while (true);

	return 1;
}
开发者ID:nikolain,项目名称:high-performance-string-float-random,代码行数:36,代码来源:cout_test_2.cpp


示例12: on_pipe_client_connection

static void
on_pipe_client_connection(uv_connect_t *req, int status)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    Pipe *self;
    PyObject *callback, *result, *py_errorno;
    ASSERT(req);

    self = (Pipe *)req->handle->data;
    callback = (PyObject *)req->data;

    ASSERT(self);

    if (status != 0) {
        uv_err_t err = uv_last_error(UV_HANDLE_LOOP(self));
        py_errorno = PyInt_FromLong(err.code);
    } else {
        py_errorno = Py_None;
        Py_INCREF(Py_None);
    }

    result = PyObject_CallFunctionObjArgs(callback, self, py_errorno, NULL);
    if (result == NULL) {
        handle_uncaught_exception(HANDLE(self)->loop);
    }
    Py_XDECREF(result);
    Py_DECREF(py_errorno);

    Py_DECREF(callback);
    PyMem_Free(req);

    /* Refcount was increased in the caller function */
    Py_DECREF(self);

    PyGILState_Release(gstate);
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:36,代码来源:pipe.c


示例13: on_check_callback

static void
on_check_callback(uv_check_t *handle, int status)
{
    PyGILState_STATE gstate = PyGILState_Ensure();
    Check *self;
    PyObject *result;

    ASSERT(handle);
    ASSERT(status == 0);

    self = (Check *)handle->data;
    ASSERT(self);
    /* Object could go out of scope in the callback, increase refcount to avoid it */
    Py_INCREF(self);

    result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
    if (result == NULL) {
        handle_uncaught_exception(HANDLE(self)->loop);
    }
    Py_XDECREF(result);

    Py_DECREF(self);
    PyGILState_Release(gstate);
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:24,代码来源:check.c


示例14: UDP_tp_init

static int
UDP_tp_init(UDP *self, PyObject *args, PyObject *kwargs)
{
    int r;
    Loop *loop;

    UNUSED_ARG(kwargs);

    RAISE_IF_HANDLE_INITIALIZED(self, -1);

    if (!PyArg_ParseTuple(args, "O!:__init__", &LoopType, &loop)) {
        return -1;
    }

    r = uv_udp_init(loop->uv_loop, (uv_udp_t *)UV_HANDLE(self));
    if (r != 0) {
        RAISE_UV_EXCEPTION(loop->uv_loop, PyExc_UDPError);
        return -1;
    }

    initialize_handle(HANDLE(self), loop);

    return 0;
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:24,代码来源:udp.c


示例15: Timer_tp_init

static int
Timer_tp_init(Timer *self, PyObject *args, PyObject *kwargs)
{
    int err;
    Loop *loop;

    UNUSED_ARG(kwargs);

    RAISE_IF_HANDLE_INITIALIZED(self, -1);

    if (!PyArg_ParseTuple(args, "O!:__init__", &LoopType, &loop)) {
        return -1;
    }

    err = uv_timer_init(loop->uv_loop, &self->timer_h);
    if (err < 0) {
        RAISE_UV_EXCEPTION(err, PyExc_TimerError);
        return -1;
    }

    initialize_handle(HANDLE(self), loop);

    return 0;
}
开发者ID:iyedb,项目名称:pyuv,代码行数:24,代码来源:timer.c


示例16: tiff_seek

static toff_t
tiff_seek (thandle_t handle, toff_t offset, int whence)
{
	Handle    *h = HANDLE (handle);
	GSeekType  seek_type;

	seek_type = G_SEEK_SET;
        switch (whence) {
        case SEEK_SET:
        	seek_type = G_SEEK_SET;
                break;
        case SEEK_CUR:
        	seek_type = G_SEEK_CUR;
                break;
        case SEEK_END:
        	seek_type = G_SEEK_END;
                break;
        }

	if (! g_seekable_seek (G_SEEKABLE (h->istream), offset, seek_type, h->cancellable, NULL))
		return -1;

	return g_seekable_tell (G_SEEKABLE (h->istream));
}
开发者ID:GNOME,项目名称:gthumb,代码行数:24,代码来源:cairo-image-surface-tiff.c


示例17: dump_thread

static void
dump_thread(void *arg)
{
    HANDLE dbghelp;
    BOOL (WINAPI *pSymInitialize)(HANDLE, const char *, BOOL);
    BOOL (WINAPI *pSymCleanup)(HANDLE);
    BOOL (WINAPI *pStackWalk64)(DWORD, HANDLE, HANDLE, STACKFRAME64 *, void *, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64);
    DWORD64 (WINAPI *pSymGetModuleBase64)(HANDLE, DWORD64);
    BOOL (WINAPI *pSymFromAddr)(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFO *);
    BOOL (WINAPI *pSymGetLineFromAddr64)(HANDLE, DWORD64, DWORD *, IMAGEHLP_LINE64 *);
    HANDLE (WINAPI *pOpenThread)(DWORD, BOOL, DWORD);
    DWORD tid = *(DWORD *)arg;
    HANDLE ph;
    HANDLE th;

    dbghelp = LoadLibrary("dbghelp.dll");
    if (!dbghelp) return;
    pSymInitialize = (BOOL (WINAPI *)(HANDLE, const char *, BOOL))GetProcAddress(dbghelp, "SymInitialize");
    pSymCleanup = (BOOL (WINAPI *)(HANDLE))GetProcAddress(dbghelp, "SymCleanup");
    pStackWalk64 = (BOOL (WINAPI *)(DWORD, HANDLE, HANDLE, STACKFRAME64 *, void *, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64))GetProcAddress(dbghelp, "StackWalk64");
    pSymGetModuleBase64 = (DWORD64 (WINAPI *)(HANDLE, DWORD64))GetProcAddress(dbghelp, "SymGetModuleBase64");
    pSymFromAddr = (BOOL (WINAPI *)(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFO *))GetProcAddress(dbghelp, "SymFromAddr");
    pSymGetLineFromAddr64 = (BOOL (WINAPI *)(HANDLE, DWORD64, DWORD *, IMAGEHLP_LINE64 *))GetProcAddress(dbghelp, "SymGetLineFromAddr64");
    pOpenThread = (HANDLE (WINAPI *)(DWORD, BOOL, DWORD))GetProcAddress(GetModuleHandle("kernel32.dll"), "OpenThread");
    if (pSymInitialize && pSymCleanup && pStackWalk64 && pSymGetModuleBase64 &&
	pSymFromAddr && pSymGetLineFromAddr64 && pOpenThread) {
	SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG | SYMOPT_LOAD_LINES);
	ph = GetCurrentProcess();
	pSymInitialize(ph, NULL, TRUE);
	th = pOpenThread(THREAD_SUSPEND_RESUME|THREAD_GET_CONTEXT, FALSE, tid);
	if (th) {
	    if (SuspendThread(th) != (DWORD)-1) {
		CONTEXT context;
		memset(&context, 0, sizeof(context));
		context.ContextFlags = CONTEXT_FULL;
		if (GetThreadContext(th, &context)) {
		    char libpath[MAX_PATH];
		    char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
		    SYMBOL_INFO *info = (SYMBOL_INFO *)buf;
		    DWORD mac;
		    STACKFRAME64 frame;
		    memset(&frame, 0, sizeof(frame));
#if defined(_M_AMD64) || defined(__x86_64__)
		    mac = IMAGE_FILE_MACHINE_AMD64;
		    frame.AddrPC.Mode = AddrModeFlat;
		    frame.AddrPC.Offset = context.Rip;
		    frame.AddrFrame.Mode = AddrModeFlat;
		    frame.AddrFrame.Offset = context.Rbp;
		    frame.AddrStack.Mode = AddrModeFlat;
		    frame.AddrStack.Offset = context.Rsp;
#elif defined(_M_IA64) || defined(__ia64__)
		    mac = IMAGE_FILE_MACHINE_IA64;
		    frame.AddrPC.Mode = AddrModeFlat;
		    frame.AddrPC.Offset = context.StIIP;
		    frame.AddrBStore.Mode = AddrModeFlat;
		    frame.AddrBStore.Offset = context.RsBSP;
		    frame.AddrStack.Mode = AddrModeFlat;
		    frame.AddrStack.Offset = context.IntSp;
#else	/* i386 */
		    mac = IMAGE_FILE_MACHINE_I386;
		    frame.AddrPC.Mode = AddrModeFlat;
		    frame.AddrPC.Offset = context.Eip;
		    frame.AddrFrame.Mode = AddrModeFlat;
		    frame.AddrFrame.Offset = context.Ebp;
		    frame.AddrStack.Mode = AddrModeFlat;
		    frame.AddrStack.Offset = context.Esp;
#endif

		    while (pStackWalk64(mac, ph, th, &frame, &context, NULL,
					NULL, NULL, NULL)) {
			DWORD64 addr = frame.AddrPC.Offset;
			IMAGEHLP_LINE64 line;
			DWORD64 displacement;
			DWORD tmp;

			if (addr == frame.AddrReturn.Offset || addr == 0 ||
			    frame.AddrReturn.Offset == 0)
			    break;

			memset(buf, 0, sizeof(buf));
			info->SizeOfStruct = sizeof(SYMBOL_INFO);
			info->MaxNameLen = MAX_SYM_NAME;
			if (pSymFromAddr(ph, addr, &displacement, info)) {
			    if (GetModuleFileName((HANDLE)(uintptr_t)pSymGetModuleBase64(ph, addr), libpath, sizeof(libpath)))
				fprintf(stderr, "%s", libpath);
			    fprintf(stderr, "(%s+0x%I64x)",
				    info->Name, displacement);
			}
			fprintf(stderr, " [0x%p]", (void *)(VALUE)addr);
			memset(&line, 0, sizeof(line));
			line.SizeOfStruct = sizeof(line);
			if (pSymGetLineFromAddr64(ph, addr, &tmp, &line))
			    fprintf(stderr, " %s:%lu", line.FileName, line.LineNumber);
			fprintf(stderr, "\n");
		    }
		}

		ResumeThread(th);
	    }
	    CloseHandle(th);
//.........这里部分代码省略.........
开发者ID:alansparrow,项目名称:learningruby,代码行数:101,代码来源:vm_dump.c


示例18: defined

BOOL COXFileWatcher::AddWatch(LPCTSTR pszPath, BOOL bWatchSubtree, DWORD dwWatchFilter)
{
#if defined (_WINDLL)
#if defined (_AFXDLL)
	AFX_MANAGE_STATE(AfxGetAppModuleState());
#else
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
#endif

	ASSERT(pszPath != NULL);

	// Clear error flag
	m_hrError = ERROR_SUCCESS;

	COXWatchedDir* pwdNewEntry;

	// Make the class a Thread-Safe Class
	CSingleLock lockObj(&m_crArrayWatchedDirGuard);
	VERIFY(lockObj.Lock());

	// Fisrt check if we are not watching for the same path
	for(int i=0; i<m_arWatchedDirs.GetSize(); i++)
	{
		if((m_arWatchedDirs[i])->m_sPath == pszPath)
		{
			// ... OK. The path is already here
			COXWatchedDir* pwdPresentEntry = m_arWatchedDirs[i];

			if(bWatchSubtree == pwdPresentEntry->m_bWatchSubTree &&
			   dwWatchFilter == pwdPresentEntry->m_dwWatchFilter)
			{
				// No modifications
				return TRUE;
			}

			pwdNewEntry = new COXWatchedDir(
				pszPath,										// directory to be watched
				bWatchSubtree|pwdPresentEntry->m_bWatchSubTree,	// flag for monitoring directory or directory tree 
				dwWatchFilter|pwdPresentEntry->m_dwWatchFilter,	// filter conditions to watch for
				IsExtendedInfoSupported());						// flag for extended info

			// Create new handle
			if(!pwdNewEntry->FindFirstHandle(m_hrError))
			{
				goto error;
			}

			// Prepares the handles for the watcher thread
			m_pNewHandles = m_pHandles;

			VERIFY(m_mxThreadCanContinue.Lock());
			// Informs the watcher thread that it can change the handles
			// and waits for the watcher thread to stop
			VERIFY(m_mxThreadShouldStop.Unlock());
			// wait until the watcher thread stops
			VERIFY(m_mxThreadStopped.Lock());

			// Update the entry for the given path
			m_arWatchedDirs.SetAt(i, pwdNewEntry);

			// Close old entry. This will close the old handle
			delete pwdPresentEntry;

			// Replace the old handle with the new one and start the 
			// thread again
			m_pHandles[i+1]=pwdNewEntry->m_hEvent;

			VERIFY(m_mxThreadStopped.Unlock());
			VERIFY(m_mxThreadShouldStop.Lock());
			// notify watcher thread that it can go on executing
			VERIFY(m_mxThreadCanContinue.Unlock());

			return TRUE;
		}
	}

	pwdNewEntry = new COXWatchedDir(pszPath,		// directory to be watched
									bWatchSubtree,	// flag for monitoring directory or directory tree 
									dwWatchFilter,	// filter conditions to watch for
									IsExtendedInfoSupported());// flag for extended info

	if(pwdNewEntry->FindFirstHandle(m_hrError))
	{
		// Handles are m_nNumHandles, so we must allocate (m_nNumHandles+2) : one for the StartStopEvent
		// and one for the new entry
		m_pNewHandles= new HANDLE[m_nNumHandles + 2];
		// Informs the watcher thread that it can change the handles
		if(m_bThreadIsRunning) 
		{
			VERIFY(m_mxThreadCanContinue.Lock());
			// notify watcher thread that it should stop
			VERIFY(m_mxThreadShouldStop.Unlock());
			// wait until it stops

			DWORD dwResult=::WaitForSingleObject(m_mxThreadStopped.m_hObject, 0xFFFFFFFF);
			ASSERT(dwResult==NULL);
			//VERIFY(m_mxThreadStopped.Lock());
		}

//.........这里部分代码省略.........
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:101,代码来源:OXFileWatcher.cpp


示例19: vlc_mutex_lock

/*****************************************************************************
 * Thread: main loop
 *****************************************************************************/
static void *Thread( void *p_data )
{
    MSG message;

    intf_thread_t *p_intf = p_data;
    intf_sys_t *p_sys = p_intf->p_sys;

    /* Window which receives Hotkeys */
    vlc_mutex_lock( &p_sys->lock );
    p_sys->hotkeyWindow =
        (void*)CreateWindow( _T("STATIC"),           /* name of window class */
                _T("VLC ghk ") _T(VERSION),         /* window title bar text */
                0,                                           /* window style */
                0,                                   /* default X coordinate */
                0,                                   /* default Y coordinate */
                0,                                           /* window width */
                0,                                          /* window height */
                NULL,                                    /* no parent window */
                NULL,                              /* no menu in this window */
                GetModuleHandle(NULL),    /* handle of this program instance */
                NULL );                                 /* sent to WM_CREATE */

    if( p_sys->hotkeyWindow == NULL )
    {
        p_sys->hotkeyWindow = INVALID_HANDLE_VALUE;
        vlc_cond_signal( &p_sys->wait );
        vlc_mutex_unlock( &p_sys->lock );
        return NULL;
    }
    vlc_cond_signal( &p_sys->wait );
    vlc_mutex_unlock( &p_sys->lock );

    SetWindowLongPtr( p_sys->hotkeyWindow, GWLP_WNDPROC,
            (LONG_PTR)WMHOTKEYPROC );
    SetWindowLongPtr( p_sys->hotkeyWindow, GWLP_USERDATA,
            (LONG_PTR)p_intf );

    /* Registering of Hotkeys */
    for( const struct hotkey *p_hotkey = p_intf->obj.libvlc->p_hotkeys;
            p_hotkey->psz_action != NULL;
            p_hotkey++ )
    {
        char varname[12 + strlen( p_hotkey->psz_action )];
        sprintf( varname, "global-key-%s", p_hotkey->psz_action );

        char *key = var_InheritString( p_intf, varname );
        if( key == NULL )
            continue;

        UINT i_key = vlc_str2keycode( key );
        free( key );
        if( i_key == KEY_UNSET )
            continue;

        UINT i_keyMod = 0;
        if( i_key & KEY_MODIFIER_SHIFT ) i_keyMod |= MOD_SHIFT;
        if( i_key & KEY_MODIFIER_ALT ) i_keyMod |= MOD_ALT;
        if( i_key & KEY_MODIFIER_CTRL ) i_keyMod |= MOD_CONTROL;

#define HANDLE( key ) case KEY_##key: i_vk = VK_##key; break
#define HANDLE2( key, key2 ) case KEY_##key: i_vk = VK_##key2; break

#define KEY_SPACE ' '

#ifndef VK_VOLUME_DOWN
#define VK_VOLUME_DOWN          0xAE
#define VK_VOLUME_UP            0xAF
#endif

#ifndef VK_MEDIA_NEXT_TRACK
#define VK_MEDIA_NEXT_TRACK     0xB0
#define VK_MEDIA_PREV_TRACK     0xB1
#define VK_MEDIA_STOP           0xB2
#define VK_MEDIA_PLAY_PAUSE     0xB3
#endif

#ifndef VK_PAGEUP
#define VK_PAGEUP               0x21
#define VK_PAGEDOWN             0x22
#endif

        UINT i_vk = 0;
        switch( i_key & ~KEY_MODIFIER )
        {
            HANDLE( LEFT );
            HANDLE( RIGHT );
            HANDLE( UP );
            HANDLE( DOWN );
            HANDLE( SPACE );
            HANDLE2( ESC, ESCAPE );
            HANDLE2( ENTER, RETURN );
            HANDLE( F1 );
            HANDLE( F2 );
            HANDLE( F3 );
            HANDLE( F4 );
            HANDLE( F5 );
            HANDLE( F6 );
//.........这里部分代码省略.........
开发者ID:BossKing,项目名称:vlc,代码行数:101,代码来源:win32.c


示例20: handle

static LRESULT WINAPI handle(HWND win, UINT msg, WPARAM w, LPARAM l)  {
        LRESULT r;
        switch (msg) {
#define HANDLE(x) case WM_##x: r = HANDLE_WM_##x(win, w, l, on##x); break
                HANDLE(MOUSEMOVE);
                HANDLE(SIZE);
                HANDLE(CLOSE);
                HANDLE(KEYDOWN);
                HANDLE(SYSKEYDOWN);
                HANDLE(SYSKEYUP);
                HANDLE(CHAR);
                HANDLE(KEYUP);
                HANDLE(LBUTTONDOWN);
                HANDLE(RBUTTONDOWN);
                HANDLE(MBUTTONDOWN);
                HANDLE(LBUTTONUP);
                HANDLE(RBUTTONUP);
                HANDLE(MBUTTONUP);
                HANDLE(MOUSEWHEEL);
                HANDLE(SETCURSOR);
                HANDLE(PAINT);
#undef HANDLE
        default: r = 0;
        }
        if (!r)
                r = DefWindowProcW(win, msg, w, l);
        return r;
}
开发者ID:jacereda,项目名称:glcv,代码行数:28,代码来源:win.c



注:本文中的HANDLE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HANDLE_CLERROR函数代码示例发布时间:2022-05-30
下一篇:
C++ HAL_WRITE_UINT8函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap