📄 insdb.pas
字号:
unit insdb;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, SUIForm, SUIButton, ComCtrls, StdCtrls;
type
Tfrmdb = class(TForm)
suiForm1: TsuiForm;
Label1: TLabel;
ProgressBar1: TProgressBar;
btnclose: TsuiButton;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure btncloseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmdb: Tfrmdb;
iLoop:integer;
implementation
{$R *.dfm}
procedure Tfrmdb.FormShow(Sender: TObject);
begin
left:=(screen.Width-width)div 2;
top:=(screen.Height-height)div 2;
end;
procedure Tfrmdb.btncloseClick(Sender: TObject);
begin
if application.MessageBox('你确定要退出数据库安装?','提示',mb_yesno+mb_iconquestion)=idyes then
close;
end;
procedure Tfrmdb.FormCreate(Sender: TObject);
var
wnd:Hwnd;
cmdline:string;
begin
wnd:=findWindow(nil,'SQL SERVER 服务管理器');
cmdline:=extractfilepath(paramstr(0))+'startsql';
sleep(5000);
if wnd<>0 then
winexec(pchar(cmdline),sw_hide)
else
begin
winexec(pchar('sqlmangr.exe'),SW_MINIMIZE);
sleep(100000);
wnd:=findWindow(nil,'SQL SERVER 服务管理器');
if wnd=0 then
begin
application.MessageBox('您没有安装数据库服务器!','警告',mb_ok+mb_iconwarning);
application.Terminate;
end;
winexec(pchar(cmdline),sw_hide);
end;
if not fileExists(extractfilepath(paramstr(0))+'\Data.sql') then
begin
messageBox(application.Handle,pchar('数据库文件错误'),pchar('警告'),mb_ok+mb_iconWarning);
application.Terminate;
exit;
end;
cmdline:='OSQL -U sa -P -d master -i '+cmdline+'\Data.sql';
winexec(pchar(cmdline),sw_hide);
timer1.Enabled :=true;
end;
procedure Tfrmdb.Timer1Timer(Sender: TObject);
begin
iLoop:=iLoop+1;
progressBar1.Position:=iLoop div 3;
if iLoop=300 then begin
messageBox(application.Handle,pchar('数据库安装完成!'),pchar('提示'),mb_ok+mb_iconInformation);
timer1.Enabled:=false;
close
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -