项目是从Delphi迁移过来,Delphi上正常运行,但Lazarus就是跑不起来,将第二个参数设为nil即可正常,经分析是编码的问题,中文名称无法正常获取。
查询资料:
[ Lazarus における Windows API の関数の日本語文字列 ] - Mr.XRAY
https://www.cnblogs.com/delphi-xe5/articles/4472030.html
LazarusでFindWindowが常に0を返してしまう件について - Delphi・Lazarus
解决方案 :
Lazarus FindWindow do not work when Window Name Contain non-English string - Stack Overflow
即:Try inserting {$codepage utf8} on top of your unit without any casts (i.e. FindWindowW(nil, '你好,世界');). Read string literals in this topic.