禁止关机
1.先打开头文件作如下修改:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
class TForm1 : public TForm { __published: // IDE-managed Components private: // User declarations void __fastcall WMQueryEndSession(TWMQueryEndSession &msg); public: // User declarations __fastcall TForm1(TComponent* Owner); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_QUERYENDSESSION,TWMQueryEndSession,WMQueryEndSession) END_MESSAGE_MAP(TForm) }; extern PACKAGE TForm1 *Form1; |
2.然后对unit.cpp文件添加如下代码:
1 2 3 4 5 |
void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession &msg) { msg.Result = 0; ShowMessage("你不能关闭系统"); } |