我看了一下lcl的实现,窗口类名是硬编码的常量:
lazarus\lcl\interfaces\win32\win32int.pp
const
BOOL_RESULT: array[Boolean] of String = ('False', 'True'); ClsName: array[0..6] of char = 'Window'#0;
ClsHintName: array[0..10] of char = 'HintWindow'#0;
EditClsName: array[0..4] of char = 'Edit'#0;
ButtonClsName: array[0..6] of char = 'Button'#0;
ComboboxClsName: array[0..8] of char = 'ComboBox'#0;
ListboxClsName: array[0..8] of char = 'LISTBOX'#0;
TabControlClsName: array[0..15] of char = 'SysTabControl32'#0;
ListViewClsName: array[0..13] of char = 'SysListView32'#0;
LCLComboboxClsName: array[0..11] of char = 'LCLComboBox'#0;
LCLListboxClsName: array[0..10] of char = 'LCLListBox'#0;
LCLCheckListboxClsName: array[0..15] of char = 'LCLCheckListBox'#0;
ClsNameW: array[0..6] of WideChar = ('W', 'i', 'n', 'd', 'o', 'w', #0);
ClsHintNameW: array[0..10] of WideChar = ('H', 'i', 'n', 't', 'W', 'i', 'n', 'd', 'o', 'w', #0);
然后在窗体建立handle的时候直接使用了指向类名的指针:
lazarus\lcl\interfaces\win32\win32wsforms.pp
class function TWin32WSCustomForm.CreateHandle(const AWinControl: TWinControl;
begin
//... pClassName := @ClsName[0];
//...
end;