也不能注销,不能重起计算机了?/
这个问题如何解决!!!
请高手发标!!

解决方案 »

  1.   

    在 private部分加上
    procedure WMQueryEndSession(var Msg:TMessage);
                message WM_QueryEndSession; 在实现部分加上下列过程procedure TForm1.WMQueryEndSession(var Msg:TMessage);begin form1.Close;Msg.Result:=1;end;
      

  2.   

    是delphi那个控件一个错误,得改一句,你找找吧,我原来看过的忘了
      

  3.   

    老兄,你用的是win2000吧,在win98下应该没问题,你可在FORM的关闭事件中再调用一次关机函数不就得了,要注意在win2000下调用系统关机函数要取得系统特权,方才可行。
      

  4.   

    我能取得系统权限,但是不知道如何调用关机函数,楼上的老兄,我使用的就是2000操作系统。麻烦你帮帮忙吧,这个问题捆饶了我N久了。我希望和你QQ联系,你要多少分都可以··。我可用分很多。
    还有,请把你的邮箱地址留下来好不好。。谢谢了
    我的QQ是:9421662
      

  5.   

    并且程序运行过程中,不但关机、重启、注销等都不能正常使用!!
    如果用hzl88688(hzl88688) 老兄提到的方法,程序是能关闭,但是以上关机、重启、等不能正常。
    也就是说,需要关闭两次计算机才能关闭!
    如何解决这个BUG。这是NMStrmServ1控件的BUG。但是我听说有人解决过这个问题。不知道在2000下是如何解决的?
    还想知道是不是在DELPHI 7中能解决这个问题··
      

  6.   

    to  sforever(人在江湖飘,谁能不挨刀.) :
     我现在给你贴一段代码,别忘了给我加分,另.unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Psock, NMSTRM;type
      TForm1 = class(TForm)
        NMStrmServ1: TNMStrmServ;
        private
        { Private declarations }
      procedure WMQueryEndSession(var Msg:TMessage);
                message WM_QueryEndSession;   procedure ShutDown;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}
      procedure TForm1.WMQueryEndSession(var Msg:TMessage);begin Msg.Result:=1;
      form1.Close;
      shutdown;
     end;function GetWinVersion: String;
      var
         VersionInfo : TOSVersionInfo;
         OSName      : String;
      begin
         // set the size of the record
         VersionInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo );     if Windows.GetVersionEx( VersionInfo ) then
            begin
               with VersionInfo do
               begin
                  case dwPlatformId of
                     VER_PLATFORM_WIN32s   : OSName := 'Win32s';
                     VER_PLATFORM_WIN32_WINDOWS : OSName := 'Windows 95';
                     VER_PLATFORM_WIN32_NT      : OSName := 'Windows NT';
                  end; // case dwPlatformId
                  Result := OSName + ' Version ' + IntToStr( dwMajorVersion ) + '.' + IntToStr( dwMinorVersion ) +
                            #13#10' (Build ' + IntToStr( dwBuildNumber ) + ': ' + szCSDVersion + ')';
               end; // with VersionInfo
            end // if GetVersionEx
         else
            Result := '';
      end;  procedure tform1.ShutDown;
      const
        SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';   // Borland forgot this declaration
      var
        hToken       : THandle;
        tkp          : TTokenPrivileges;
        tkpo         : TTokenPrivileges;
        zero         : DWORD;
      begin
        if Pos( 'Windows NT', GetWinVersion) = 1  then // we've got to do a whole buch of things
           begin
              zero := 0;
              if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
                 begin
                   MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );
                   Exit;
                 end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)
              if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
                 begin
                   MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );
                   Exit;
                 end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)
              // SE_SHUTDOWN_NAME
              if not LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[ 0 ].Luid ) then
                 begin
                    MessageBox( 0, 'Exit Error', 'LookupPrivilegeValue() Failed', MB_OK );
                    Exit;
                 end; // if not LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[0].Luid )
              tkp.PrivilegeCount := 1;
              tkp.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;          AdjustTokenPrivileges( hToken, False, tkp, SizeOf( TTokenPrivileges ), tkpo, zero );
              if Boolean( GetLastError() ) then
                 begin
                    MessageBox( 0, 'Exit Error', 'AdjustTokenPrivileges() Failed', MB_OK );
                    Exit;
                 end // if Boolean( GetLastError() )
              else
                 ExitWindowsEx( EWX_FORCE or EWX_SHUTDOWN, 0 );
            end // if OSVersion = 'Windows NT'
         else
            begin // just shut the machine down
              ExitWindowsEx( EWX_FORCE or EWX_SHUTDOWN, 0 );
            end; // else
      end;end.