locked
PInvoke doesn't exist. RRS feed

  • Question

  • I try to compile the  following code in WM 6.1 Standard but it had an error about PInvoke.
    I copied the code from this link.
    http://msdn.microsoft.com/en-us/library/ms633558%28VS.85%29.aspx

    The code is shown below.
    [DllImport("user32.dll")]
    public static extern IntPtr WindowFromPoint(Point lpPoint);

    [DllImport("user32.dll")]
    public static extern bool GetCursorPos(out Point lpPoint);

    public static IntPtr GetWindowUnderCursor()
    {
    Point ptCursor = new Point();

    if (!(PInvoke.GetCursorPos(out ptCursor)))
    return IntPtr.Zero;

    return WindowFromPoint(ptCursor);
    }
    but it display an error "The name 'PInvoke' does not exist in the current context".

    My aim for this code is to get the application name that the cursor are point to.

    Please help and thank in advance.

    KSD
    Tuesday, January 19, 2010 9:23 AM

Answers

  • Hi,

    User32.dll is not supported by mobile OS. You have to make use of coredll.

    You can check here:

    http://www.pinvoke.net/


    Regards,
    Malleswar
    • Marked as answer by Beir.Bear Wednesday, January 20, 2010 2:26 AM
    Tuesday, January 19, 2010 10:08 AM

All replies

  • Hi,

    User32.dll is not supported by mobile OS. You have to make use of coredll.

    You can check here:

    http://www.pinvoke.net/


    Regards,
    Malleswar
    • Marked as answer by Beir.Bear Wednesday, January 20, 2010 2:26 AM
    Tuesday, January 19, 2010 10:08 AM
  • Ohh, I got it (thank you) but I got pointer to null (0).
    I try to get the text that the cursor are hover over, but still can not get it.
    Please give me more suggestion.
    KSD
    Tuesday, January 19, 2010 10:11 AM