【代码】
#include <Windows.h>
#include <CommCtrl.h>
#pragma comment(lib, "Comctl32.lib")
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#define TITLE L"Hello"
void alert(LPWSTR message)
{
MessageBox(NULL, message, TITLE, MB_ICONWARNING);
}
BOOL confirm(LPWSTR message)
{
return (MessageBox(NULL, message, TITLE, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
if (confirm(L"Are you sure you want to say hello?"))
alert(L"Hello World!");
else
alert(L"You are not welcome.");
return 0;
}
【运行结果】