This procedure saves the database of the register of the sistema:procedure TForm1.SaveRegister(iTimeOutMs: DWORD; sFileName: SHortString); Var Ticks: DWord; StartInfo: TStartupInfo; ProcessInfo: TProcessInformation; End: Boolean; Begin FillChar (StartInfo, SizeOf (StartInfo), #0); StartInfo.cb: = SizeOf (StartInfo); If CreateProcess (Nil, PChar('regedit.exe /se ' +sFileName), Nil, Nil, False, 0, Nil, Nil, StartInfo, ProcessInfo) Then Begin ShowMessage('Guardando la BD...) '); Ticks: = GetTickCount; End: = False; Repeat Case WaitForSingleObject(ProcessInfo.hProcess, 200) Of WAIT_OBJECT_0: end: = True; End; Application.ProcessMessages; Prevents the application blocking Sleep (250); Until (end) Or (GetTickCount - tick > iTimeOutMs); If (end = False) Then ShowMessage('TimeOut!) Not done correctly... ') Else ShowMessage('Se ha guardado la BD.) ') End else ShowMessage('Error ael inciar el guardado de la BD!) '); end; Their
Weiterlesen...