这不就是教程?
https://blog.csdn.net/yuyan987/article/details/78558648
加<windows.h>头文件试试,这段代码在我的电脑上运行是通过的
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
if(MessageBox(NULL,"sth","tital",MB_YESNO)==IDYES) cout<<1;
return 0;
}