Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "GetWindow" in [All]

advapi32

.

    string _getWindowsProductId()

.

    string _getWindowsProductId()

Constants

.

        public class GetWindowConstants {

.

        public class GetWindowConstantsObsolete {

.

public class GetWindowConstants {

.

public class GetWindowConstantsObsolete {

dwmapi

.

static extern int DwmGetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE dwAttribute, out bool pvAttribute, int cbAttribute);

.

static extern int DwmGetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE dwAttribute, out RECT pvAttribute, int cbAttribute);

.

Declare Function DwmGetWindowAttribute Lib "dwmapi.dll" (TODO) As TODO

.
Documentation
[DwmGetWindowAttribute] on MSDN

Interfaces

.

        int GetWindow(out IntPtr phwnd);

.

    Public Overridable Sub GetWindow(ByRef phwnd As System.IntPtr) Implements IDeskBand.GetWindow, IDockingWindow.GetWindow, IOleWindow.GetWindow

.

    Sub GetWindow(ByRef phwnd As System.IntPtr)

.

    Sub GetWindow(ByRef phwnd As System.IntPtr)

.

    Sub GetWindow(ByRef phwnd As System.IntPtr)

.

        int GetWindow(out IntPtr phwnd);

.

    Public Overridable Sub GetWindow(ByRef phwnd As System.IntPtr) Implements IDeskBand.GetWindow, IDockingWindow.GetWindow, IOleWindow.GetWindow

.

    Sub GetWindow(ByRef phwnd As System.IntPtr)

.

    Sub GetWindow(ByRef phwnd As System.IntPtr)

.

    Sub GetWindow(ByRef phwnd As System.IntPtr)

.

    void GetWindow (out IntPtr phwnd) ;

.

      Sub GetWindow(<System.Runtime.InteropServices.Out()> ByRef phwnd As IntPtr)

.
IMPORTANT
The phwnd parameter for the VB Definition of GetWindow MUST be ByRef or else a 'protected memory' error will occur. - Andrew Powell 04.27.08
.

    void GetWindow(out IntPtr phwnd);

Enums

.

    static extern int DwmGetWindowAttribute(IntPtr hWnd, DwmWindowAttribute dwAttribute, out RECT lpRect, int cbAttribute);

.

Enum DwmGetWindowAttribute

.
Documentation
[DwmGetWindowAttribute] on MSDN
.
Summary
.
Summary
14: SPI
.

      /// Windows 95:  This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.

.

      /// Windows 95:  This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.

.

      /// Windows 95:  This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.

.

      /// Windows 95:  This flag is supported only if Windows Plus! is installed. See SPI_GETWINDOWSEXTENSION.

.

      SPI_GETWINDOWSEXTENSION = 0x005C,

.

    public const uint SPI_GETWINDOWSEXTENSION = 0x005C;

.

    SPI_GETWINDOWSEXTENSION = &H5C

.
Summary

coredll

.

[DllImport("coredll.dll", EntryPoint="GetWindowDC", SetLastError=true)]

.

private static extern IntPtr GetWindowDCCE(IntPtr hWnd);

.

<DllImport("coredll.dll", EntryPoint:="GetWindowDC", CharSet:=CharSet.Auto, ExactSpelling:=True)> _

.

Private Shared Function GetWindowDC(ByVal hWnd As HandleRef) As IntPtr

.

Declare Function GetWindowDC Lib "coredll.dll" (ByVal hWnd As HandleRef) As IntPtr

.
Documentation
[GetWindowDC] on MSDN
.
Summary
This function retrieves information about the specified window. GetWindowLong also retrieves the 32-bit value at the specified offset into the extra window memory of a window.
.

static extern System.UInt32 GetWindowLong(IntPtr  hWnd, int nIndex);

.

static extern IntPtr GetWindowLong(IntPtr window, int index);

.

    Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As System.UInt32

.
Documentation
[GetWindowLong] on MSDN
.
Summary
.

private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

.

Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer

.

        style = GetWindowLong(hWnd, GWL_STYLE);

.

    Private Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer

.

    style = GetWindowLong(hWnd, GWL_STYLE)

gdi32

19: BitBlt
.

            dc2=GetWindowDC(c.Handle);

20: GetDC
.

Use GetWindowDC(IntPtr hWnd); for taking the dc for the whole window since this function only gets the client area of the window.

.
Summary
.

static extern bool GetWindowExtEx(IntPtr hdc, out SIZE lpSize);

.
Documentation
[GetWindowExtEx] on MSDN
.
Summary
.

static extern bool GetWindowOrgEx(IntPtr hdc, out POINT lpPoint);

.
Documentation
[GetWindowOrgEx] on MSDN

psapi

.

GetWindowThreadProcessId(hWnd, out pid);

setupapi

.

   if (0 == GetWindowsDirectory(winDir, winDir.Capacity)) return (false);

uxtheme

.

public extern static IntPtr GetWindowTheme(IntPtr hWnd);

.

Public Declare Function GetWindowTheme Lib "uxtheme.dll" (ByVal hWnd As IntPtr) As IntPtr

.

If a window has a visual style applied, the GetWindowTheme function returns the most recent theme handle from OpenThemeData. If no visual style is applied, GetWindowTheme returns NULL.

.
Documentation
[GetWindowTheme] on MSDN

kernel32

.
Summary
.

static extern uint GetWindowsDirectory(StringBuilder lpBuffer,

.

<DllImport("kernel32.dll", SetLastError:=true, EntryPoint:="GetWindowsDirectoryW", CharSet:=CharSet.Unicode)> _

.

Public Function GetWindowsDirectory(<MarshalAs(UnmanagedType.LPTSTR)>lpBuffer As System.Text.StringBuilder, _

.

Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _

.

   Dim Res As Integer = GetWindowsDirectory(WinDir, WinDir.Length)

.

     GetWindowsDirectory(sb,i)

.

   int len = (int)GetWindowsDirectory(sb, MaxPathLength);

.

     GetWindowsDirectory(sb,ref  i);

.
Documentation
[GetWindowsDirectory] on MSDN

shell32

27: CSIDL
.

            CSIDL_WINDOWS           = 0x0024,    // GetWindowsDirectory()

.

        CSIDL_WINDOWS         = 0x0024,    // GetWindowsDirectory()

.

        CSIDL_WINDOWS       = 0x0024,    // GetWindowsDirectory()

Structures

.

     /// The length of the structure, in bytes. Before calling the GetWindowPlacement or SetWindowPlacement functions, set this member to sizeof(WINDOWPLACEMENT).

.

     /// GetWindowPlacement and SetWindowPlacement fail if this member is not set correctly.

.

Use with GetWindowPlacement and SetWindowPlacement

user32

.

var idAttach = GetWindowThreadProcessId(hFore, out id);

.

    static extern bool GetWindowRect(System.IntPtr hWnd, out RECT lpRect);

.

        GetWindowRect(hWnd, out to);

.

    bool GetWindowRect(int hWnd, RECT^ lpRect);

.

        GetWindowRect(hWnd, to);

.

    EnumedWindow callBackPtr = GetWindowHandle;

.

private static bool GetWindowHandle(IntPtr windowHandle, ArrayList windowHandles)

.

    [DllImport("user32.dll", EntryPoint = "GetWindowText",

.

    public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);

.

        int nLength = user32.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1);

.

      public static ArrayList GetWindows()

.

     EnumedWindow callBackPtr = GetWindowHandle;

.

      private static bool GetWindowHandle(IntPtr windowHandle, ArrayList windowHandles)

.

            GetWindowText(hWnd, sb, sb.Capacity);

.

    public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

.
Alternative
.

///     If the lpWindowName parameter is not NULL, FindWindow calls the <see cref="M:GetWindowText" /> function to

.

///     for <see cref="M:GetWindowText" />.

.

Can be used to find the active window Hwnd for GetWindowText

.

    Private Declare Auto Function GetWindowDC Lib "user32.dll" (ByVal windowHandle As IntPtr) As IntPtr

.

    Dim srcDeviceContext As IntPtr = GetWindowDC(windowHandle)

.

            //Optional Win32.GetWindowThreadProcessId(GetForegroundWindow(),out ProcessID)

.
Summary
There is no GetNextWindow function. It is actually a macro for the GetWindow function. Call GetWindow instead.
.
Summary
.

/// <remarks>The EnumChildWindows function is more reliable than calling GetWindow in a loop. An application that

.

/// calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window

.

private static extern IntPtr GetWindow(IntPtr hWnd, GetWindowType uCmd);

.

private enum GetWindowType : uint

.

Declare Auto Function GetWindow Lib "user32.dll" ( _

.

    Private Shared Function GetWindow(ByVal hWnd As IntPtr, ByVal uCmd As UInt32) As IntPtr

.

Private Enum GetWindowType As UInteger

.

Dim Owner As IntPtr = GetWindow(hWnd, GW_OWNER)

.

IntPtr dlgHandle = GetWindow(myProcess.MainWindowHandle, GW_ENABLEDPOPUP);

.
Documentation
[GetWindow] on MSDN
.
Summary
The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area. GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous attributes are lost.
.

static extern IntPtr GetWindowDC(IntPtr hWnd);

.

Public Shared Function GetWindowDC(ByVal hWnd As IntPtr) As IntPtr

.

Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long

.

GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any window is not recommended. The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title bar, menu, and scroll bars. The GetDC function can be used to retrieve a device context for the entire screen.

.

  Declare Function GetWindowDC Lib "user32" (ByVal hwnd As IntPtr) As IntPtr

.

    Dim MyGrphHdc As IntPtr = GetWindowDC(Me.Handle)

.
Documentation
[GetWindowDC] on MSDN
.
Summary
.

private static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi);

.

Public Declare Auto Function GetWindowInfo Lib "user32" _

.

Public Shared Function GetWindowInfo(ByVal hwnd As IntPtr, ByRef pwi As WINDOWINFO) As Boolean

.

You must assign the cbSize parameter prior to calling GetWindowInfo(). For example:

.

    GetWindowInfo(Handle, ref info);

.

    GetWindowInfo(Handle, info)

.
Documentation
[GetWindowInfo] on MSDN
.
Summary
.

On this platform this function is in fact a macro that calls GetWindowLong, so the EntryPoint property has to be set to the real function:

.

[DllImport("user32.dll", EntryPoint="GetWindowLong")]

.

static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);

.

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _

.

Private Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, <MarshalAs(UnmanagedType.I4)>nIndex As WindowLongFlags) As IntPtr

.

Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" _

.

[DllImport("user32.dll", EntryPoint="GetWindowLongPtr")]

.

private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);

.

<DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _

.

Private Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, <MarshalAs(UnmanagedType.I4)>nIndex As WindowLongFlags) As IntPtr

