判断MS SQL Server是否启动
点击次数:50 次 发布日期:2008-11-09 08:38:20 作者:源代码网
|
源代码网推荐 object Form1: TForm1 源代码网推荐 Left = 192 源代码网推荐 Top = 107 源代码网推荐 Width = 442 源代码网推荐 Height = 246 源代码网推荐 Caption = "Form1" 源代码网推荐 Color = clBtnFace 源代码网推荐 Font.Charset = DEFAULT_CHARSET 源代码网推荐 Font.Color = clWindowText 源代码网推荐 Font.Height = -11 源代码网推荐 Font.Name = "MS Sans Serif" 源代码网推荐 Font.Style = [] 源代码网推荐 OldCreateOrder = False 源代码网推荐 PixelsPerInch = 96 源代码网推荐 TextHeight = 13 源代码网推荐 object Label1: TLabel 源代码网推荐 Left = 216 源代码网推荐 Top = 40 源代码网推荐 Width = 32 源代码网推荐 Height = 13 源代码网推荐 Caption = "Label1" 源代码网推荐 end 源代码网推荐 object Button1: TButton 源代码网推荐 Left = 32 源代码网推荐 Top = 16 源代码网推荐 Width = 75 源代码网推荐 Height = 25 源代码网推荐 Caption = "Button1" 源代码网推荐 TabOrder = 0 源代码网推荐 OnClick = Button1Click 源代码网推荐 end 源代码网推荐 object Button2: TButton 源代码网推荐 Left = 48 源代码网推荐 Top = 104 源代码网推荐 Width = 75 源代码网推荐 Height = 25 源代码网推荐 Caption = "Button2" 源代码网推荐 TabOrder = 1 源代码网推荐 OnClick = Button2Click 源代码网推荐 end 源代码网推荐 object cs: TClientSocket 源代码网推荐 Active = False 源代码网推荐 Address = "202.99.0.172" 源代码网推荐 ClientType = ctNonBlocking 源代码网推荐 Port = 1433 源代码网推荐 Left = 32 源代码网推荐 Top = 48 源代码网推荐 end 源代码网推荐 object Timer1: TTimer 源代码网推荐 Interval = 5000 源代码网推荐 OnTimer = Timer1Timer 源代码网推荐 Left = 80 源代码网推荐 Top = 48 源代码网推荐 end 源代码网推荐 end 源代码网推荐 源代码网推荐 源代码网推荐 ////////////代码 源代码网推荐 unit Unit1; 源代码网推荐 源代码网推荐 interface 源代码网推荐 源代码网推荐 uses 源代码网推荐 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 源代码网推荐 StdCtrls, ScktComp, ExtCtrls; 源代码网推荐 源代码网推荐 const 源代码网推荐 SERVICE_STOPPED=1; // Stopped 源代码网推荐 SERVICE_START_PENDING=2; // Starting 源代码网推荐 SERVICE_STOP_PENDING=3; // Stopping 源代码网推荐 SERVICE_RUNNING=4; // Running 源代码网推荐 SERVICE_CONTINUE_PENDING=5; // Restarting after being paused 源代码网推荐 SERVICE_PAUSE_PENDING=6; // Pausing 源代码网推荐 SERVICE_PAUSED=7; //Paused 源代码网推荐 源代码网推荐 type 源代码网推荐 TForm1 = class(TForm) 源代码网推荐 cs: TClientSocket; 源代码网推荐 Button1: TButton; 源代码网推荐 Timer1: TTimer; 源代码网推荐 Label1: TLabel; 源代码网推荐 Button2: TButton; 源代码网推荐 procedure Button1Click(Sender: TObject); 源代码网推荐 procedure Timer1Timer(Sender: TObject); 源代码网推荐 procedure Button2Click(Sender: TObject); 源代码网推荐 private 源代码网推荐 { Private declarations } 源代码网推荐 public 源代码网推荐 { Public declarations } 源代码网推荐 end; 源代码网推荐 function SQLSCMGetLocalServiceStateA(lpszSvc: PChar;dwErr:PDWORD): Integer;cdecl;external "w95scm.dll"; 源代码网推荐 源代码网推荐 var 源代码网推荐 Form1: TForm1; 源代码网推荐 源代码网推荐 implementation 源代码网推荐 源代码网推荐 {$R *.DFM} 源代码网推荐 源代码网推荐 procedure TForm1.Button1Click(Sender: TObject); 源代码网推荐 begin 源代码网推荐 cs.Open; 源代码网推荐 end; 源代码网推荐 源代码网推荐 procedure TForm1.Timer1Timer(Sender: TObject); 源代码网推荐 begin 源代码网推荐 try 源代码网推荐 cs.Active := true; 源代码网推荐 finally 源代码网推荐 if cs.Active then 源代码网推荐 Label1.Caption := "Runnig" 源代码网推荐 else 源代码网推荐 Label1.Caption := "Not Runnig"; 源代码网推荐 end; 源代码网推荐 end; 源代码网推荐 源代码网推荐 procedure TForm1.Button2Click(Sender: TObject); 源代码网推荐 var 源代码网推荐 r,e: DWORD; 源代码网推荐 begin 源代码网推荐 r := SQLSCMGetLocalServiceStateA("MSSQLServer",@e); 源代码网推荐 case r of 源代码网推荐 SERVICE_STOPPED: 源代码网推荐 ShowMessage("Stoped"); 源代码网推荐 SERVICE_START_PENDING: 源代码网推荐 ShowMessage("Starting"); 源代码网推荐 SERVICE_STOP_PENDING: 源代码网推荐 ShowMessage("Stopping"); 源代码网推荐 SERVICE_RUNNING: 源代码网推荐 ShowMessage("Running"); 源代码网推荐 SERVICE_CONTINUE_PENDING: 源代码网推荐 ShowMessage("Restarting"); 源代码网推荐 SERVICE_PAUSE_PENDING: 源代码网推荐 ShowMessage("Pausing"); 源代码网推荐 SERVICE_PAUSED: 源代码网推荐 ShowMessage("Paused"); 源代码网推荐 end; 源代码网推荐 end; 源代码网推荐 源代码网推荐 end. 源代码网推荐 源代码网供稿. |
