#include <windows.h>

int main(int argc, char* argv[])

{

HWND hwnd = FindWindow(NULL,"无标题 记事本");

if (hwnd != NULL)

{

SendMessage(hwnd,WM_CLOSE,0,0);

printf("程序已经关闭!\n");

}else{

printf("未发现要关闭的应用程序!\n");

}

return 0;

}

 

 

 

#include <windows.h>

#include <stdio.h>

//#include <winbase.h>

BOOL TernimateProcessById(DWORD dwProcessId){

BOOL bRet=FALSE;

HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwProcessId);

if (hProcess != NULL)

{

bRet = TerminateProcess(hProcess,0);

}

CloseHandle(hProcess);

return bRet;

}

int main(int argc , char *argv[]){

BOOL bRet = TernimateProcessById(3092);

if (!bRet)

{

printf("关闭进程出错\n");

}else{

printf("关闭进程成功\n");

}

return 0;

}

相关文章:

  • 2021-06-22
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-12-11
  • 2021-05-31
  • 2021-08-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案