GetClassName Function

Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Platforms

Description & Usage

GetClassName retrieves the name of the window class to which a window belongs. The name of the class is placed into the string passed as lpClassName.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns the number of characters copied into the string passed as lpClassName.

Visual Basic-Specific Issues

None.

Parameters

hWnd
A handle to the window to get the name of the window class of.
lpClassName
A string which receives the name of the window class. This must first be initialized to a sufficient length to receive the string.
nMaxCount
The size in bytes of the string passed as lpClassName.

Example

' This code is licensed according to the terms and conditions listed here.

' Display the name of the window class to which window Form1 belongs.
Dim classname As String  ' receives the name of the class
Dim slength As Long  ' length of the string retrieved

' Make room in the string to receive the information.
classname = Space(255)  ' much more than enough room
' Get the name of the window class.
slength = GetClassName(Form1.hWnd, classname, 255)
' Extract the useful information from the string and display it.
classname = Left(classname, slength)  ' remove empty space
Debug.Print "Form1's window class is: "; classname

Category

Window Classes

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: August 21, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getclassname.html