📄 createdb.pas
字号:
Exit;
end;
ExecThread('database');
end;
// Create DB and Table
if (bBoth) then begin
startThread;
if Not CreateDB then begin
MessageDlg('不能建立数据库. ', mtInformation, [mbCancel], 0);
Animate1.Active:=false;
WizardNoteBook.ActivePage:='Step2';
Stopthread;
Result:=FALSE;
Exit;
end;
//
//ExecThread('database');
if Not CreateTable then begin
MessageDlg('不能建立表. ', mtInformation, [mbCancel], 0);
Animate1.Active:=false;
WizardNoteBook.ActivePage:='Step2';
StopThread;
Result:=FALSE;
Exit;
end;
//
ExecThread('table');
end;
// Create table
if bTable then begin
startThread;
if Not CreateTable then begin
MessageDlg('不能建立表. ', mtInformation, [mbCancel], 0);
Animate1.Active:=false;
WizardNoteBook.ActivePage:='Step2';
StopThread;
Result:=FALSE;
Exit;
end;
ExecThread('table');
end;
Animate1.Active:=false;
Animate1.Visible:=false;
Result:=TRUE;
end;
// Run a program and wait for it to finish executing
function TMainform.WinExecAndWait32(FileName:String; Visibility : integer):Integer;
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
ExitCode: DWORD;
begin
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then Result := -1 { pointer to PROCESS_INF }
else begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, ExitCode);
Result:=ExitCode;
end;
end;
function Tmainform.GetCompname:string;
var size:Cardinal;
name:Pchar;
begin
Size:=255;
Getmem(Name,size);
GetComputerName(Name,size);
Result:=String(Name);
FreeMem(Name);
end;
//
function Tmainform.GetdeviceNum:String;
var
Reg: TRegistry;
str:string;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\SOFTWARE\XWFD\Setup', True) then begin
str:=Reg.ReadString('DeviceNum');
if str<>'' then begin
str:= IntTOStr((StrToint(str)-1));
Reg.WriteString('DeviceNum',str);
end else begin
Reg.WriteString('DeviceNum','199');
str:='199';
end;
end;
finally
Reg.CloseKey;
Reg.Free;
Result:=Str;
end;
end;
procedure Tmainform.SetdeviceNum(sNum:String);
var
Reg1: TRegistry;
begin
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_LOCAL_MACHINE;
if Reg1.OpenKey('\SOFTWARE\XWFD\Setup', True) then begin
Reg1.WriteString('DeviceNum',sNum);
end;
finally
Reg1.CloseKey;
Reg1.Free;
end;
end;
procedure Tmainform.sysDelay(aMs: Longint);
var
TickCount : LongInt;
begin
TickCount:=GetTickCount;
while GetTickCount - TickCount < aMs do Application.ProcessMessages;
end;
procedure Tmainform.StartThread;
begin
ProgressBar1.Position:=0;
DBThread:=TBarThread.Create(Progressbar1);
end;
procedure Tmainform.StopThread;
begin
if DbThread<>nil then begin
DBThread.Terminate;
end;
end;
procedure Tmainform.ExecThread(str:string);
var i:integer;
begin
sysdelay(6000);
StopThread;
//MessageDlg('Create '+str+' successfully!',mtInformation,[mbOK],0);
ProgressBar1.position:=0;
for i:=1 to 100 do
ProgressBar1.Position:=i;
end;
procedure TMainForm.btnNextClick(Sender: TObject);
var i:integer;
begin
if WizardNoteBook.ActivePage='Step1' then begin
WizardNoteBook.ActivePage:='Step2';
Back.Enabled:=TRUE;
end else if WizardNoteBook.ActivePage='Step2' then begin
WizardNoteBook.ActivePage:='Step3';
Back.Enabled:=FALSE;
btnNext.Enabled:=FALSE;
end else if WizardNoteBook.ActivePage='Step3' then begin
btnFinish.Caption:='结束';
Back.Enabled:=TRUE;
end;
if WizardNotebook.ActivePage='Step2' then begin
try
if not DirectoryExists(eLocation.text) then
if not ForceDirectories(eLocation.text) then begin
MessageDlg('不能建立目录 !',mtwarning,[mbCancel],0);
eLocation.SetFocus;
Exit;
end;
except
MessageDlg('不能建立目录 !',mtwarning,[mbCancel],0);
eLocation.SetFocus;
Exit;
end;
bDB:=FALSE;
bTable:=FALSE;
bBoth:=FALSE;
bSkip:=FALSE;
if rbCdb.Checked then begin
bDB:=TRUE;
bTC:=TRUE;
end;
if rbCtb.Checked then bTable:=TRUE;
if rbBoth.Checked then bBoth:=TRUE;
if rbSkip.Checked then bSkip:=TRUE;
if (bDB) or (bBoth) then begin
GroupBox4.Visible:=TRUE;
cbTc.visible:=FALSE;
end;
if bTable then begin
GroupBox4.Visible:=FALSE;
cbTc.visible:=TRUE;
end;
end else if WizardNotebook.ActivePage='Step3' then begin
if cbTc.Checked then begin
bTC:=TRUE;
end else bTC:=FALSE;
if not DirectoryExists(elocation.Text) then
if Not DirectoryExists(elocation.Text) then Exit;
label12.caption:='请等待一会儿...';
// StartThread;
if ExecuteCreate then begin
label12.caption:='安装结束';
StopThread;
MessageDlg('数据库建立成功!',mtInformation,[mbOK],0);
ProgressBar1.position:=0;
for i:=1 to 100 do
ProgressBar1.Position:=i;
Back.Enabled:=FALSE;
btnNext.Enabled:=FALSE;
btnFinish.Caption:='结束';
end else begin
StopThread;
Back.Enabled :=TRUE;
btnNext.Enabled:=TRUE;
btnFinish.Caption:='放弃';
end;
end else if WIzardNoteBook.ActivePage='Step4' then begin
end;
end;
procedure TMainForm.btnFinishClick(Sender: TObject);
begin
if btnFinish.Caption='放弃' then begin
if MessageDlg(' 你想放弃并退出吗? ', mtInformation, [mbYes, mbNo], 0)=mrNo then begin
Exit;
end;
end;
//Application.Terminate;
Animate1.Active:=false;
Animate1.Visible:=false;
ProgressBar1.Visible:=false;
label20.Caption:=' 请等待一会儿...';
btnFinish.Enabled:=FALSE;
StopThread;
Close;
end;
procedure TMainForm.BackClick(Sender: TObject);
begin
if WizardNoteBook.ActivePage='Step2' then begin
WizardNoteBook.ActivePage:='Step1';
Back.Enabled:=FALSE;
end else if WizardNoteBook.ActivePage='Step3' then
WizardNoteBook.ActivePage:='Step2'
else if WizardNoteBook.ActivePage='Step1' then begin
btnFinish.Caption:='放弃';
Back.Enabled:=FALSE;
end;
if (bDB) or (bBoth) then begin
GroupBox4.Visible:=TRUE;
cbTc.Visible:=FALSE;
end;
if bTable then begin
cbTC.Visible:=TRUE;
GroupBox4.Visible:=FALSE;
end;
if WizardNotebook.ActivePage='Step2' then begin
StopThread;
end else if WizardNotebook.ActivePage='Step3' then begin
end else if WizardNotebook.ActivePage='Step4' then begin
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -