Easy Hook lib를 사용하고 있습니다. 소유자 윈도우가 어떻게 처리됩니까?DrawText Hook에서 자식의 부모 Hwd 가져 오기
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public override string ToString()
{
return $"[Left: {Left}, Top: {Top}, Right: {Right}, Bottom: {Bottom}]";
}
}
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int DrawText(IntPtr hDc, string lpString, int nCount, ref Rect lpRect, uint uFormat);
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
public delegate int DDrawText(IntPtr hDc, string lpString, int nCount, ref Rect lpRect, uint uFormat);
private int DrawText_Hooked(IntPtr hDc, string lpString, int nCount, ref Rect lpRect, uint uFormat)
{
var This = (Main) HookRuntimeInfo.Callback;
lock (This._queue)
{
var parent = GetAncestor(hDc, GetAncestorFlags.GetParent); // always return 0! why????????????????
This._queue.Push($"parent [{parent}]");
}
return DrawText(hDc, lpString, nCount, ref lpRect, uFormat);
}
GetWindowDC,의 GetDC,의 getParent 및 기타 방법 부모 창을 가져도 전혀 작동하지 않습니다?
GetAncestor는 창 핸들을 필요로하며 드로잉 컨텍스트를 전달합니다. 드로잉 컨텍스트에서 창 핸들을 가져 오려면 [GetWindowFromDC] (https://msdn.microsoft.com/en-us/library/dd145201(VS.85) .aspx)를 호출하십시오. –
무엇을하려고합니까? – andlabs
WindowFromDC는 작동하지 않습니다! –