

”’ OUTPUT – The process ID will be copied to this Integer, but only if the Integer passed in is not 0 ”’ A handle to the window to get the thread and process ID for ”’ Gets the thread and process ID that created a window Public Shared Function GetWindowTextLength( ByVal hWnd As System.IntPtr) As Integer ”’ A handle to the window to get the text length from ”’ Gets the number of characters present in a window’s title bar text Public Shared Function GetWindowText( ByVal hWnd As System.IntPtr, ByVal lpString As, ByVal nMaxCount As Integer) As Integer ”’ The maximimum number of characters to get from the window title and copy to the object in the lpString parameter ”’ OUTPUT – the window text will be copied to this object ”’ A handle to the window to get the text from ”’ Gets the title bar text from the specified window Public Shared Function IsWindowVisible( ByVal hWnd As System.IntPtr) As Boolean ”’ A handle to the window to check the visibility of Public Shared Function EnumWindows( ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As IntPtr) As Boolean ”’ Enumerates all top level windows and calls the specified callback once for each window found Public Delegate Function EnumWindowsProc( ByVal hwnd As System.IntPtr, ByVal lparam As System.IntPtr) As Boolean ”’ Used by the EnumWindows API to specify a callback function that should be called once for each window found Note that you will get a few windows that you would not see in the Applications tab of Task Manager, such as the window that works with the system tray and on windows 7 the start button, so if you do not want to display those in your application then you will have to manually filter them out of the list returned by my method below (or modify my method obviously).ĪPI DEFINITIONS (define in a class named NativeAPI and Import ): Check back on this blog soon if that sounds like something you would be interested in.Īnyway, here are the API definitions for this particular wrapper, which as explained above, will return a list of all top level windows that are currently visible. NET methods, with no need to marshal anything across to unmanaged code. So you can just add a reference to the class library DLL and then you can avoid having to use the APIs directly as you can just use my nice simple.

This time my code makes use of about 6 different Windows APIs to provide you with a method that will return a list of all windows that are currently open on the computer along with their handle, title bar text, class name and the process that owns the window.Īlso might be worth mentioning: I’m going to be releasing a class library soon full of lots of these “.NET friendly” methods that I’ve written to make calling specific Windows APIs simpler and easier. NET wrapper/helper that I’ve written for some Windows API functionality.
