C++ (Qt)typedef void (*TYPEPROC)(char *); class myApp :public QCoreApplication{public: myApp(int &argc, char**argv) :QCoreApplication(argc, argv) {}; bool winEventFilter(MSG *message, long *result) { if (message->message == WM_SYSCOMMAND){ if (message->wParam == 1037){ quit(); return true; } } }; }; int main(int argc, char *argv[]){ myApp app(argc, argv); TYPEPROC proc = 0; HMODULE hDLL=NULL; hDLL = LoadLibrary (L"liba.dll"); if (!hDLL) return 0; proc = (TYPEPROC) GetProcAddress(hDLL,"proc"); if (!proc){ std::cout << "Error load function!"; } proc("go"); return app.exec(); }
C++ (Qt)class myApp :public QApplication{public: myApp(int &argc, char**argv) :QApplication(argc, argv) {}; bool winEventFilter(MSG *message, long *result) { if (message->message == WM_SYSCOMMAND){ if (message->wParam == 1037){ doIt(); return true; } } };int main(int argc, char *argv[]){ myApp a(argc, argv); ...}
C++ (Qt)QAbstractEventDispatcher* m_EventDispatcher; bool EventFilter(void* message){ MSG *msg; msg = (MSG*)message; if (msg->message == WM_SYSCOMMAND){ if (msg->wParam == 1037){ doIt(); return true; } }int main(int argc, char *argv[]){ QApplication a(argc, argv); m_EventDispatcher = QAbstractEventDispatcher::instance(); a.installEventFilter(m_EventDispatcher);// QCoreApplication::instance()->installEventFilter(m_EventDispatcher); m_EventDispatcher->setEventFilter((QAbstractEventDispatcher::EventFilter)EventFilter); ...}}