有谁知道wm_QueryEndSession的wParam及lParam参数(50分)

  • 主题发起人 主题发起人 vine3
  • 开始时间 开始时间
V

vine3

Unregistered / Unconfirmed
GUEST, unregistred user!
如题<br><br>当系统要关机时,会发一个消息:wm_QueryEndSession<br><br>但这个消息对关机重起都一样的<br><br>现在不知道怎么分清这两种情况<br><br>据知如果是关机时在其中一个参数为logoff的呵、<br><br>不知道是不是这样的呵<br><br>望高手指点
 
我在 Win 2000 上测试过,WM_QUERYENDSESSION.lParam :<br>&nbsp; 注销:-2147483648<br>&nbsp; 关机:0<br>&nbsp; 重启:0<br>确实没办法分辨
 
在98下面呢!<br><br>应该象可以分辩的吧
 
我没有98的环境,你可以用下面的代码测试一下:<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; private<br>&nbsp; &nbsp; procedure WMQUERYENDSESSION(var msg:Tmessage);message WM_QUERYENDSESSION;<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>procedure tform1.WMQUERYENDSESSION(var msg:Tmessage);<br>begin<br>&nbsp; &nbsp; showmessage(inttostr(msg.lparamlo)+chr(13)+chr(10)+inttostr(msg.lparamhi));<br>&nbsp; &nbsp; msg.Result :=0;<br>end;<br>
 
此消息只可以判断是否LOGOFF却无法判断是RESTART还是SHUTDOWN<br>判断是否是LOGOFF可以通过对 LPARAM AND $80000000后是否为0来知道<br>为0表示SHUTDOWN 或者RESTART,否则为LOGOFF<br>&nbsp;
 
那有没有什么其它方法来分辨这两码事种情况?
 
我是无法的,除非自己替换掉USER32.DLL,截获EXITWINDOWS,EXITWINDOWSX
 
记得以前有个光驱帮助软件<br>是这样的:<br>&nbsp; 当关机时,如果光驱里面还有光盘时,它会自动把光驱先弹出来,然后再关机的<br>&nbsp;不过如果不是关机,而是重启,它就没有什么动作的呵!<br>这就是说它可以区分这两种情况的呵!<br>声明一下它只有一个 &nbsp;EXE 文件。<br>这个软件嘛象叫什么 autoeject的,不是十分清楚了
 
关注[:D]<br>
 
我有一个简单的问题<br>&nbsp; &nbsp;'WM_MOUSEWHEEL <br>fwKeys = LOWORD(wParam); // key flags <br>zDelta = (short) HIWORD(wParam); // wheel rotation <br>xPos = (short) LOWORD(lParam); // horizontal position of pointer <br>yPos = (short) HIWORD(lParam); // vertical position of pointer <br>&nbsp;<br>zDelta <br>The value of the high-order word of wParam. Indicates the distance that <br>the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, <br>which is 120. A positive value indicates that the wheel was rotated <br>forward, away from the user; a negative value indicates that the wheel <br>was rotated backward, toward the user<br>可你在messages.pas中明明可以看到<br>WM_MOUSEWHEEL &nbsp; &nbsp; &nbsp; = $020A;<br>&nbsp; {$EXTERNALSYM WM_MOUSELAST}<br>是常量,zDelta := HIWORD(wParam);怎么可能有正有负表示向前向后<br>滚轮确能消息能捕到,我试过,但如何判断先前滚向后滚<br>我要捕另外一个程序的滚轮消息,所以不能用OnMouseWheelUp<br>我用的是钩子dll,到底怎么才行
 
你说的不错,请仔细阅读以下内容,相信对你有所帮助.<br>以下来自Platform SDK<br>WM_QUERYENDSESSION<br>The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls the ExitWindows function. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. <br><br>After processing this message, the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message. <br><br>A window receives this message through its WindowProc function. <br><br>LRESULT CALLBACK WindowProc(<br>&nbsp; HWND hwnd, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// handle to window<br>&nbsp; WM_QUERYENDSESSION, // the message to send<br>&nbsp; WPARAM wParam, &nbsp; &nbsp; &nbsp;// not used<br>&nbsp; LPARAM lParam &nbsp; &nbsp; &nbsp; // logoff option<br>);<br>Parameters<br>wParam <br>This parameter is reserved for future use. <br>lParam <br>Specifies whether the user is logging off or shutting down the system. If this parameter includes the ENDSESSION_LOGOFF value, the user if logging off. (Note that this parameter is a bit mask. To test for this value, use a bit-wise operation; do not test for equality.) <br>Windows 2000/XP: If this parameter is zero, the system is shutting down. <br><br>Return Values<br>If an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE. <br><br>Remarks<br>By default, the DefWindowProc function returns TRUE for this message. <br><br>Windows NT/2000/XP: When an application returns TRUE for this message, it receives the WM_ENDSESSION message and it is terminated, regardless of how the other applications respond to the WM_QUERYENDSESSION message. <br><br>Windows 95/98/Me: After all applications return TRUE for this message, they receive the WM_ENDSESSION and they are terminated. <br><br>Requirements <br>&nbsp; Windows NT/2000/XP: Included in Windows NT 3.1 and later.<br>&nbsp; Windows 95/98/Me: Included in Windows 95 and later.<br>&nbsp; Header: Declared in Winuser.h; include Windows.h.<br><br>
 
后退
顶部