本文整理汇总了C++中OpenMutex函数的典型用法代码示例。如果您正苦于以下问题:C++ OpenMutex函数的具体用法?C++ OpenMutex怎么用?C++ OpenMutex使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OpenMutex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _T
//初始化接口
bool COcrInput::Init(void)
{
CStdString strMsg = _T("");
CStdString strDir = GetInstallPath();
m_hDLL = LoadLibrary(strDir + _T("\\bin\\InputOCR.dll"));
if(m_hDLL)
{
m_pfuncPushOCRData = (PUSH_OCR_DATA)GetProcAddress(m_hDLL, PUSHCODEDATA);
m_pfuncSetOcrInputFocus = (SET_OCR_INPUTFOCUS)GetProcAddress(m_hDLL, SETOCRINPUTFOCUS);
m_pfunGetCodeDataBack = (GET_CODEDATA_BACK)GetProcAddress(m_hDLL, GETCODEDATABACK) ;
}
if (!m_hDLL || !m_pfuncPushOCRData || !m_pfuncSetOcrInputFocus)
{
strMsg.Format(_T("加载验证码输入模块失败! err:%d"), GetLastError());
MessageBox(NULL, strMsg, _T("程序错误"), MB_OK);
return false;
}
m_hMutexSyncFocus = OpenMutex(MUTEX_ALL_ACCESS, FALSE, _T("InputFocus"));
if (NULL == m_hMutexSyncFocus)
{
strMsg.Format(_T("打开同步焦点对象失败! err:%d"), GetLastError());
MessageBox(NULL, strMsg, _T("程序错误"), MB_OK);
return false;
}
m_hMutexSystemInput = OpenMutex(MUTEX_ALL_ACCESS, FALSE, _T("Engine_SystemInPutMutex"));
return true;
}
示例2: RenderFunc
bool RenderFunc()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
if (menu)
{
HANDLE mutex1 = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX1);
if (mutex1)
WaitForSingleObject(mutex1, INFINITE);
RenderGUI();
ReleaseMutex(mutex1);
if (menu == 4)
{
text->printf(SCREEN_WIDTH/2, 200, HGETEXT_CENTER, "NESTERENKO DIMA");
text->printf(SCREEN_WIDTH/2, 250, HGETEXT_CENTER, "COMPUTER ACADEMY \"STEP\"");
}
}
else
{
world->Render();
mouse_cursor->Render(mouse_pos.x, mouse_pos.y);
if (text)
{
char str[8];
int life;
HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX2);
if (mutex)
WaitForSingleObject(mutex, INFINITE);
life = player->GetLife();
ReleaseMutex(mutex);
hard->Render(32, 32);
text->printf(74, 16, HGETEXT_LEFT, "%d", life);
if (level_end == 1)
{
text->printf(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, HGETEXT_CENTER, "GO TO NEXT LEVEL!!!");
}
else if (level_end == 2)
{
text->printf(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, HGETEXT_CENTER, "YOU WIN!!!");
}
if (ENTITY_DEATH == player->GetState())
{
text->printf(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, HGETEXT_CENTER, "Please press a space.....");
}
}
}
hge->Gfx_EndScene();
return false;
}
示例3: CaptureThread
DWORD WINAPI CaptureThread(HANDLE hDllMainThread)
{
bool bSuccess = false;
//wait for dll initialization to finish before executing any initialization code
if(hDllMainThread)
{
WaitForSingleObject(hDllMainThread, INFINITE);
CloseHandle(hDllMainThread);
}
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.hInstance = hinstMain;
wc.lpszClassName = SENDER_WINDOWCLASS;
wc.lpfnWndProc = (WNDPROC)SenderWindowProc;
if(RegisterClass(&wc))
{
hwndSender = CreateWindow(SENDER_WINDOWCLASS, NULL, 0, 0, 0, 0, 0, NULL, 0, hinstMain, 0);
if(hwndSender)
{
textureMutexes[0] = OpenMutex(MUTEX_ALL_ACCESS, FALSE, TEXTURE_MUTEX1);
if(textureMutexes[0])
{
textureMutexes[1] = OpenMutex(MUTEX_ALL_ACCESS, FALSE, TEXTURE_MUTEX2);
if(textureMutexes[1])
{
while(!AttemptToHookSomething())
Sleep(50);
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
AttemptToHookSomething();
}
CloseHandle(textureMutexes[1]);
textureMutexes[1] = NULL;
}
CloseHandle(textureMutexes[0]);
textureMutexes[0] = NULL;
}
DestroyWindow(hwndSender);
}
}
return 0;
}
示例4: Java_com_tkym_labs_sharedmem_win_BaseNamedObjectsJni_openMutex
JNIEXPORT jint JNICALL Java_com_tkym_labs_sharedmem_win_BaseNamedObjectsJni_openMutex(JNIEnv * env, jobject, jstring name){
LPCTSTR lpName = (LPCTSTR)env->GetStringChars(name, NULL);
HANDLE handle = OpenMutex(MUTEX_ALL_ACCESS, FALSE, lpName);
env->ReleaseStringChars(name, (const jchar *)lpName);
if (handle == NULL) return (jint) (-1*GetLastError());
else return (jint) handle;
}
示例5: ASSERT
bool CSingleAccess::Setup(LPCTSTR signalName)
{
if(signalName)
{
#ifdef _DEBUG
m_signalName=signalName;
#endif
}
else
{
#ifdef _DEBUG
m_signalName="";
#endif
return false;
}
ASSERT(m_hSignal==NULL);
if(OpenMutex(MUTEX_ALL_ACCESS,false,signalName))
{
TRACE("CSingleAccess无法构造对象,因为名称[%s]已经存在!\n",signalName);
return false;
}
m_hSignal=CreateMutex(NULL,FALSE,signalName);
if(m_hSignal) ReleaseMutex(m_hSignal);
return m_hSignal!=NULL;
}
示例6: openwrite
int Mymutex::openwrite(wchar_t* name){
mutex=OpenMutex(MUTEX_ALL_ACCESS,false, (LPCWSTR)name);
if(mutex==NULL){
if(GetLastError()==ERROR_FILE_NOT_FOUND){
mutex=CreateMutex(NULL,false,(LPCWSTR)name);
}else{
printf("BBBBBBBB\n");
return -1;
}
}
int wr=WaitForSingleObject(mutex,INFINITE);
if(wr==WAIT_FAILED){
printf("BBBBBBBB1\n");
return -1;
}
file=CreateFileW(name,GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if (file==INVALID_HANDLE_VALUE){
return -1;
}
int pos=0;
int sr=SetFilePointer(file,0,(PLONG)&pos,FILE_END);
if(sr==INVALID_SET_FILE_POINTER){
return -1;
}
return 0;
}
示例7: OpenMutex
long CUpdateBar::OnSelfUpdateInit(WPARAM wParam, LPARAM lParam)
{
// Wait for terminating MUpdate.exe
HANDLE hMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, MUPDATE_MUTEXNAME);
if (hMutex) {
DWORD dwVal = WaitForSingleObjectEx(hMutex, INFINITE, TRUE);
TRACE("MUTEX Result = %d \n", dwVal);
}
// Copy MUpdate_New.exe to MUpdate.exe
if (!CopyFile("MUpdate_New.exe", "MUpdate.exe", FALSE)) {
DWORD dwError = GetLastError();
TRACE("CopyFile Error : %d \n", dwError);
}
DeleteFile("MUpdate_New.exe");
// Shutdown
exit(0);
// CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
// pFrame->DestroyWindow();
// pFrame->PostMessage(WM_CLOSE);
return TRUE;
}
示例8: _T
BOOL CSageApp::InitInstance()
{
LPCTSTR szSingleInstanceMutex = _T("EGAR SAGE {1772A390-F4B7-4d4c-8949-1A11955CC803}");
m_hSingleInstanceMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, szSingleInstanceMutex);
if (m_hSingleInstanceMutex)
{
return FALSE;
}
m_hSingleInstanceMutex = CreateMutex(NULL, FALSE, szSingleInstanceMutex);
// Change the registry key under which our settings are stored.
SetRegistryKey(APP_KEY);
CoInitialize(NULL);
CTracer::CreateFileName();
CSageDlg dlg;
m_pMainWnd = &dlg;
dlg.DoModal();
CoUninitialize();
if (m_hSingleInstanceMutex)
CloseHandle(m_hSingleInstanceMutex);
return FALSE;
}
示例9: OpenMutex
void ClientManager::SubstractUser(int fd)
{
#if 0
/* Mutex Open */
m_hMutex = OpenMutex(MUTEX_ALL_ACCESS, TRUE, (LPCWSTR)SHARE_MUTEX);
if (m_hMutex == NULL)
{
printf("Mutex Handle is NULL.. \n");
m_hMutex = CreateMutex(NULL, FALSE, (LPCWSTR)SHARE_MUTEX);
}
WaitForSingleObject(m_hMutex, INFINITE);
#endif
/* Mutex Open */
unordered_map<int, ObjectUser*>::iterator it_user;
it_user = map_user.find(fd);
if (it_user != map_user.end()) {
map_user.erase(it_user);
delete UserInfo[fd];
SubtractClientCnt();
};
#if 0
/* Mutex Close */
ReleaseMutex(m_hMutex);
//CloseHandle(m_hMutex);
m_hMutex = NULL;
/* Mutex Close */
#endif
}
示例10: WinMain
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nShowCmd) {
lua_State *L;
int hostCommand, initTop, endTop;
if (OpenMutex(MUTEX_ALL_ACCESS, FALSE, g_mutex)) {
MessageBoxA(0, "CWG4 is already loaded.", g_appName, MB_ICONERROR);
return 1;
}
CreateMutex(NULL, TRUE, g_mutex);
do {
hostCommand = 0;
L = luaL_newstate();
if (!L) return 2;
luaL_openlibs(L);
initTop = lua_gettop(L);
if (luaL_loadfile(L, "init.lua") || lua_pcall(L, 0, LUA_MULTRET, 0)) {
MessageBoxA(0, lua_tostring(L, -1), g_appName, MB_ICONERROR);
lua_close(L);
return 3;
}
endTop = lua_gettop(L);
if (endTop > initTop) hostCommand = lua_tointeger(L, -1);
lua_close(L);
} while (hostCommand == 42);
return 0;
}
示例11: OpenMutex
void World::UpdateGraphic()
{
bg->Update();
map->UpdateGraphic();
HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NAME_MUTEX2);
if (mutex)
{
WaitForSingleObject(mutex, INFINITE);
for (int i = 0; i < entitys.size(); i++)
{
entitys[i]->UpdateGraphic();
}
if (player)
player->UpdateGraphic();
ReleaseMutex(mutex);
for (size_t i = 0; i < bullets.size(); i++)
{
bullets[i]->UpdateGraphic();
}
}
}
示例12: check_already
//
// すでに起動済みかどうかを Mutex で判定
// out: TRUE .. 起動済み
//
BOOL check_already(void)
{
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sa;
TCHAR mutex_name[MAX_PATH];
wsprintf(mutex_name, MUTEX_STRING, service_name);
// 排他処理用 mutex を作成
mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, mutex_name);
if(mutex != NULL) {
if(!service_flag) {
// すでに起動されています。
MessageBoxResourceText(NULL, IDS_ERROR_ALREADY_EXECUTE, NULL, ERROR_HEADER, MB_OK);
}
return TRUE;
}
sa.lpSecurityDescriptor = NULL;
if(InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) {
if(SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE)) {
sa.lpSecurityDescriptor = &sd;
}
}
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
mutex = CreateMutex(&sa, FALSE, mutex_name);
return FALSE;
}
示例13: THR_ObtainMutex
CONDITION
THR_ObtainMutex(int fac) {
#ifdef CTN_USE_THREADS
#ifdef _MSC_VER
char name[32];
HANDLE hTmpMutex;
mutexName(fac, name);
hTmpMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, name);
WaitForSingleObject(hMutex[fac], INFINITE);
/* From JCS, close temp handle to get eliminate resource leak. */
CloseHandle(hTmpMutex);
return THR_NORMAL;
#else
int cond;
if (!initialized) {
fprintf(stderr,
"Threads not initialized in call to THR_ObtainMutex: exiting\n");
exit(1);
}
cond = mutex_lock(&mutex[fac]);
if (cond != 0) {
fprintf(stderr, "Failed on call to mutex_lock in THR_ObtainMutex\n");
return THR_GENERICFAILURE;
}
return THR_NORMAL;
#endif
#else
return THR_NORMAL;
#endif
}
示例14: sizeof
BOOL CTabletInfoApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
hMutex=OpenMutex(MUTEX_ALL_ACCESS,FALSE,"TabletInfo");
if(hMutex)
{
//AfxMessageBox("程序已经启动,请双击对应的系统图标打开程序!",MB_ICONERROR);
HWND hWnd=FindWindow(NULL,"TabletInfo v1.4");
if (hWnd)
{
if(!IsWindowVisible(hWnd))
ShowWindow(hWnd,SW_SHOW);
SetForegroundWindow(hWnd);
}
return FALSE;
}
else
{
hMutex=CreateMutex(NULL,FALSE,"TabletInfo");
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("TabletInfo"));
CTabletInfoDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
示例15: etk_win32_sem_locker_t
etk_win32_sem_locker_t()
{
const char *lockerName = "_etk_global_";
if((iLocker = OpenMutex(MUTEX_ALL_ACCESS, FALSE, lockerName)) == NULL)
iLocker = CreateMutex(NULL, FALSE, lockerName);
if(iLocker == NULL) ETK_ERROR("[KERNEL]: Can't initialize global semaphore!");
}