#include <windows.h> #include <iostream> using namespace std; int main() { //HWND hWnd = ::FindWindow("Notepad",NULL); HWND hWnd = ::FindWindow(NULL,"a.txt - 记事本"); if(hWnd != NULL) { ::SendMessage(hWnd,WM_CLOSE,0,0); } char a; cin>>a; return 0; }
2021-08-29 03:46:08
#include <windows.h> #include <iostream> using namespace std; int main() { //HWND hWnd = ::FindWindow("Notepad",NULL); HWND hWnd = ::FindWindow(NULL,"a.txt - 记事本"); if(hWnd != NULL) { ::SendMessage(hWnd,WM_CLOSE,0,0); } char a; cin>>a; return 0; }