|
[求助]通过PID 或 TID得到其主窗口句柄的问题!!!
谢谢, 不知你有没有试过,我以前试过了,好像不能起到识别的作用,同时比较“PID”和“TID”也没多大的识别作用, 因为,好像大部分程序都会自动创建有一个“输入法窗口(类名是:MSCTFIME UI 和 M)”的。 我想, 如果可以通过“PID”或“TID”传个自定义标记给当前窗口,这样就可以通过“EnumWindow”或“EnumThreadWindow”来识别做过标记的“主窗口”了,不过,好像有没有相关的 API。 下面是我现在的一种方法,很不可靠: if ThreadCount = 1 then // 单线程的程序,调用“EnumThreadWindows” 来得到主窗口句柄 //_SYSTEM_PROCESSES EnumThreadWindows(MyGetThreadID(Threads[0].ClientId), @EnumThreadWndProc, Integer(@HWND_A)) else begin // 多线程的的程序,想不出有什么好的方法来识别主窗口句柄,等高手出手了 end; // 这个是我调用来识别“单线程的程序”的主窗口,可靠。 function EnumThreadWndProc(WinHWND : HWND; var ResultWinHWND : HWND): Bool; stdcall; begin Result:=False; ResultWinHWND :=WinHWND; end; //这是我以前用调用的“EnumWindow”和“EnumThreadWindow”的识别过程,想不出有什么好的方法来识别主窗口句柄,所以未调用。 function EnumWindowsProc(Wnd: DWORD; var EI: TEnumInfo): Bool; stdcall; EnumWindow var PID : DWORD; begin GetWindowThreadProcessID(Wnd, @PID); Result := (PID <> EI.ProcessID) or (not IsWindowVisible(WND)) or (not IsWindowEnabled(WND)); if not result then EI.WinHandle := WND; end; function EnumThreadWndProcEX(WinHWND : HWND; var ResultWinHWND : HWND): Bool; stdcall; // 多线程的程序,很不可靠 var PClassName : array[0..12] of Char; ParentHWND, PID : HWND; AA : String; begin Result:=True; ResultWinHWND:=Windows.GetParent(WinHWND); // if ResultWinHWND = 0 then // 没有父窗口,则它就是主窗口 begin ResultWinHWND:= WinHWND; Result:=False; end; end; |
|
[求助]如果一个进程有窗口,如何通过PID得到其主窗口句柄呢(不知道窗口名字和类名)?
你听过,有个叫输入法的窗口吗? |
|
[求助]如果一个进程有窗口,如何通过PID得到其主窗口句柄呢(不知道窗口名字和类名)?
这种方法只适合“VC”, “VC++”, 编写的程序,不适合“DELPHI”编写的的程序(基本主窗口只用来通信, 不是用来显示(主介面或操作)的窗口) |
|
[求助]如果一个进程有窗口,如何通过PID得到其主窗口句柄呢(不知道窗口名字和类名)?
这个问题搞了我 7 个月,前几天以为搞好了,但试了试,发现还是不行, 通过“PID得到其主窗口句柄”根本就没有好方法, 就是比较同一 PID 和 TID 也没用.... 这个方法很差!!!! |
|
|
|
[求助]不死心, 再问:"Windows 的“当按 CTRL 键时显示指针是用了什么 API 来实现的?"
编辑出错, 重发了...................... |
|
[求助]不死心, 再问:"Windows 的“当按 CTRL 键时显示指针是用了什么 API 来实现的?"
谢谢, 效果很完美!!! 但好像不能自定义画笔颜色,如:SetROP2 如果用 R2_COPYPEN , 就不能擦除上次绘制的图形: 不过,好像想要“蓝色”的, 指定“黄色”,就可以得到“蓝色”了。 procedure TForm1.Button1Click(Sender: TObject); var ScreenDC : HDC; PointA : TPoint; nS, I, LeltP, BottomP, RightP, TopP : integer; hNewPen, hOldPen : HPEN; begin ScreenDC:=GetDC(0); nS:=SaveDC(ScreenDC); hNewPen := CreatePen(PS_SOLID, //指定画笔样式,可以是下述常数之一 // PS_SOLID 画笔画出的是实线 // PS_DASH 画笔画出的是虚线(nWidth必须是1) // PS_DOT 画笔画出的是点线(nWidth必须是1) // PS_DASHDOT 画笔画出的是点划线(nWidth必须是1) // PS_DASHDOTDOT 画笔画出的是点-点-划线(nWidth必须是1) // PS_NULL 画笔不能画图 // PS_INSIDEFRAME 画笔在由椭圆、矩形、圆角矩形、饼图以及弦等生成的封闭对象框中画图。如指定的准确RGB颜色不存在,就进行抖动处理 3, // 以逻辑单位表示的画笔的宽度 clYellow); // 画笔的RGB颜色 // clWhite // clGreen 蓝色 hOldPen := HPEN(SelectObject(ScreenDC, hNewPen)); // 该函数选择一对象到指定的设备上下文环境中,该新对象替换先前的相同类型的对象。 SetROP2(ScreenDC, R2_XORPEN //R2_BLACK //所有绘制出来的像素为黑色 // R2_WHITE //所有绘制出来的像素为白色 // R2_NOP // Pixel remains unchanged. //任何绘制将不改变当前的状态 // R2_NOT //当前绘制的像素值设为屏幕像素值的反,这样可以覆盖掉上次的绘图,(自动擦除上次绘制的图形) // R2_COPYPEN //使用当前的画笔的颜色 // R2_NOTCOPYPEN //当前画笔的反色 ); // 该函数的主要的作用是根据nDrawMode设置的方式重新设定绘图的方式 GetCursorPos(PointA); for I := 8 downto 1 do begin LeltP:=PointA.X - I * 15; TopP:=PointA.Y + I * 15; RightP:=PointA.X + I * 15; BottomP:=PointA.Y - I * 15; BeginPath(ScreenDC); Ellipse(ScreenDC, LeltP, TopP, RightP, BottomP); EndPath(ScreenDC); StrokePath(ScreenDC); Sleep(100); BeginPath(ScreenDC); Ellipse(ScreenDC, LeltP, TopP, RightP, BottomP); EndPath(ScreenDC); StrokePath(ScreenDC); end; SelectObject(ScreenDC, hOldPen); DeleteDC(ScreenDC); DeleteObject(hNewPen); RestoreDC(ScreenDC, nS); ReleaseDC(0, ScreenDC); end; |
|
[推荐]强!!! 汉字读音查询
谢谢, 我不是用易语言,谢谢. |
|
[推荐]强!!! 汉字读音查询
谢谢大家!!!! |
|
[推荐]强!!! 汉字读音查询
谢谢!!!!!!!!!!!!!! |
|
[原创]监控进程的启动的一种方法利用
好厉害!!! |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值