ARTICLE AD BOX
I'm using the koffi library to call Win32 APIs from TypeScript. However, I'm stuck at the very first step: FindWindowW consistently returns 0 (NULL), indicating that the Progman window cannot be found. Here are some part of the code:
const FindWindowW = user32.func("int FindWindowW(str lpClassNmae, str lpWindowName)"); export function attachToWallpaper(targetHwnd: number | bigint) { // 步骤 1: 找到桌面顶层管理器 Progman const progman = FindWindowW('Progman', "Program Manager"); console.log('Progman:', progman); if (progman === 0) { console.error('X Couldn\'t find Progman window'); return false; } // 步骤 2: 发送 0x052C 消息 const resultPtr = koffi.alloc('int', koffi.sizeof('int')); SendMessageTimeoutW(progman, WM_SPAWN_WORKERW, 0, 0, SMTO_NORMAL, 1000, resultPtr); koffi.free(resultPtr); }