最近在折腾系统关机的时候,通过ofw程序给单片机发送一条指令(serial.writeBytes(bytesHexToWater,10);)第一尝试如下, 不被响应:
if (SetConsoleCtrlHandler(PHANDLER_ROUTINE(CTRL_SHUTDOWN_EVENT),true))
{
serial.writeBytes(bytesHexToWater,10);
}
第二尝试如下:
LRESULT CALLBACK WindowProc(UINT message, WPARAM wParam, LPARAM lParam){
// TODO: Add your specialized code here and/or call the base class
testApp getAppClass;
if ( message == WM_QUERYENDSESSION ) //Windows关机消息
{
getAppClass.serial.writeBytes(getAppClass.bytesHexToWater,10);
cout<<"just comeHere everytimes"<<endl;
return false;
}
//return WindowProc(message, wParam, lParam);
cout<<"just comeHere everytimes"<<endl;
}
ofw程序直接走不到这片代码之中,至于自带的exit(),exitApp()均没有使用成功。。。鉴于某初学无术,百思不得解,特发此贴,敬请各位高人走过路过顺便看看,不吝赐教,指点一二,小生感激不尽!