WinAPI: GetClassName - 获取指定窗口的类名
WinAPI: GetClassName - 获取指定窗口的类名 //声明: GetClassName( hWnd: HWND; {指定窗口句柄} lpClassName: PChar; {缓冲区} nMaxCount: Integer {缓冲区大小} ): Integer; {返回类名大小; 失败返回 0} -------------------------------------------------------------------------------- //测试1: 新建一个工程, 主窗口的类名默认是 TForm1, 用程序获取一下看看 var ps: array[0..254] of Char; begin GetClassName(Handle, ps, 255); ShowMessage(ps); {TForm1} end; -------------------------------------------------------------------------------- //测试2: 看看 "计算器" 窗口的类名(先启动计算器) var h: HWND; ps: array[0..254] of Char; begin h := FindWindow(nil, '计算器'); {这句是获取计算器窗口的句柄} GetClassName(h, ps, 255); ShowMessage(ps); {SciCalc} end; -------------------------------------------------------------------------------- //测试3: 看看记事本窗口的类名(先重新启动记事本): var h: HWND; ps: array[0..254] of Char; begin h := FindWindow(nil, '无标题 - 记事本'); {这句是获取记事本窗口的句柄} GetClassName(h, ps, 255); ShowMessage(ps); {Notepad} end;