请问如何捕捉关机信息,我上次在网吧用API写一个关机的东东,那个网吧管理软件不让我关机,弹出警告框如何作到的?

解决方案 »

  1.   

    he WM_QUERYENDSESSION message is sent when the user chooses to end the Windows session or when an application calls the ExitWindows function. If any application returns zero, the Windows session is not ended. Windows stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. After processing this message, Windows sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message. WM_QUERYENDSESSION  
    nSource = (UINT) wParam;    // source of end-session request 
    fLogOff = lParam            // logoff flag 
     ParametersnSourceReserved for future use. fLogOffValue of lParam. Indicates whether the user is logging off or shutting down the system. Supported values include: ENDSESSION_LOGOFF. Return ValuesIf an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE. ResBy default, the DefWindowProc function returns TRUE for this message. 
    Windows NT: 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. 
    Windows 95: After all applications return TRUE for this message, they receive the WM_ENDSESSION and they are terminated. See AlsoDefWindowProc, ExitWindows, WM_ENDSESSION
      

  2.   

    二楼说的这个WM_QUERYENDSESSION仅仅是本程序退出时,可以用来捕捉的,并不表示Windows其它的东东不懂
      

  3.   

    哈哈高手来了 
    看着吧 眼睛瞪大点 以下是一个简单的阻止关机的程序 适用9X
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
       //下面是最重要的一句 映射关机消息到一个过程
        procedure windowsclose(var msg:tmessage);message wm_queryendsession;
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure tform1.windowsclose(var msg:tmessage);
    begin
    msg.result:=1;//不记得是1还是0自己试
    end;
    end.
      

  4.   

    如果我想关机的时候弹出一个警告框那要怎么做?
    没学多久DELPHI有很多地方不懂,还请大家多多指教
      

  5.   

    procedure tform1.windowsclose(var msg:tmessage);
    begin
    if messagebox(handle,pchar('真的要关么?'),pchar('提示'),MB_OKCANCEL or MB_ICONQUESTION)=1 then msg.result:=1
    else msg.result:=0;
    end;