下面的代码 取屏幕任意一点的颜色, 这个代码在游戏没打开之前都好用,游戏打开以后不管取哪个窗口的颜色,返回值都为0,关掉游戏以后又能正常运行了,是GetPixel被禁用了吗 还是有别的原因呢
'Form里----------------------------------------
Dim pi As POINTAPI
Dim Ret As Long
Ret = GetCursorPos(pi)
Dim crtHwnd As Long
crtHwnd = WindowFromPoint(pi.x, pi.y)
Dim rect As rect
Ret = GetWindowRect(crtHwnd, rect)
Me.TXT_BloodX.BackColor = GetColorFromPoint(crtHwnd, pi.x - rect.Left, pi.y - rect.Top)
'Module里----------------------------------------Public Function GetColorFromPoint(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long) As Long
Dim hDC As Long
hDC = GetWindowDC(hwnd)
Dim lngColor As Long
lngColor = GetPixel(hDC, x, y)
Dim lngRet As Long
lngRet = ReleaseDC(hwnd, hDC)
GetColorFromPoint = lngColor
End Function
'Form里----------------------------------------
Dim pi As POINTAPI
Dim Ret As Long
Ret = GetCursorPos(pi)
Dim crtHwnd As Long
crtHwnd = WindowFromPoint(pi.x, pi.y)
Dim rect As rect
Ret = GetWindowRect(crtHwnd, rect)
Me.TXT_BloodX.BackColor = GetColorFromPoint(crtHwnd, pi.x - rect.Left, pi.y - rect.Top)
'Module里----------------------------------------Public Function GetColorFromPoint(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long) As Long
Dim hDC As Long
hDC = GetWindowDC(hwnd)
Dim lngColor As Long
lngColor = GetPixel(hDC, x, y)
Dim lngRet As Long
lngRet = ReleaseDC(hwnd, hDC)
GetColorFromPoint = lngColor
End Function
ret = GetPixel(dc, nRect.X, nRect.Y)
Not all devices support GetPixel. An application should call GetDeviceCaps to determine whether a specified device supports this function.
可能游戏不支持GetPixel,它会影响到别的程序也不支持这个函数吗,有谁遇到过同样现象?to chenhui530
被hook了是个什么思路呢,能具体讲讲吗?ps 游戏是《英雄》 谁愿意可以试一下
Private Const RASTERCAPS As Long = 38
Private Const RC_BITBLT As Long = 1Function CanGetPixel(ByVal hdc As Long) As Boolean
CanGetPixel = (GetDeviceCaps(hdc, RASTERCAPS) And RC_BITBLT) <> 0
End Function