词条 | findwindow |
释义 | 简述FindWindow, LPCTSTR lpClassName, // pointer to class name LPCTSTR lpWindowName // pointer to window name ); HWND hWnd, // handle of window LPDWORD lpdwProcessId // address of variable for process identifier ); DWORD dwDesiredAccess, // access flag BOOL bInheritHandle, // handle inheritance flag DWORD dwProcessId // process identifier ); HANDLE hProcess, // handle to process whose memory is written to LPVOID lpBaseAddress, // address to start writing to LPVOID lpBuffer, // pointer to buffer to write data to DWORD nSize, // number of bytes to write LPDWORD lpNumberOfBytesWritten // actual number of bytes written ); const ResourceOffset: dword = $004219F4; resource: dword = 3113226621; ResourceOffset1: dword = $004219F8; resource1: dword = 1940000000; ResourceOffset2: dword = $0043FA50; resource2: dword = 1280185; ResourceOffset3: dword = $0043FA54; resource3: dword = 3163064576; ResourceOffset4: dword = $0043FA58; resource4: dword = 2298478592; var hw: HWND; pid: dword; h: THandle; tt: Cardinal; begin hw := FindWindow('XX', nil); if hw = 0 then Exit; GetWindowThreadProcessId(hw, @pid); h := OpenProcess(PROCESS_ALL_ACCESS, false, pid); if h = 0 then Exit; if flatcheckbox1.Checked=true then begin WriteProcessMemory(h, Pointer(ResourceOffset), @Resource, sizeof(Resource), tt); WriteProcessMemory(h, Pointer(ResourceOffset1), @Resource1, sizeof(Resource1), tt); end; if flatcheckbox2.Checked=true then begin WriteProcessMemory(h, Pointer(ResourceOffset2), @Resource2, sizeof(Resource2), tt); WriteProcessMemory(h, Pointer(ResourceOffset3), @Resource3, sizeof(Resource3), tt); WriteProcessMemory(h, Pointer(ResourceOffset4), @Resource4, sizeof(Resource4), tt); end; MessageBeep(0); CloseHandle(h); close 函数原型:HWND FindWindow ( LPCSTR lpClassName, LPCSTR lpWindowName ); 参数表:lpClassName 指向一个以null结尾的、用来指定类名的字符串或一个可以确定类名字符串的原子。如果这个参数是一个原子,那么它必须是一个在调用此函数前已经通过GlobalAddAtom函数创建好的全局原子。这个原子(一个16bit的值),必须被放置在lpClassName的低位字节中,lpClassName的高位字节置零。 如果该参数为null时,将会寻找任何与lpWindowName参数匹配的窗口。 lpWindowName 指向一个以null结尾的、用来指定窗口名(即窗口标题)的字符串。如果此参数为NULL,则匹配所有窗口名。 返回值:如果函数执行成功,则返回值是拥有指定窗口类名或窗口名的窗口的句柄。 如果函数执行失败,则返回值为 NULL 。可以通过调用GetLastError函数获得更加详细的错误信息。 如何在C#中使用导入库:user32.lib 头文件:winuser.h ***.Net 中运用 命名空间 using System.Runtime.InteropServices; 导入库 [DllImport("user32.dll")] 函数原型 public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 参数说明 lpClassName String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类 lpWindowName String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收 任何窗口标题 返回值 :句柄 如何在C++中使用头文件:afxwin.h 例子: // activate an application with a window with a specific class name BOOL CMyApp::FirstInstance() { CWnd *pWndPrev, *pWndChild; // Determine if a window with the class name exists... pWndPrev = CWnd::FindWindow(_T("MyNewClass"), NULL); if(NULL != pWndPrev) { // If so, does it have any popups? pWndChild = pWndPrev->GetLastActivePopup(); // If iconic, restore the main window if(pWndPrev->IsIconic()) pWndPrev->ShowWindow(SW_RESTORE); // Bring the main window or its popup to the foreground pWndChild->SetForegroundWindow(); // and you are done activating the other application returnFALSE; } returnTRUE; } 声明:VB6.0中的声明: Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long FINDWINDOWS Delphi简单例子: var t:thandle; begin t:=findwindow(nil,'计算器'); //运行windows计算器,获取计算器的句柄 showmessage(inttostr(t)); end; 易语言中的声明: .版本 2 .DLL命令 FindWindow, 整数型, "user32.dll", "FindWindowA" .参数 类名, 文本型 .参数 标题, 文本型 |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。