这篇教程C++ GetWindowThreadProcessId函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetWindowThreadProcessId函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowThreadProcessId函数的具体用法?C++ GetWindowThreadProcessId怎么用?C++ GetWindowThreadProcessId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetWindowThreadProcessId函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: close_alert_window_enumBOOL CALLBACK close_alert_window_enum( HWND hwnd, LPARAM lParam ){ char buf[ 7 ] = { 0 }; PROCESS_HANDLE_ID p = *( (PROCESS_HANDLE_ID *)lParam ); DWORD pid = 0; DWORD tid = 0; /* We want to find and close any window that: * 1. is visible and * 2. is a dialog and * 3. is displayed by any of our child processes */ if ( !IsWindowVisible( hwnd ) ) return TRUE; if ( !GetClassNameA( hwnd, buf, sizeof( buf ) ) ) return TRUE; /* Failed to read class name; presume it is not a dialog. */ if ( strcmp( buf, "#32770" ) ) return TRUE; /* Not a dialog */ /* GetWindowThreadProcessId() returns 0 on error, otherwise thread id of * window message pump thread. */ tid = GetWindowThreadProcessId( hwnd, &pid ); if ( tid && is_parent_child( p.pid, pid ) ) { /* Ask really nice. */ PostMessageA( hwnd, WM_CLOSE, 0, 0 ); /* Now wait and see if it worked. If not, insist. */ if ( WaitForSingleObject( p.h, 200 ) == WAIT_TIMEOUT ) { PostThreadMessageA( tid, WM_QUIT, 0, 0 ); WaitForSingleObject( p.h, 300 ); } /* Done, we do not want to check any other window now. */ return FALSE; } return TRUE;}
开发者ID:4ukuta,项目名称:core,代码行数:43,
示例2: EnumWindowsCallbackstatic BOOL CALLBACK EnumWindowsCallback(HWND windowHandle, LPARAM lParam){ DWORD pid; GetWindowThreadProcessId(windowHandle, &pid); if (pid == lParam) { // This window belongs to the process if (!windowTitle.empty()) return TRUE; TCHAR text[256]; GetWindowText(windowHandle, text, sizeof(text)); if ((GetWindowLong(windowHandle, GWL_STYLE) & WS_VISIBLE)) { windowTitle = text; return FALSE; } } return TRUE;}
开发者ID:pampersrocker,项目名称:G-CVSNT,代码行数:19,
示例3: EnumWindowsProcBOOL CALLBACK EnumWindowsProc( HWND hwnd, LONG lParam ){ DWORD pid = 0; DWORD i; CHAR buf[TITLE_SIZE]; PTASK_LIST_ENUM te = (PTASK_LIST_ENUM)lParam; PTASK_LIST tlist = te->tlist; DWORD numTasks = te->numtasks; // // get the processid for this window // if (!GetWindowThreadProcessId( hwnd, &pid )) { return TRUE; } // // look for the task in the task list for this window // for (i=0; i<numTasks; i++) { if (tlist[i].dwProcessId == pid) { tlist[i].hwnd = hwnd; // // we found the task so lets try to get the // window text // if (GetWindowText( tlist[i].hwnd, buf, zsizeof(buf) )) { // // got it, so lets save it // strcpy( (LPSTR)tlist[i].WindowTitle, buf ); } break; } } // // continue the enumeration // return TRUE;}
开发者ID:DeegC,项目名称:10d,代码行数:43,
示例4: WriteC3CMemoryint WriteC3CMemory(uint32_t lpAddress, void *buf, int len){ if (hwnd) { DWORD pid; GetWindowThreadProcessId(hwnd, &pid); HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); SIZE_T wlen; WriteProcessMemory(hProc, (void *) lpAddress, buf, len, &wlen); CloseHandle(hProc); if (len == wlen) { return TRUE; } else { fprintf(stderr, "Memory write error/n"); return FALSE; } } else { return FALSE; }}
开发者ID:CoreDumpling,项目名称:c3me,代码行数:19,
示例5: GetWindowThreadProcessId//! Entrypoint used to make another window become subclassed.bool BlueWindow::SubclassNewWindow(HWND hwnd){ DWORD windowpid; if (hwnd != NULL && IsWindow(hwnd) && GetWindowThreadProcessId(hwnd, &windowpid) && windowpid == GetCurrentProcessId() && OldWindowProcs.find(hwnd) == OldWindowProcs.end()) { // Found the window that is from our process. Subclass it. WNDPROC lpfnOldWindowProc = (WNDPROC) LongToPtr(GetWindowLongPtr(hwnd, GWL_WNDPROC)); OldWindowProcs.insert(std::make_pair<HWND, WNDPROC>(hwnd, lpfnOldWindowProc)); SetWindowLongPtr(hwnd, GWL_WNDPROC, PtrToLong(BlueWindow::SubclassProc)); ForceNonclientRepaint(hwnd); return true; } return false; // could not successfully subclass specified window.}
开发者ID:bovine,项目名称:stuntour,代码行数:20,
示例6: check_console/* See if we were launched from a console window. */bool check_console() { /* If we're running in a service context there will be no console window. */ HWND console = GetConsoleWindow(); if (! console) return false; unsigned long pid; if (! GetWindowThreadProcessId(console, &pid)) return false; /* If the process associated with the console window handle is the same as this process, we were not launched from an existing console. The user probably double-clicked our executable. */ if (GetCurrentProcessId() != pid) return true; /* We close our new console so that subsequent messages appear in a popup. */ FreeConsole(); return false;}
开发者ID:kirillkovalenko,项目名称:nssm,代码行数:20,
示例7: TimerFuncvoid CALLBACK TimerFunc(HWND hWnd,UINT nMsg,UINT_PTR nTimerid,DWORD dwTime){(void) hWnd;(void) nMsg;(void) dwTime;DWORD wso; wso = WaitForSingleObject(hSynhroMutex, 0); if (wso == WAIT_OBJECT_0 || wso == WAIT_ABANDONED) { KillTimer(0, nTimerid); TimerID = 0; while( 1 ) { POINT curPt; HWND targetWnd; DWORD winProcessID = 0; if( !GetCursorPos( &curPt ) ) break; if( GlobalData == NULL || GlobalData->LastPt.x != curPt.x || GlobalData->LastPt.y != curPt.y) break; if( ( targetWnd = GetWindowFromPoint( curPt ) ) == NULL ) break; if( GlobalData->LastWND != targetWnd ) break; GetWindowThreadProcessId( targetWnd, &winProcessID ); if( winProcessID != ourProcessID ) { char className[64]; if( !GetClassName( targetWnd, className, sizeof(className) ) ) break; if( lstrcmpi( className, "ConsoleWindowClass" ) != 0 ) break; } SendWordToServer(); break; } ReleaseMutex(hSynhroMutex); }}
开发者ID:5w1tch,项目名称:goldendict,代码行数:43,
示例8: EnumFindProcessWndBOOL CALLBACK EnumFindProcessWnd(HWND hwnd, LPARAM lParam){ DWORD procid = 0; TCHAR WindowClass [40]; GetWindowThreadProcessId(hwnd, &procid); GetClassName(hwnd, WindowClass, countof(WindowClass)); if (procid == GetCurrentProcessId() && (_tcscmp(WindowClass, _l("MediaPlayerClassicW")) == 0 || // MPC-HC window _tcscmp(WindowClass, _l("WMPlayerApp")) == 0 || // WMPlayer window _tcscmp(WindowClass, _l("eHome Render Window")) == 0 // WMC window ) ) { HWND* pWnd = (HWND*) lParam; *pWnd = hwnd; return FALSE; } return TRUE;}
开发者ID:TheRyuu,项目名称:ffdshow,代码行数:19,
示例9: resizeWindowvoidresizeWindow(HWND hWnd, int width, int height) { RECT rClient; GetClientRect(hWnd, &rClient); if (width == rClient.right - rClient.left && height == rClient.bottom - rClient.top) { return; } RECT rWindow; GetWindowRect(hWnd, &rWindow); width += (rWindow.right - rWindow.left) - rClient.right; height += (rWindow.bottom - rWindow.top) - rClient.bottom; // SetWindowPos will hang if this ever happens. assert(GetCurrentThreadId() == GetWindowThreadProcessId(hWnd, NULL)); SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, width, height, SWP_NOMOVE);}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:19,
示例10: GetConsoleWindowProcstatic BOOL CALLBACK GetConsoleWindowProc(HWND hWnd, LPARAM lParam){ const char cConsoleClassName[] = "ConsoleWindowClass"; DWORD dwPid = (DWORD)-1; char cBuf[sizeof(cConsoleClassName)] = ""; GetWindowThreadProcessId(hWnd, &dwPid); if (dwPid != GetCurrentProcessId()) return TRUE; if (GetClassName(hWnd, cBuf, sizeof cBuf) != sizeof(cConsoleClassName)-1) return TRUE; if (strcmp(cConsoleClassName, cBuf) != 0) return TRUE; *(HWND*)lParam = hWnd; return FALSE;}
开发者ID:richardneish,项目名称:ltrdata,代码行数:19,
示例11: FindWindowFB::VariantList btlauncherAPI::stopRunning(const std::wstring& val) { FB::VariantList list; if (wcsstr(val.c_str(), _T(BT_HEXCODE)) || wcsstr(val.c_str(), _T(BTLIVE_CODE))) { HWND hWnd = FindWindow( val.c_str(), NULL ); DWORD pid; DWORD parent; parent = GetWindowThreadProcessId(hWnd, &pid); HANDLE pHandle = OpenProcess(PROCESS_TERMINATE, NULL, pid); if (! pHandle) { list.push_back("could not open process"); list.push_back(GetLastError()); } else { BOOL result = TerminateProcess(pHandle, 0); list.push_back("ok"); list.push_back(result); } } return list;}
开发者ID:bbarrows,项目名称:btlauncher,代码行数:19,
示例12: AttachGuiWindowvoid AttachGuiWindow(HWND hOurWindow){ _ASSERTEX(gbAttachGuiClient); // Уже должен был быть установлен? gnAttachMsgId = RegisterWindowMessageW(L"ConEmu:Attach2Gui"); if (gnAttachMsgId) { DWORD nWndTID = GetWindowThreadProcessId(hOurWindow, NULL); ghAttachMsgHook = SetWindowsHookExW(WH_CALLWNDPROC, AttachGuiWindowCallback, NULL, nWndTID); // Поскольку аттач хорошо бы выполнять в той нити, в которой крутится окно - то через хук AttachMsgArg args = {gnAttachMsgId, 0, ghConEmuWnd, hOurWindow}; LRESULT lRc = SendMessageW(hOurWindow, gnAttachMsgId, gnAttachMsgId, (LPARAM)&args); _ASSERTEX(args.Result == gnAttachMsgId); UNREFERENCED_PARAMETER(lRc); UnhookWindowsHookEx(ghAttachMsgHook); ghAttachMsgHook = NULL; }}
开发者ID:isleon,项目名称:ConEmu,代码行数:19,
示例13: whilebool Input::Initialize(){ bool debug = false; int i = 0; while (!Vars.bActive) { if (i >= 300) { MessageBox(0, "Failed to set hooks, exiting!", "D2Etal", 0); return false; } if (fpGetHwnd() && (MENU::ClientState() == ClientStateMenu || MENU::ClientState() == ClientStateInGame)) { if (!Vars.oldWNDPROC) Vars.oldWNDPROC = (WNDPROC)SetWindowLong(fpGetHwnd(), GWL_WNDPROC, (LONG)Input::WndProc); if (!Vars.oldWNDPROC) continue; DWORD _mainThread = GetWindowThreadProcessId(fpGetHwnd(), 0); if (_mainThread) { if (!Vars.hKeybHook) Vars.hKeybHook = SetWindowsHookEx(WH_KEYBOARD, Input::KeyPress, NULL, _mainThread); if (!Vars.hMouseHook) Vars.hMouseHook = SetWindowsHookEx(WH_MOUSE, Input::MouseMove, NULL, _mainThread); } } else continue; if (Vars.hKeybHook && Vars.hMouseHook) { Vars.bActive = TRUE; } if (debug && Vars.oldWNDPROC && Vars.hKeybHook && Vars.hMouseHook) { MessageBox(0, "All Hooks Set!", "D2Etal", 0); } Sleep(50); i++; } return true;}
开发者ID:Nedkali,项目名称:V8EtalDl,代码行数:42,
示例14: GetWindowThreadProcessIdBOOL LowLevelHook::Initialize(HWND hwndMain){TRY_CATCH //Store our window's handle g_hwndVNCViewer = hwndMain; if (0 == g_Instances) { ++g_Instances; HINSTANCE hInstance = NULL ; g_fHookActive = TRUE; g_VncProcessID = 0 ; g_HookID = 0 ; g_fGlobalScrollLock = FALSE ; //Receive the HInstacne of this window //(required because LowLevel-Keyboard-Hook must be global, // and need the HMODULE parameter in SetWindowsHookEx) hInstance = (HINSTANCE)GetWindowLong(g_hwndVNCViewer,GWL_HINSTANCE); if (hInstance==NULL) { return FALSE; } //Store the ProcessID of the VNC window. //this will prevent the keyboard hook procedure to interfere //with keypressed in other processes' windows GetWindowThreadProcessId(g_hwndVNCViewer,&g_VncProcessID); //Try to set the hook procedure g_HookID = SetWindowsHookEx(WH_KEYBOARD_LL,VncLowLevelKbHookProc,hInstance,0); if (0 == g_HookID) { Log.WinError(_ERROR_,_T("Failed to SetWindowsHookEx ")); return FALSE ; } return TRUE; } ++g_Instances; return TRUE;CATCH_THROW()}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:42,
示例15: ExplorerExecutionvoid ExplorerExecution (HWND hwnd, LPARAM lParam){ DWORD hwndid; int i; GetWindowThreadProcessId(hwnd,&hwndid); if (hwndid == pid){ /* Replace keybd_event with SendMessage() and PostMessage() calls */ printf("HANDLE Found. Attacking =)/n"); SetForegroundWindow(hwnd); keybd_event(VK_LWIN,1,0,0); keybd_event(VkKeyScan('r'),1,0,0); keybd_event(VK_LWIN,1,KEYEVENTF_KEYUP,0); keybd_event(VkKeyScan('r'),1,KEYEVENTF_KEYUP,0); for(i=0;i<strlen(buf);i++) { if (buf[i]==':') { keybd_event(VK_SHIFT,1,0,0); keybd_event(VkKeyScan(buf[i]),1,0,0); keybd_event(VK_SHIFT,1,KEYEVENTF_KEYUP,0); keybd_event(VkKeyScan(buf[i]),1,KEYEVENTF_KEYUP,0); } else { if (buf[i]=='//') { keybd_event(VK_LMENU,1,0,0); keybd_event(VK_CONTROL,1,0,0); keybd_event(VkKeyScan(' C++ GetWindowsDirectory函数代码示例 C++ GetWindowTheme函数代码示例
|