.

Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" _

.

[DllImport("user32.dll", EntryPoint="GetWindowLong")]

.

private static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);

.

[DllImport("user32.dll", EntryPoint="GetWindowLongPtr")]

.

private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);

.

// GetWindowLongPtr directly

.

public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)

.

     return GetWindowLongPtr64(hWnd, nIndex);

.

     return GetWindowLongPtr32(hWnd, nIndex);

.

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _

.

Private Shared Function GetWindowLongPtr32(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr

.

<DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _

.

Private Shared Function GetWindowLongPtr64(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr

.

' This static method is required because Win32 does not support GetWindowLongPtr dirctly

.

Public Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr

.

      Return GetWindowLongPtr64(hWnd, nIndex)

.

      Return GetWindowLongPtr32(hWnd, nIndex)

.

     result = GetWindowLongPtr(winhandle, GWL.GWL_ID);

.
Documentation
[GetWindowLongPtr] on MSDN
.
Summary
.

On this platform this function is in fact a macro that calls GetWindowLong, so the EntryPoint property has to be set to the real function:

.

[DllImport("user32.dll", EntryPoint="GetWindowLong")]

.

static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);

.

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _

.

Private Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, <MarshalAs(UnmanagedType.I4)>nIndex As GWL) As IntPtr

.

Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" _

