public static GetClassName ( |
||
windowHandle | A handle to the window and, indirectly, the class to which the window belongs. | |
Résultat | string |
public static string GetClassName(IntPtr windowHandle)
{
// Check if the handle is valid
HandleManipulator.ValidateAsArgument(windowHandle, "windowHandle");
// Get the window class name
var stringBuilder = new StringBuilder(char.MaxValue);
if (NativeMethods.GetClassName(windowHandle, stringBuilder, stringBuilder.Capacity) == 0)
throw new Win32Exception("Couldn't get the class name of the window or the window has no class name.");
return stringBuilder.ToString();
}
/// <summary> /// Gets all the windows that have the specified class name. /// </summary> /// <param name="className">The class name string.</param> /// <returns>A collection of <see cref="RemoteWindow"/>.</returns> public IEnumerable <RemoteWindow> GetWindowsByClassName(string className) { return(WindowHandles .Where(handle => WindowCore.GetClassName(handle) == className) .Select(handle => new RemoteWindow(_memorySharp, handle))); }