调用win32 api 函数SendMessage() 实现消息直接调用

时间:2021-07-14 12:10:39

简单的调用例子, 适合初学者学习,当然 我也是初学者.

 #include <windows.h>
#include <stdio.h>
#include <stdlib.h> #define dim(x) (sizeof()/sizeof(x[0])) int main()
{
system("color 5b");
/* system("mode con cols=60 lines=8");*/
system("title Kill Window");
char sName[] = {};
HWND hWnd = ; puts("====--------------====");
puts("==== QQ 702368956 ====");
puts("====--------------====");
while ()
{
printf("Help You Kill it: ");
gets(sName);
hWnd = FindWindow(NULL, sName);
if (hWnd)
{
SendMessage(hWnd, WM_CLOSE, , );
break;
}
else
{
printf(" 没有找到窗口...\n\n");
continue;
}
}
return ;
}