.

[DllImport("user32.dll", EntryPoint="GetWindowLongPtr")]

.

private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);

.

<DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _

.

Private Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, <MarshalAs(UnmanagedType.I4)>nIndex As GWL) As IntPtr

.

Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" _

.

[DllImport("user32.dll", EntryPoint="GetWindowLong")]

.

private static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);

.

[DllImport("user32.dll", EntryPoint="GetWindowLongPtr")]

.

private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);

.

// GetWindowLongPtr directly

.

public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex)

.

     return GetWindowLongPtr64(hWnd, nIndex);

.

     return GetWindowLongPtr32(hWnd, nIndex);

.

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _

.

Private Shared Function GetWindowLongPtr32(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr

.

<DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _

.

Private Shared Function GetWindowLongPtr64(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr

.

' This static method is required because Win32 does not support GetWindowLongPtr dirctly

.

Public Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr

.

      Return GetWindowLongPtr64(hWnd, nIndex)

.

      Return GetWindowLongPtr32(hWnd, nIndex)

.

     result = GetWindowLongPtr(winhandle, GWL.GWL_ID);

.
Documentation
[GetWindowLongPtr] on MSDN
.
Summary
.

static extern uint GetWindowModuleFileName(IntPtr hwnd,

.

  Private Shared Function GetWindowModuleFileName(hwnd As IntPtr, _

.
Workaround
Use GetWindowThreadProcessId to get the process ID, then Process.GetProcessById to retrieve the process information. The resultant System.Diagnostics.Process Object's MainModule Property has the Filename Property, which is the Information you are probably searching.
.

GetWindowModuleFileName(hwnd, fileName, 2000);

.
Documentation
[GetWindowModuleFileName] on MSDN
.
Summary
.

public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);

.

Private Shared Function GetWindowPlacement(ByVal hWnd As IntPtr, ByRef lpwndpl As WINDOWPLACEMENT) As Boolean

.

Public Declare Function GetWindowPlacement Lib "user32" _

.

        GetWindowPlacement(this.Handle, ref placement);

.

    Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As IntPtr, ByRef lpwndpl As WINDOWPLACEMENT) As Integer

.

        intRet = GetWindowPlacement(Me.Handle.ToInt32, wpTemp)

.
Documentation
[GetWindowPlacement] on MSDN
.
Summary
GetWindowPos is an old Win32 method, you should use GetWindowRect or GetWindowPlacement
.

static extern TODO GetWindowPos(TODO);

.

Declare Function GetWindowPos Lib "user32.dll" (TODO) As TODO

.

Use GetWindowRect Win32 method for position information.

.

Use GetWindowPlacement Win32 method for a more detailed set of info such as Z-Order.

.
Documentation
[GetWindowPos] on MSDN
.
Summary
.

static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);

.

Private Shared Function GetWindowRect(ByVal hWnd As HandleRef, ByRef lpRect As RECT) As Boolean

.

Please note that this does NOT work properly with Windows Vista Aero (this includes Windows 10), and reports faulty values. This is largely due to Aero incorporating additional invisible borders which are used to "resize" the window using the cursor. In this instance, the developer should look into using DwmGetWindowAttribute (dwmapi.dll) with DWMWA_EXTENDED_FRAME_BOUNDS.

.

static extern bool GetWindowRect(HandleRef hWnd, out RECT lpRect);

.

     if(!GetWindowRect(new HandleRef(this, this.Handle), out rct ))

.
Documentation
[GetWindowRect] on MSDN
.
Summary
.

static extern int GetWindowRgn(IntPtr hWnd, IntPtr hRgn);

.

Private Shared Function GetWindowRgn(ByVal hWnd As IntPtr, ByVal hRgn As IntPtr) As Integer

.
Documentation
[GetWindowRgn] on MSDN
.
Summary
.

///     GetWindowTextLength cannot retrieve the length of the text of an edit control in another application.

.

///     If the target window is owned by the current process, <see cref="GetWindowTextLength" /> causes a

.

///     <see cref="GetWindowTextLength" /> function may return a value that is larger than the actual length of the

.

///     occur when an application uses the ANSI version of <see cref="GetWindowTextLength" /> with a window whose window

.

///     procedure is Unicode, or the Unicode version of <see cref="GetWindowTextLength" /> with a window whose window

.

///     GetWindowText function.

.

static extern int GetWindowTextLength(IntPtr hWnd);

.

Private Shared Function GetWindowTextLength(ByVal hwnd As IntPtr) As Integer

.

class method GetWindowTextLength(hWnd: IntPtr): Int32; external;

.

Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" _

.

Often used with GetWindowText

.

(See GetWindowText.)

.
Documentation
[GetWindowTextLength] on MSDN
.
Summary
Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application, If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control.
.
Remarks
If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. This behavior is by design. It allows applications to call GetWindowText without becoming unresponsive if the process that owns the target window is not responding. However, if the target window is not responding and it belongs to the calling application, GetWindowText will cause the calling application to become unresponsive. .

To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.

.

///     control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another

.

///     If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the

.

///     specified window or control. If the target window is owned by another process and has a caption, GetWindowText

.

///     behavior is by design. It allows applications to call GetWindowText without becoming unresponsive if the process

.

///     the calling application, GetWindowText will cause the calling application to become unresponsive. To retrieve the

.

///     text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.<br />For

.

static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

.

<DllImport("user32.dll", EntryPoint:="GetWindowText")>

.

Public Function GetWindowText(ByVal hwnd As Integer, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer

.

extern IntPtr GetWindowText(IntPtr hwnd, StringBuilder lpString, int maxCount)

.

class method GetWindowText(hWnd: IntPtr; lpString: StringBuilder; nMaxCount: Int32): Int32; external;

.

Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _

.

See also GetWindowTextLength

.

    int length       = GetWindowTextLength(hWnd);

.

    GetWindowText(hWnd, sb, sb.Capacity);

.

But, if you need to get text from a control in another process, GetWindowText() won't work. Use WM_GETTEXT instead.

.

public static string GetWindowTextRaw(IntPtr hwnd)

.

    length = GetWindowTextLength(hWnd)

.

    GetWindowText(hWnd, sb, sb.Capacity + 1)

.
Documentation
[GetWindowText] on MSDN
.
Summary
.

static extern int GetWindowTextLength(IntPtr hWnd);

.

Private Shared Function GetWindowTextLength(ByVal hwnd As IntPtr) As Integer

.

Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" _

.

Often used with GetWindowText

.

(See GetWindowText.)

.
Documentation
[GetWindowTextLength] on MSDN
.
Summary
.

static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

.

static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);

.

Private Shared Function GetWindowThreadProcessId(ByVal hwnd As IntPtr, _

.

    ''' <param name="lpdwProcessId">A pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not. </param>

.

    Private Declare Auto Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, _

.

  GetWindowThreadProcessId(lngAccessHwnd, lngPid)

.

    Public Declare Auto Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As IntPtr, ByRef lpdwProcessId As IntPtr) As IntPtr

.

        GetWindowThreadProcessId(hOwner, iProcessID)

.

IntPtr pID = GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero);

.

GetWindowThreadProcessId returns the id of the thread that created the target window. To get the process id of a window, use the first c# signature above, and:

.

int threadID = GetWindowThreadProcessId(hWnd, out processID);

.
Documentation
[GetWindowThreadProcessId] on MSD
.

GetWindowRect(hWnd, out rct);

.

    internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);

.

        GetWindowRect(id, ref Rect);