const
MB_ICONINFORMATION = $40;
TitleCaption='提示......';
SERVICE_STOPPED=1;
// Stopped == SQL //==
SERVICE_START_PENDING=2;
// Starting == //==
SERVICE_STOP_PENDING=3;
// Stopping == Check //==
SERVICE_RUNNING=4;
// Running == //==
SERVICE_CONTINUE_PENDING=5;
// Restarting after being paused == ISRun //==
SERVICE_PAUSE_PENDING=6;
// Pausing == -ning //==
SERVICE_PAUSED=7;
//Paused == //==
function SQLSCMGetLocalServiceStateA(lpszSvc: PChar;dwErr:LongWord): Integer;
//==
external 'SQLSCMGetLocalServiceStateA@files:w95scm.dll cdecl';
//==
function MessageBox(hWnd: Integer;
lpText, lpCaption: String;
uType: Cardinal): Integer;
external 'MessageBoxA@user32.dll stdcall';
procedure CheckMSSQLServer;
var //判断SQLServer 当前运行状态
r,e: LongWORD;
hWnd: Integer;
begin
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
r := SQLSCMGetLocalServiceStateA('MSSQLServer',e);
case r of
SERVICE_STOPPED:
MessageBox(hWnd,'Stoped,没有启动或已停止MSSQLServer服务。',TitleCaption, MB_OK or MB_ICONINFORMATION);
SERVICE_START_PENDING:
MessageBox(hWnd,'Starting,正在启动MSSQLServer服务。',TitleCaption, MB_OK or MB_ICONINFORMATION);
SERVICE_STOP_PENDING:
MessageBox(hWnd,'Stopping,正在关闭MSSQLServer服务。',TitleCaption, MB_OK or MB_ICONINFORMATION);
SERVICE_RUNNING:
MessageBox(hWnd,'Running,MSSQLServer服务已运行。',TitleCaption, MB_OK or MB_ICONINFORMATION);
SERVICE_CONTINUE_PENDING:
MessageBox(hWnd,'Restarting,正在重新启动MSSQLServer服务。',TitleCaption, MB_OK or MB_ICONINFORMATION);
SERVICE_PAUSE_PENDING:
MessageBox(hWnd,'Pausing,正在暂停MSSQLServer服务。',TitleCaption, MB_OK or MB_ICONINFORMATION);
SERVICE_PAUSED:
MessageBox(hWnd,'Paused,MSSQLServer服务已暂停。',TitleCaption, MB_OK or MB_ICONINFORMATION);
end;
end;