User32GetClassName(IntPtr, StringBuilder, Int32) Method

Retrieves the name of the class to which the specified window belongs.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static int GetClassName(
	IntPtr hWnd,
	StringBuilder className,
	int maxCount
)

Parameters

hWnd  IntPtr
A handle to the window and, indirectly, the class to which the window belongs.
className  StringBuilder
The class name string.
maxCount  Int32
The length of the className buffer, in characters.

The buffer must be large enough to include the terminating null character; otherwise, the class name string is truncated to maxCount-1 characters.

Return Value

Int32
If the function succeeds, the return value is the number of characters copied to the buffer, not including the terminating null character.

If the function fails, the return value is 0.

To get extended error information, call GetLastWin32Error.

Remarks

See Also